Conversation
syntax/cpp.vim
Outdated
| hi def link cppNumber Number | ||
| hi def link cppChronoLiteralsDecimal Number | ||
| hi def link cppChronoLiteralsFloat Number | ||
| hi def link cppChronoLiteralsFloat Number |
|
I think these kind of literals can be highlighted more generally. http://en.cppreference.com/w/cpp/language/user_literal e.g. int main() {
1.2_w; // calls operator "" _w(1.2L)
u"one"_w; // calls operator "" _w(u"one", 3)
12_w; // calls operator "" _w("12")
"two"_w; // error: no applicable literal operator
}If we determine to define the chrono literals, we also need to define highlights for user defined literals. If not, IMO, we should not highlight literals defined in standard library also for consistency. |
| syn match cppChronoLiteralsFloat display "\.\d\+\([eE][\-+]\=\d\+\)\=\(h\|min\|s\|ms\|us\|ns\)\>" | ||
| syn match cppChronoLiteralsBinary display "\<0b[01]\('\=[01]\+\)*\(h\|min\|s\|ms\|us\|ns\)\>" | ||
| syn match cppChronoLiteralsHexa display "\<0x\x\('\=\x\+\)*\(h\|min\|s\|ms\|us\|ns\)\>" | ||
| syn match cppChronoLiteralsOctal display "\<0\o\+\(h\|min\|s\|ms\|us\|ns\)\>" contains=cOctalZero |
There was a problem hiding this comment.
If we determine to highlight them, how about adding them to existing number highlights as below?
syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\|h\|min\|s\|ms\|us\|ns\)\>"|
The point looks that we should highlight identifiers defined in standard library or not. Currently syntax/cpp.vim highlights no identifier defined in standard library as long as I know. |
|
From my point of view, the chrono literals were just «enhanced numbers», that's why I have proposed to highlight them in the same color than the numbers. |
|
yeah I understand that standard user-defined literals are near the language core feature and it looks better if they are highlighted as well as builtin literals such as |
Allow the duration to be highlighted as the numbers.
See this link for more informations on chrono literals:
http://en.cppreference.com/w/cpp/chrono/duration