vim/after/syntax/c.vim

44 lines
1.9 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_doxygen = get(g:, 'c_doxygen', 1)
if exists('g:c_doxygen') && g:c_doxygen
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.*$\|$\)'
syn match cDoxygenTodo 'todo' contained
syn region cComment oneline start='\/\/\/\s*[\\@]\zetodo\s\+' end='$' contains=cDoxygenTodo
hi default link cDoxygen SpecialComment
hi default link cDoxygenTodo Todo
endif
" Match curly braces with cDelimiter highlight group
syn region cBlock matchgroup=cDelimiter start="{" end="}" transparent fold
" Define additional highlight groups
hi default link cDelimiter Delimiter
hi default link cFunction Function