vim/after/syntax/c.vim

37 lines
1.7 KiB
VimL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

" 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 '\(<<=\|==\|!=\|<=\|>=\|&&\|||\|++\|--\|->\*\|->\)'
" TODO: Match : in ternary operator as 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