Add improved additional C++ syntax highlighting

This commit is contained in:
Kenneth Benzie 2016-09-02 22:36:46 +01:00
parent b5c24ed587
commit 47b8b5861b

30
after/syntax/cpp.vim Normal file
View File

@ -0,0 +1,30 @@
" File: cpp.vim
" Language: C++
" Description: Additional C++ syntax file.
" Author: Kenneth Benzie (Benie) k.benzie83@gmail.com
" Last Modified: September 02, 2016
" Match delimiter expressions: <expr>, (expr) {expr} ex::pr
" ^ ^ ^ ^ ^ ^ ^^
syn match cppDelimiter '\([()\[\]{}<>]\|::\)'
" Match keyword logic operators
syn keyword cppOperator and and_eq bitand bitor compl
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: / < >
" ^ ^ ^
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::
" ^^^^
syn match cppStorageClass '\w[A-Za-z0-9_]*\ze::'
" Define additional highlight groups
hi default link cppDelimiter Delimiter
hi default link cppFunction Function