This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
253 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
" We define our own handling for if, while and for, so remove them from | ||
" the simple keyword matching used by default | ||
syn clear cConditional | ||
syn clear cRepeat | ||
|
||
syn keyword cConditional switch else | ||
syn keyword cRepeat do | ||
|
||
" Matches for types in function parameters | ||
syn match cJCParamVoid "\<void\>" contained | ||
syn match cJCParamType "\<\(\(const\|restrict\|volatile\|signed\|unsigned\|struct\|enum\)[ \t*]\+\)*\I\i*[ \t*]\+\I"he=e-1 contained containedin=cJCFor | ||
|
||
" Matchs for types in variables and function declarations | ||
syn match cJCTypeInDecl "^\s*\(\(inline\|const\|restrict\|extern\|GLOBAL\|static\|register\|auto\|volatile\|virtual\|signed\|unsigned\|struct\)[ \t*]\+\)*\I\i*\([ \t*]\+\(const\|restrict\|volatile\)\)*[ \t*]*" contained | ||
syn match cJCDecl "^\s*\(inline\s\+\)\=\(\I\i*[ \t*]\+\)\+\s*\I" contains=cJCTypeInDecl | ||
|
||
" Matches function declarations and definitions | ||
syn region cJCFunc start="^\(\(inline\|const\|extern\|GLOBAL\|static\|register\|auto\|volatile\|virtual\|signed\|unsigned\|struct\)[ \t*]\+\)*\I\i*\s\+\**\s*\I[[:ident:]:]*\s*(" end=")" contains=CJCParamVoid,cJCParamType,cJCTypeInDecl,cComment | ||
syn region cJCFunc start="^\I\i*\s*(" end=")" contains=CJCParamVoid,cJCParamType | ||
|
||
" Matches type casts | ||
syn match cJCTypeCast "(\@<=\s*\(\(const\|restrict\|volatile\|signed\|unsigned\|struct\|enum\)[ \t*]\+\)*\I\i*\s*\**\s*\(restrict\)\?\s*)\s*[^) \t;,{]"me=e-2 | ||
"syn match cJCTypeCast "[[:space:],(]*(\I\i*\s*\**\s*)\s*"me=e-1,ms=s+1 | ||
|
||
|
||
" Matchs function calls and if/else/while, so they are not | ||
" accidentally matched by things above. | ||
syn match cJCFctCall "\i\s*(\s*\(\(const\|restrict\|volatile\|signed\|unsigned\|struct\|enum\)[ \t*]\+\)*\I\i*\s*\**\s*)" | ||
syn region cJCIfParent matchgroup=cStatement start="(" end=")" contained contains=ALLBUT,@cParenGroup,cJCTypeInDecl | ||
syn region cJCIf matchgroup=cConditional start="\(\s*\(\<else\s\+\)\=\<if\|\s*\<while\)\s*("rs=e-1 matchgroup=NONE end="." contains=cJCIfParent | ||
syn region cJCFor matchgroup=cConditional start="\<for\s*(" end=")" contains=ALLBUT,@cParenGroup,cJCTypeInDecl,cErrInBracket | ||
|
||
" Put our custom matching things in clusters that are used in ALLBUT places | ||
" in vim standard C highlighting, because we don't want them to match there. | ||
syn cluster cParenGroup add=cJCTypeInDecl,cJCParamType | ||
syn cluster cPreProcGroup add=cJCParamType,cJCTypeCast | ||
|
||
" Override some standard C things because cJCDecl matches a bit too easily | ||
syn match cStatement "^\s*return\>."me=e-1 | ||
syn match cStatement "^\s*goto\s\+\I"me=e-1 | ||
syn match cConditional "^\s*case\>."me=e-1 | ||
syn match cConditional ":\s*$" | ||
|
||
|
||
" Delete the keyword-based cType matching, it just gets in the way | ||
syn clear cType | ||
|
||
" And finally the thing we wanted to do: highlight all the types using cType | ||
" highlight, not just the ones matching C keywords. | ||
hi link cJCType cType | ||
hi link cJCParamType cType | ||
hi link cJCTypeInDecl cType | ||
hi link cJCTypeCast cType | ||
|
||
" Uncomment these for debug mode: very visible highlight of what we match | ||
"hi cJCTypeCast guibg=#ff0000 | ||
"hi cJCDecl guibg=#d08080 | ||
"hi cJCType guibg=#FFFF00 | ||
"hi cJCTypeInDecl guibg=#FF00FF | ||
"hi cJCFunc guibg=#00FF00 | ||
"hi cJCParamType guibg=#0000FF | ||
"hi cJCIf guibg=#00FFFF | ||
"hi cJCFor guibg=#00FF80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
" Delete the keyword-based cType matching, it just gets in the way | ||
syn clear cppType | ||
|
||
" Redefine cppStatement so that "new" is not a keyword, so the below can match | ||
" it | ||
syn clear cppStatement | ||
|
||
syn keyword cJCNewStatement new contained | ||
hi def link cJCNewStatement cppStatement | ||
|
||
syn keyword cppStatement delete this friend using | ||
if !exists("cpp_no_cpp20") | ||
syn keyword cppStatement co_await co_return co_yield requires | ||
endif | ||
|
||
" Detect type in "new" expressions | ||
syn match cJCNew "new \I[[:ident:]:]*" contains=cJCNewStatement | ||
|
||
" Match various well known things from the STL that are known to contain types | ||
" in their template arguments | ||
syn match cJCCppCast "\(static_cast\|dynamic_cast\|reinterpret_cast\|const_cast\|time_point_cast\|make_unique\|make_shared\|make_optional\)<\zs\I[[:ident:]:&*]*>"me=e-1 | ||
|
||
" Redefine several things from the C syntax to handle templates and references | ||
" in addition to the other things | ||
syn clear cJCTypeInDecl | ||
syn clear cJCDecl | ||
syn clear cJCFunc | ||
syn clear cJCParamType | ||
|
||
syn match cJCTypeInDecl "^\s*\(\(inline\|const\|restrict\|extern\|GLOBAL\|static\|register\|auto\|volatile\|virtual\|signed\|unsigned\|struct\)[ \t*]\+\)*\I[[:ident:]:<>]*&\?\([ \t*]\+\(const\|restrict\|volatile\)\)*[ \t*]*" contained | ||
syn match cJCDecl "^\s*\(inline\s\+\)\=\(\I[[:ident:]:<>]*&\?[ \t*]\+\)\+\s*\I" contains=cJCTypeInDecl | ||
|
||
syn region cJCFunc start="^\t*\(\(inline\|const\|extern\|GLOBAL\|static\|register\|auto\|volatile\|virtual\|signed\|unsigned\|struct\)[ \t*]\+\)*\I[[:ident:]:<>]*\s\+\**\s*\I[[:ident:]:]*\s*(" end=")" contains=CJCParamVoid,cJCParamType,cJCTypeInDecl,cComment | ||
|
||
" This matches constructors, but only if they are in the first column for now | ||
" (no identation). Otherwise it also matches all function calls, and that | ||
" breaks a lot of things. | ||
syn region cJCFunc start="^\I[[:ident:]:<>]*\s*(" end=")" contains=CJCParamVoid,cJCParamType | ||
|
||
syn match cJCParamType "\<\(\(const\|restrict\|volatile\|signed\|unsigned\|struct\|enum\)[ \t*]\+\)*\I[[:ident:]:<>]*&\?[ \t*]\+\I"he=e-1 contained containedin=cJCFor | ||
|
||
hi link cJCNew cType | ||
|
||
hi link cJCCppCast cType | ||
hi link cJCTypeInDecl cType | ||
hi link cJCParamType cType | ||
|
||
" Uncomment these for debug mode: very visible highlight of what we match | ||
"hi cJCCppCast guibg=#00FF80 | ||
"hi cJCFunc guibg=#00FF00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.