Skip to content

Commit 54d6ace

Browse files
committed
Capturing template and its argument list so class
can be highlighted differently as a template keyword than as an actual class
1 parent 0cb922e commit 54d6ace

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
### Changes
44

5-
* Namespace highlighting
5+
* Adding namespace highlighting
66
* Fixing several preprocessor directive highlighting bugs
77
* Fixing a class/struct highlighting bug
8+
* Fixing incorrect highlighting when using the class keyword in a template parameter list
89

910
## 0.1.0 - Initial Release
1011

grammars/cpp.cson

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@
9797
{
9898
'include': '#char-literals'
9999
},
100+
{
101+
'include': '#template'
102+
},
100103
{
101104
'include': '#function'
102105
},
@@ -155,6 +158,9 @@
155158
{
156159
'include': '#char-literals'
157160
},
161+
{
162+
'include': '#template'
163+
},
158164
{
159165
'include': '#function'
160166
},
@@ -241,9 +247,10 @@
241247
'name': 'invalid.deprecated.cpp'
242248

243249
# storage types
244-
# NOTE: class, struct, and union are highlighted in '#class'
250+
# NOTE: class, struct, and union are highlighted in '#class';
251+
# template is highlighted in '#template'
245252
'storage-types':
246-
'match': '\\b(?:auto|bool|char|char16_t|char32_t|decltype|double|enum|float|int|long|short|signed|template|unsigned|void|wchar_t)\\b'
253+
'match': '\\b(?:auto|bool|char|char16_t|char32_t|decltype|double|enum|float|int|long|short|signed|unsigned|void|wchar_t)\\b'
247254
'name': 'storage.type.cpp'
248255

249256
# storage modifiers
@@ -463,3 +470,64 @@
463470
'include': '#after-function'
464471
}]
465472
}]
473+
474+
# template
475+
'template':
476+
'begin': '\\btemplate\\b'
477+
'beginCaptures':
478+
'0':
479+
'name': 'storage.type.cpp'
480+
'end': '(?=>)'
481+
'patterns': [{
482+
'begin': '(?=<)'
483+
'end': '(?=>)'
484+
'patterns': [{
485+
'include': '#block-comment'
486+
},
487+
{
488+
'include': '#line-comment'
489+
},
490+
{
491+
'include': '#numeric-literals'
492+
},
493+
{
494+
'include': '#language-constants'
495+
},
496+
{
497+
'include': '#storage-types'
498+
},
499+
{
500+
'match': '\\bclass\\b'
501+
'name': 'storage.type.cpp'
502+
},
503+
{
504+
'include': '#control-keywords'
505+
},
506+
{
507+
'include': '#operator-keywords'
508+
},
509+
{
510+
'include': '#cast-operator-keywords'
511+
},
512+
{
513+
'include': '#deprecated-keywords'
514+
},
515+
{
516+
'include': '#storage-modifiers'
517+
},
518+
{
519+
'include': '#support-types'
520+
},
521+
{
522+
'include': '#string'
523+
},
524+
{
525+
'include': '#raw-string'
526+
},
527+
{
528+
'include': '#char-literals'
529+
},
530+
{
531+
'include': '#function'
532+
}]
533+
}]

0 commit comments

Comments
 (0)