Skip to content

Add support for chrono literals #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions syntax/cpp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ if !exists("cpp_no_cpp14")
syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
syn match cppChronoLiteralsDecimal display "\(\<0\|\<[1-9]\d*\)\(h\|min\|s\|ms\|us\|ns\)\>"
syn match cppChronoLiteralsFloat display "\<\d\+\.\d*[eE]\=[\-+]\=\d\+\(h\|min\|s\|ms\|us\|ns\)\>"
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
Copy link
Contributor

@rhysd rhysd Feb 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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\)\>"

syn case match
endif

Expand All @@ -71,6 +77,11 @@ hi def link cppConstant Constant
hi def link cppRawStringDelimiter Delimiter
hi def link cppRawString String
hi def link cppNumber Number
hi def link cppChronoLiteralsDecimal Number
hi def link cppChronoLiteralsFloat Number
hi def link cppChronoLiteralsBinary Number
hi def link cppChronoLiteralsHexa Number
hi def link cppChronoLiteralsOctal Number

let b:current_syntax = "cpp"

Expand Down