Improve C/C++ syntax highlighting
This commit is contained in:
parent
b1af2d0eff
commit
a7630ace55
35
after/syntax/c.vim
Normal file
35
after/syntax/c.vim
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
" Language: C
|
||||||
|
" Description: Additional C syntax file.
|
||||||
|
" Author: Kenneth Benzie (Benie) <k.benzie83@gmail.com>
|
||||||
|
" Last Modified: September 04, 2016
|
||||||
|
|
||||||
|
" Match delimiter expressions: (expr) {expr} : ;
|
||||||
|
" ^ ^ ^ ^ ^ ^
|
||||||
|
syn match cDelimiter '[()\[\]{}:;]'
|
||||||
|
" Match single character operators, ordering within the [] is important
|
||||||
|
syn match cOperator '[\*=\.\^\~+-,&|!%]'
|
||||||
|
" Match single character operators if they are surrounded by white space: / < >
|
||||||
|
" ^ ^ ^
|
||||||
|
syn match cOperator '\(\s\zs\/\s\ze\|\s\zs<\s\ze\|\s\zs>\s\ze\)'
|
||||||
|
" Match multi character operators
|
||||||
|
syn match cOperator '\(+=\|-=\|\*=\|/=\|%=\|\ˆ=\|&=\||=\|<<\|>>\|>>=\)'
|
||||||
|
syn match cOperator '\(<<=\|==\|!=\|<=\|>=\|&&\|||\|++\|--\|->\*\|->\)'
|
||||||
|
" Match function expressions: expr()
|
||||||
|
" ^^^^
|
||||||
|
syn match cFunction '\w[A-Za-z0-9_]*\ze\s*('
|
||||||
|
" Match label expressions: expr:
|
||||||
|
" ^^^^
|
||||||
|
syn match cLabel '^\s*\w[A-Za-z0-9_]\+\ze::\@!' contains=cppAccess
|
||||||
|
|
||||||
|
" Match Doxygen comments
|
||||||
|
let g:c_enable_doxygen_highlights = get(g:, 'c_enable_doxygen_highlights', 1)
|
||||||
|
if g:c_enable_doxygen_highlights
|
||||||
|
syn region cDoxygen oneline matchgroup=cComment start='\/\/\/\s*@brief\s\+' end='$'
|
||||||
|
syn region cDoxygen oneline matchgroup=cComment start='\/\/\/\s*@tparam\s\+' end='\(\s.*$\|$\)'
|
||||||
|
syn region cDoxygen oneline matchgroup=cComment start='\/\/\/\s*@param\(\[\(\|in\|out\|inout\)\]\)\=\s\+' end='\(\s.*$\|$\)'
|
||||||
|
hi default link cDoxygen SpecialComment
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Define additional highlight groups
|
||||||
|
hi default link cDelimiter Delimiter
|
||||||
|
hi default link cFunction Function
|
@ -1,30 +1,26 @@
|
|||||||
" File: cpp.vim
|
|
||||||
" Language: C++
|
" Language: C++
|
||||||
" Description: Additional C++ syntax file.
|
" Description: Additional C++ syntax file.
|
||||||
" Author: Kenneth Benzie (Benie) k.benzie83@gmail.com
|
" Author: Kenneth Benzie (Benie) k.benzie83@gmail.com
|
||||||
" Last Modified: September 02, 2016
|
" Last Modified: September 04, 2016
|
||||||
|
|
||||||
" Match delimiter expressions: <expr>, (expr) {expr} ex::pr
|
" Match delimiter expressions: <expr>, ex::pr
|
||||||
" ^ ^ ^ ^ ^ ^ ^^
|
" ^ ^ ^^
|
||||||
syn match cppDelimiter '\([()\[\]{}<>]\|::\)'
|
syn match cppDelimiter '\(<\|>\|::\)'
|
||||||
" Match keyword logic operators
|
" Match keyword logic operators
|
||||||
syn keyword cppOperator and and_eq bitand bitor compl
|
syn keyword cppOperator and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq
|
||||||
syn keyword cppOperator not not_eq or or_eq xor xor_eq
|
|
||||||
" Match single character operators, ordering within the [] is important
|
|
||||||
syn match cppOperator '[\*=\.\^\~+-,;&|!%]'
|
|
||||||
" Match single character operators if they are surrounded by white space: / < >
|
" Match single character operators if they are surrounded by white space: / < >
|
||||||
" ^ ^ ^
|
" ^ ^ ^
|
||||||
syn match cppOperator '\(\s\zs\/\s\ze\|\s\zs<\s\ze\|\s\zs>\s\ze\)'
|
syn match cppOperator '\(\s\zs\/\s\ze\|\s\zs<\s\ze\|\s\zs>\s\ze\)'
|
||||||
" Match multi character operators
|
|
||||||
syn match cppOperator '\(+=\|-=\|\*=\|/=\|%=\|\ˆ=\|&=\||=\|<<\|>>\|>>=\)'
|
|
||||||
syn match cppOperator '\(<<=\|==\|!=\|<=\|>=\|&&\|||\|++\|--\|->\*\|->\)'
|
|
||||||
" Match function expressions: foo()
|
|
||||||
" ^^^
|
|
||||||
syn match cppFunction '\w[A-Za-z0-9_]*\ze\s*('
|
|
||||||
" Match nested namespace expressions: expr::
|
" Match nested namespace expressions: expr::
|
||||||
" ^^^^
|
" ^^^^
|
||||||
syn match cppStorageClass '\w[A-Za-z0-9_]*\ze::'
|
syn match cppStorageClass '\w[A-Za-z0-9_]*\ze::'
|
||||||
|
" " Match multi character operators, override cppDelimiter matches for < >
|
||||||
|
" " ^ ^
|
||||||
|
syn match cppOperator '\(<<\|>>\|>>=\|<<=\|<=\|>=\|->\*\|->\)'
|
||||||
|
|
||||||
" Define additional highlight groups
|
" Define additional highlight groups
|
||||||
hi default link cppDelimiter Delimiter
|
hi default link cppDelimiter Delimiter
|
||||||
hi default link cppFunction Function
|
|
||||||
|
" Override default highlight groups
|
||||||
|
hi link cppCast Operator
|
||||||
|
hi link cppModifier Statement
|
||||||
|
Loading…
x
Reference in New Issue
Block a user