├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── grammars └── cpp.cson ├── package.json ├── settings └── language-cpp14.cson └── snippets └── language-cpp14.cson /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.6.2 2 | 3 | ### Changes 4 | 5 | * Fixing incorrect highlighting with a template of a template 6 | 7 | 8 | ## 0.6.1 9 | 10 | ### Changes 11 | 12 | * Fixing incorrect indentation in some switch statements (thanks to vmrob!) 13 | 14 | ## 0.6.0 15 | 16 | ### Changes 17 | 18 | * Adding more file extensions 19 | * No longer highlighting keywords in the error, pragma, and warning preprocessor directives 20 | 21 | ## 0.5.0 22 | 23 | ### Changes 24 | 25 | * Highlighting C++ attributes 26 | * Doxygen keywords are now highlighted by default 27 | * Recognizing more C++ file extensions (cc, cp, cxx, inl) 28 | * Fixing a bug where destructors were not properly highlighted 29 | 30 | ## 0.4.2 31 | 32 | ### Changes 33 | 34 | * Fixing a bug where comments were not highlighted around namespaces and enums 35 | 36 | ## 0.4.1 37 | 38 | ### Changes 39 | 40 | * Fixing a bug where operator overload functions were not highlighted 41 | 42 | ## 0.4.0 43 | 44 | ### Changes 45 | 46 | * Adding enum highlighting 47 | * Adding snippets for common STL containers 48 | * Highlighting \_\_func\_\_, \_\_FILE\_\_, \_\_FUNCTION\_\_, and \_\_LINE\_\_ 49 | * Fixing incorrect highlighting when preceding a function with the insertion operator 50 | 51 | ## 0.3.0 52 | 53 | ### Changes 54 | 55 | * Highlighting more doxygen keywords 56 | * Adding snippets 57 | * Adding auto-indent settings 58 | 59 | ## 0.2.0 60 | 61 | ### Changes 62 | 63 | * Adding namespace highlighting 64 | * Fixing several preprocessor directive highlighting bugs 65 | * Fixing a class/struct highlighting bug 66 | * Fixing incorrect highlighting when using the class keyword in a template parameter list 67 | 68 | ## 0.1.0 - Initial Release 69 | 70 | ### Changes 71 | 72 | * C++11 and C++14 keywords 73 | * Doxygen keywords 74 | * Binary literals 75 | * Digit separators 76 | * Raw strings 77 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 John B Wilkes III 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # language-cpp14 package 2 | 3 | Syntax highlighting for C++14. 4 | 5 | ### Features 6 | 7 | * C++11 and C++14 keywords 8 | * Doxygen keywords 9 | * Binary literals 10 | * Digit separators 11 | * Raw strings 12 | * Attributes 13 | * C++ snippets 14 | 15 | ### Doxygen 16 | 17 | This package marks doxygen keywords. Most syntax themes will highlight them with the same color as keywords. To change this, add the following to your styles.less file: 18 | 19 | ```less 20 | atom-text-editor::shadow .keyword.other.documentation 21 | { 22 | color: red; 23 | } 24 | ``` 25 | 26 | ### License 27 | 28 | MIT 29 | -------------------------------------------------------------------------------- /grammars/cpp.cson: -------------------------------------------------------------------------------- 1 | 'scopeName': 'source.cpp' 2 | 'name': 'C++14' 3 | 4 | 'fileTypes': [ 5 | 'c++' 6 | 'cc' 7 | 'cp' 8 | 'cpp' 9 | 'cxx' 10 | 'h' 11 | 'h++' 12 | 'hh' 13 | 'hpp' 14 | 'hxx' 15 | 'inc' 16 | 'inl' 17 | 'ipp' 18 | 'tcc' 19 | 'tpp' 20 | ] 21 | 22 | # control keywords 23 | 'patterns': [{ 24 | # preprocessor 25 | 'begin': '(?=#)' 26 | 'end': '(?) 52 | { 53 | 'begin': '<' 54 | 'end': '>' 55 | 'name': 'string.quoted.other.lt-gt.include.cpp' 56 | }, 57 | { 58 | 'include': '#line-comment' 59 | }, 60 | { 61 | 'include': '#block-comment' 62 | }] 63 | }, 64 | # TODO: highlight common pragma keywords 65 | # error, pragma, and warning 66 | { 67 | 'begin': '#\\s*(error|pragma|warning)\\b' 68 | 'beginCaptures': 69 | '1': 70 | 'name': 'keyword.control.cpp' 71 | 'end': '(?|#|%|"|\\.|::|\\||-{2,3})|(?:a|addindex|addtogroup|anchor|arg|attention|author|authors|b|brief|bug|c|callergraph|callgraph|category|cite|class|code|cond|copybrief|copydetails|copydoc|copyright|date|def|defgroup|deprecated|details|diafile|dir|docbookonly|dontinclude|dot|dotfile|e|else|elseif|em|endcode|endcond|enddocbookonly|enddot|endhtmlonly|endif|endinternal|endlatexonly|endlink|endmanonly|endmsc|endparblock|endrtfonly|endsecreflist|endverbatim|enduml|endxmlonly|enum|example|exception|extends|file|fn|headerfile|hidecallergraph|hidecallgraph|hideinitializer|htmlinclude|htmlonly|idlexcept|if|ifnot|image|implements|include|includelineno|ingroup|internal|invariant|interface|latexinclude|latexonly|li|line|link|mainpage|manonly|memberof|msc|mscfile|n|name|namespace|nosubgrouping|note|overload|p|package|page|par|paragraph|parblock|post|pre|private|privatesection|property|protected|protectedsection|protocol|public|publicsection|pure|ref|refitem|related|relates|relatedalso|relatesalso|remark|result|return|returns|retval|rtfonly|sa|secreflist|section|see|short|showinitializer|since|skip|skipline|snippet|startuml|struct|subpage|subsection|subsubsection|tableofcontents|test|throw|throws|todo|tparam|typedef|union|until|var|verbatim|verbinclude|version|vhdlflow|warning|weakgroup|xmlonly|xrefitem)\\b)' 225 | 'name': 'comment.block.documentation.cpp keyword.other.documentation.doxygen' 226 | 227 | 'doxygen-param': 228 | 'match': '([@\\\\]param)\\b(?:\\s*(\\[(?:in|in,out|out)\\]))?' 229 | 'captures': 230 | '1': 231 | 'name': 'comment.block.documentation.cpp keyword.other.documentation.doxygen' 232 | '2': 233 | 'name': 'comment.block.documentation.cpp keyword.other.documentation.doxygen' 234 | 235 | # line comment 236 | 'line-comment': 237 | 'begin': '(?=//)' 238 | 'end': '\\n' 239 | 'name': 'comment.line.double-slash.cpp' 240 | # doxygen 241 | 'patterns': [{ 242 | # start with "///" or "//!" but not "////" 243 | 'begin': '(? 409 | # TODO: Recursively match template args 410 | 'function': 411 | 'match': '(?:[_a-zA-Z]\\w*(?:\\s*<(?:[^<].*)?>\\s*)?::)*(?:(?:~?[_a-zA-Z]\\w*(?:\\s*<(?:[^<].*)?>\\s*)?)|(?:operator\\b[^\\(]+))\\s*\\(' 412 | 'name': 'meta.function.cpp' 413 | 'captures': 414 | '0': 415 | 'patterns': [{ 416 | 'begin': '<' 417 | 'end': '>' 418 | 'patterns': [{ 419 | 'include': '$base' 420 | }] 421 | }, 422 | { 423 | 'match': '\\boperator\\b' 424 | 'name': 'keyword.control.cpp' 425 | }, 426 | { 427 | 'match': '~?[_a-zA-Z]\\w*' 428 | 'name': 'entity.name.function.cpp' 429 | }] 430 | 431 | # after function 432 | 'after-function': 433 | 'begin': '\\)' 434 | 'end': '(?=;|{)' 435 | 'name': 'meta.after-function' 436 | 'patterns': [{ 437 | 'include': '#block-comment' 438 | }, 439 | { 440 | 'include': '#line-comment' 441 | }, 442 | { 443 | 'include': '#control-keywords' 444 | }, 445 | { 446 | 'include': '#operator-keywords' 447 | }, 448 | { 449 | 'include': '#cast-operator-keywords' 450 | }, 451 | { 452 | 'include': '#special-identifiers' 453 | }, 454 | { 455 | 'include': '#storage-types' 456 | }, 457 | { 458 | 'include': '#storage-modifiers' 459 | }, 460 | { 461 | 'include': '#support-types' 462 | }, 463 | { 464 | 'include': '#language-constants' 465 | }, 466 | { 467 | 'include': '#support-constants' 468 | }, 469 | { 470 | 'include': '#language-variables' 471 | }, 472 | { 473 | 'include': '#numeric-literals' 474 | }, 475 | { 476 | 'include': '#string' 477 | }, 478 | { 479 | 'include': '#raw-string' 480 | }, 481 | { 482 | 'include': '#char-literals' 483 | }, 484 | { 485 | 'include': '#function' 486 | }] 487 | 488 | # namespace 489 | 'namespace': 490 | 'begin': '\\b(namespace)\\b' 491 | 'beginCaptures': 492 | '1': 493 | 'name': 'keyword.control.cpp' 494 | 'end': '(?=;|{)' 495 | 'patterns': [{ 496 | 'match': '\\b([_a-zA-Z]\\w*)\\b' 497 | 'name': 'entity.name.type.cpp' 498 | }, 499 | { 500 | 'include': '#line-comment' 501 | }, 502 | { 503 | 'include': '#block-comment' 504 | }] 505 | 506 | # enum 507 | 'enum': 508 | 'begin': '\\b(enum)\\b' 509 | 'beginCaptures': 510 | '1': 511 | 'name': 'storage.type.cpp' 512 | 'end': '(?=;|{)' 513 | 'name': 'meta.enum-block.cpp' 514 | 'patterns': [{ 515 | 'match': '\\b(?:class|struct)\\b' 516 | 'name': 'storage.type.cpp' 517 | }, 518 | { 519 | # enum name 520 | # TODO: only highlight one 521 | 'match': '\\b([_a-zA-Z]\\w*)\\b' 522 | 'name': 'entity.name.type.cpp' 523 | }, 524 | { 525 | 'include': '#line-comment' 526 | }, 527 | { 528 | 'include': '#block-comment' 529 | }, 530 | { 531 | 'begin': ':' 532 | 'end': '(?=;|{)' 533 | 'patterns':[{ 534 | 'include': '#line-comment' 535 | }, 536 | { 537 | 'include': '#block-comment' 538 | }, 539 | { 540 | 'include': '#storage-types' 541 | }, 542 | { 543 | 'include': '#storage-modifiers' 544 | }, 545 | { 546 | 'include': '#support-types' 547 | }] 548 | }] 549 | 550 | # class, struct, union 551 | # TODO: don't highlight words in template brackets (e.g. < >) 552 | 'class': 553 | 'begin': '\\b(class|struct|union)\\b' 554 | 'beginCaptures': 555 | '1': 556 | 'name': 'storage.type.cpp' 557 | 'end': ';' 558 | 'name': 'meta.class-struct-block.cpp' 559 | 'patterns': [{ 560 | 'begin': '(?<=class|struct|union)' 561 | 'end': '(?=;|{)' 562 | 'patterns': [{ 563 | # base must be included first or keywords will 564 | # not be highlighted 565 | 'include': '$base' 566 | }, 567 | { 568 | # class name 569 | # TODO: only highlight one 570 | 'match': '\\b([_a-zA-Z]\\w*)\\b' 571 | 'name': 'entity.name.type.cpp' 572 | }, 573 | { 574 | # inherited name(s) 575 | 'begin': ':' 576 | 'end': '(?=;|{)' 577 | 'patterns':[{ 578 | # base must be included first or keywords will 579 | # not be highlighted 580 | 'include': '$base' 581 | }, 582 | { 583 | 'match': '\\b([_a-zA-Z]\\w*)\\b' 584 | 'name': 'entity.name.type.inherited.cpp' 585 | }] 586 | }] 587 | }, 588 | { 589 | 'begin': '{' 590 | 'end': '}' 591 | 'patterns': [{ 592 | 'include': '$base' 593 | }, 594 | { 595 | 'include': '#after-function' 596 | }] 597 | }] 598 | 599 | # template 600 | 'template': 601 | 'begin': '\\btemplate\\b' 602 | 'beginCaptures': 603 | '0': 604 | 'name': 'storage.type.cpp' 605 | 'end': '(?=>)' 606 | 'patterns': [{ 607 | 'begin': '(?=<)' 608 | 'end': '(?=>)' 609 | 'patterns': [{ 610 | # recursively include template again 611 | 'include': '#template' 612 | }, 613 | { 614 | 'include': '#block-comment' 615 | }, 616 | { 617 | 'include': '#line-comment' 618 | }, 619 | { 620 | 'include': '#numeric-literals' 621 | }, 622 | { 623 | 'include': '#language-constants' 624 | }, 625 | { 626 | 'include': '#support-constants' 627 | }, 628 | { 629 | 'include': '#storage-types' 630 | }, 631 | { 632 | 'match': '\\bclass\\b' 633 | 'name': 'storage.type.cpp' 634 | }, 635 | { 636 | 'include': '#control-keywords' 637 | }, 638 | { 639 | 'include': '#operator-keywords' 640 | }, 641 | { 642 | 'include': '#cast-operator-keywords' 643 | }, 644 | { 645 | 'include': '#deprecated-keywords' 646 | }, 647 | { 648 | 'include': '#storage-modifiers' 649 | }, 650 | { 651 | 'include': '#support-types' 652 | }, 653 | { 654 | 'include': '#string' 655 | }, 656 | { 657 | 'include': '#raw-string' 658 | }, 659 | { 660 | 'include': '#char-literals' 661 | }, 662 | { 663 | 'include': '#function' 664 | }] 665 | }] 666 | 667 | 'attributes': 668 | 'begin': '\\[\\s*\\[' 669 | 'end': '\\]\\s*\\]' 670 | 'name': 'meta.attributes.cpp' 671 | 'patterns': [{ 672 | 'match': '\\b(?:carries_dependency|deprecated|noreturn)\\b' 673 | 'name': 'keyword.other.cpp' 674 | }, 675 | { 676 | 'include': '#line-comment' 677 | }, 678 | { 679 | 'include': '#block-comment' 680 | }, 681 | { 682 | 'include': '#string' 683 | }, 684 | { 685 | 'include': "#raw-string" 686 | }] 687 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-cpp14", 3 | "version": "0.6.2", 4 | "description": "C++14 language support including new keywords, raw strings, digit separators, and binary literals", 5 | "keywords": [ 6 | "C++", 7 | "C++11", 8 | "C++14", 9 | "doxygen", 10 | "grammar", 11 | "language", 12 | "syntax" 13 | ], 14 | "repository": "https://github.com/jbw3/language-cpp14", 15 | "license": "MIT", 16 | "engines": { 17 | "atom": ">=1.0.0 <2.0.0" 18 | }, 19 | "dependencies": {} 20 | } 21 | -------------------------------------------------------------------------------- /settings/language-cpp14.cson: -------------------------------------------------------------------------------- 1 | '.source.cpp': 2 | 'editor': 3 | 'commentStart': '// ' 4 | 'tabLength': 4 5 | 'increaseIndentPattern': '(?:\\{|:)$|(?:\\bcase\\b.*:.*|\\bdefault\\b:.*)$' 6 | 'decreaseIndentPattern': '(?:^\\s*\\}|\\b(?:case\\b.*|default|private|protected|public):)' 7 | -------------------------------------------------------------------------------- /snippets/language-cpp14.cson: -------------------------------------------------------------------------------- 1 | '.source.cpp': 2 | 3 | 'class': 4 | 'prefix': 'class' 5 | 'body': 'class ${1:Name}\n{\npublic:\n\t${1:Name}($2);\n\n\t~${1:Name}()${3: = default};\n\t${1:Name}(const ${1:Name}& other)${4: = default};\n\t${1:Name}(${1:Name}&& other)${5: = default};\n\t${1:Name}& operator=(const ${1:Name}& other)${6: = default};\n\t${1:Name}& operator=(${1:Name}&& other)${7: = default};\n};' 6 | 7 | 'derived class': 8 | 'prefix': 'classder' 9 | 'body': 'class ${1:Name} : public ${2:Base}\n{\npublic:\n\t${1:Name}($3);\n\n\tvirtual ~${1:Name}()${4: = default};\n\t${1:Name}(const ${1:Name}& other)${5: = default};\n\t${1:Name}(${1:Name}&& other)${6: = default};\n\t${1:Name}& operator=(const ${1:Name}& other)${7: = default};\n\t${1:Name}& operator=(${1:Name}&& other)${8: = default};\n};' 10 | 11 | 'do while': 12 | 'prefix': 'do' 13 | 'body': 'do\n{\n\t${2:/* code */}\n} while (${1:/* condition */});' 14 | 15 | 'for': 16 | 'prefix': 'for' 17 | 'body': 'for (int ${1:i} = 0; ${1:i} < ${2:n}; ++${1:i})\n{\n\t${3:/* code */}\n}' 18 | 19 | 'for iterator': 20 | 'prefix': 'forit' 21 | 'body': 'for (auto ${1:iter} = ${2:list}.begin(); ${1:iter} != ${2:list}.end(); ++${1:iter})\n{\n\t${3:/* code */}\n}' 22 | 23 | 'for each': 24 | 'prefix': 'foreach' 25 | 'body': 'for (${1:int} ${2:var} : ${3:list})\n{\n\t${4:/* code */}\n}' 26 | 27 | 'function': 28 | 'prefix': 'fn' 29 | 'body': '${1:void} ${2:name}(${3:int arg})\n{\n\t${4:/* code */}\n}' 30 | 31 | 'fn prototype': 32 | 'prefix': 'fnp' 33 | 'body': '${1:void} ${2:name}(${3:int arg});' 34 | 35 | 'if': 36 | 'prefix': 'if' 37 | 'body': 'if (${1:/* condition */})\n{\n\t${2:/* code */}\n}' 38 | 39 | 'if ... else': 40 | 'prefix': 'ifelse' 41 | 'body': 'if (${1:/* condition */})\n{\n\t${2:/* code */}\n}\nelse\n{\n\t${3:/* code */}\n}' 42 | 43 | 'lambda function': 44 | 'prefix': 'lambda' 45 | 'body': '[${1:=}]($2){${3:/* code */}}' 46 | 47 | 'main()': 48 | 'prefix': 'main' 49 | 'body': 'int main(int argc, char* argv[])\n{\n\t${1}\n\n\treturn 0;\n}' 50 | 51 | 'struct': 52 | 'prefix': 'struct' 53 | 'body': 'struct ${1:Name}\n{\n\t${2:int member};\n};' 54 | 55 | 'switch': 56 | 'prefix': 'switch' 57 | 'body': 'switch (${1:var})\n{\ncase ${2:0}:\n\t${3:/* code */}\n\tbreak;\ndefault:\n\t${4:/* code */}\n\tbreak;\n}' 58 | 59 | 'try ... catch': 60 | 'prefix': 'try' 61 | 'body': 'try\n{\n\t${1:/* code */}\n}\ncatch (${2:...})\n{\n\t${3:/* code */}\n}' 62 | 63 | 'typedef': 64 | 'prefix': 'typedef' 65 | 'body': 'typedef ${1:int} ${2:name};' 66 | 67 | 'union': 68 | 'prefix': 'union' 69 | 'body': 'union ${1:Name}\n{\n\t${2:int member};\n};' 70 | 71 | 'using': 72 | 'prefix': 'using' 73 | 'body': 'using ${1:std::cout};' 74 | 75 | 'using namespace': 76 | 'prefix': 'usingname' 77 | 'body': 'using namespace ${1:std};' 78 | 79 | 'while': 80 | 'prefix': 'while' 81 | 'body': 'while (${1:/* condition */})\n{\n\t${2:/* code */}\n}' 82 | 83 | # STL 84 | 'cerr': 85 | 'prefix': 'cerr' 86 | 'body': 'std::cerr << $1 << "\\\\n";' 87 | 88 | 'cin': 89 | 'prefix': 'cin' 90 | 'body': 'std::cin >> $1;' 91 | 92 | 'cout': 93 | 'prefix': 'cout' 94 | 'body': 'std::cout << $1 << "\\\\n";' 95 | 96 | 'STL array': 97 | 'prefix': 'array' 98 | 'body': 'std::array<${1:int}, ${2:10}> ${3:name};' 99 | 100 | 'STL list': 101 | 'prefix': 'list' 102 | 'body': 'std::list<${1:int}> ${2:name};' 103 | 104 | 'STL map': 105 | 'prefix': 'map' 106 | 'body': 'std::map<${1:std::string}, ${2:std::string}> ${3:name};' 107 | 108 | 'STL queue': 109 | 'prefix': 'queue' 110 | 'body': 'std::queue<${1:int}> ${2:name};' 111 | 112 | 'STL stack': 113 | 'prefix': 'stack' 114 | 'body': 'std::stack<${1:int}> ${2:name};' 115 | 116 | 'STL tuple': 117 | 'prefix': 'tuple' 118 | 'body': 'std::tuple<${1:int}> ${2:name};' 119 | 120 | 'STL vector': 121 | 'prefix': 'vector' 122 | 'body': 'std::vector<${1:int}> ${2:name};' 123 | --------------------------------------------------------------------------------