vim/after/syntax/c.vim

88 lines
3.4 KiB
VimL

" Language: C
" Description: Additional C syntax file.
" Don't syntax highlight text after #warning or #error
syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend
if !exists('c_no_function') && !exists('cpp_no_function')
" Match function expressions: expr()
" ^^^^
syn match cFunction '\h\w*\ze\s*(' display
hi default link cFunction Function
endif
if !exists('c_no_delimiters') && !exists('cpp_no_delimiters')
" Match delimiter expressions: (expr) {expr} ;
" ^ ^ ^ ^ ^
syn match cDelimiter '[()\[\];:]' display
" Match curly braces with cDelimiter highlight group
syn region cBlock matchgroup=cDelimiter start="{" end="}" transparent fold
hi link cUserCont Delimiter
hi default link cDelimiter cUserCont
endif
if !exists('c_no_operators') && !exists('cpp_no_operators')
" Match: * - . ^ ~ + - , & | ! % ? < > order is important
" ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
syn match cOperator '[\*=\.\^\~+\-,&|!%?><]' display
" Match: / don't override // or /* or */
" ^
syn match cOperator '[\*\/]\@<!\/[\*\/]\@!' display
" Match: (expr) ? true : false;
" ^ ^
syn region cOperatorTernary matchgroup=cOperator start='?' end='::\@!' transparent display
endif
let g:c_doxygen = get(g:, 'c_doxygen', 1)
if exists('g:c_doxygen') && g:c_doxygen
" Match: comment leader
syn match cDoxygenLeader '^\s*\/\/\/' contained display
" Match: @param name description. @retval name description.
" ^^^^ ^^^^
syn region cDoxygenSpecial matchgroup=cDoxygenComment start='@\(param\(\[\(\|in\|out\|in,out\)\]\)\|retval\)\=\s\+' end='\(\s\|$\)' contained display
" Match: @tparam name description.
" ^^^^
syn region cDoxygenSpecial matchgroup=cDoxygenComment start='@tparam\s\+' end='\(\s\|$\)' contained display
" Match: `markdown monospace`
" ^^^^^^^^^^^^^^^^^^^^
syn region cDoxygenSpecial start='`' end='`' contained contains=@NoSpell,cDoxygenLeader
" Match: @brief Description. @return Description.
" ^^^^^^^^^^^^ ^^^^^^^^^^^^
syn region cDoxygenSpecial matchgroup=cDoxygenComment start='@\(brief\|return[s]\?\|attention\)' end='\(^\s*\/\/\/\s*$\|^\(\s*\/\/\/\)\@!\|^\s*\/\/\/\s*\ze@\)' contained contains=@Spell,cDoxygenLeader,cDoxygenSpecial display
" Match: @def MACRO
" ^^^^^
syn region cDoxygenSpecial matchgroup=cDoxygenComment start='@def' end='$' contained display
" Match: something ///< description.
" ^^^^^^^^^^^^
syn region cDoxygenSpecial matchgroup=cDoxygenComment oneline start='\/\/\/<' end='$' display
" Match: @todo description.
" ^^^^
syn match cDoxygenTodo '@\zstodo' contained display
" Match: http://some.url
" ^^^^^^^^^^^^^^^
syn match cDoxygenUrl /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*/ contained display
" Match: /// Description.
" ^^^^^^^^^^^^^^^^
syn region cDoxygenComment fold start='^\s*\/\/\/' end='^\(\s*\/\/\/\)\@!' contains=@Spell,cDoxygenSpecial,cDoxygenTodo,cDoxygenUrl
hi default link cDoxygenComment cComment
hi default link cDoxygenLeader cDoxygenComment
hi default link cDoxygenSpecial SpecialComment
hi default link cDoxygenTodo Todo
hi default link cDoxygenUrl Underlined
endif