summaryrefslogtreecommitdiffstats
path: root/after/syntax/cpp.vim
diff options
context:
space:
mode:
Diffstat (limited to 'after/syntax/cpp.vim')
-rw-r--r--after/syntax/cpp.vim86
1 files changed, 47 insertions, 39 deletions
diff --git a/after/syntax/cpp.vim b/after/syntax/cpp.vim
index f6c866a6..c0bc3ec7 100644
--- a/after/syntax/cpp.vim
+++ b/after/syntax/cpp.vim
@@ -36,22 +36,56 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'c++11') == -1
" Functions
syn match cCustomParen "(" contains=cParen contains=cCppParen
-syn match cCustomFunc "\w\+\s*(\@=" contains=cCustomParen
+syn match cCustomFunc "\w\+\s*(\@="
hi def link cCustomFunc Function
-" Template functions
-if exists('g:cpp_experimental_template_highlight') && g:cpp_experimental_template_highlight
- syn region cCustomAngleBrackets matchgroup=AngleBracketContents start="\v%(<operator\_s*)@<!%(%(\_i|template\_s*)@<=\<[<=]@!|\<@<!\<[[:space:]<=]@!)" end='>' contains=@cppSTLgroup,cppStructure,cType,cCustomClass,cCustomAngleBrackets,cNumbers
- syn match cCustomBrack "<\|>" contains=cCustomAngleBrackets
- syn match cCustomTemplateFunc "\w\+\s*<.*>(\@=" contains=cCustomBrack,cCustomAngleBrackets
- hi def link cCustomTemplateFunc Function
-endif
-
" Class and namespace scope
if exists('g:cpp_class_scope_highlight') && g:cpp_class_scope_highlight
syn match cCustomScope "::"
- syn match cCustomClass "\w\+\s*::" contains=cCustomScope
- hi def link cCustomClass Function " disabled for now
+ syn match cCustomClass "\w\+\s*::"
+ \contains=cCustomScope
+ " hi def link cCustomClass Function " disabled for now
+ syn match cCustomClass "\<\u\w*\s*\>"
+endif
+
+" Template functions
+if exists('g:cpp_experimental_template_highlight') && g:cpp_experimental_template_highlight
+
+ syn match cCustomAngleBracketStart "<\_[^;()]\{-}>" contained
+ \contains=cCustomAngleBracketStart, cCustomAngleBracketEnd
+ hi def link cCustomAngleBracketStart cCustomAngleBracketContent
+
+ syn match cCustomAngleBracketEnd ">\_[^<>;()]\{-}>" contained
+ \contains=cCustomAngleBracketEnd
+ hi def link cCustomAngleBracketEnd cCustomAngleBracketContent
+
+ syn match cCustomTemplateFunc "\<\l\w*\s*<\_[^;()]\{-}>(\@="hs=s,he=e-1
+ \contains=cCustomAngleBracketStart
+ hi def link cCustomTemplateFunc cCustomFunc
+
+ syn match cCustomTemplateClass "\<\w\+\s*<\_[^;()]\{-}>"
+ \contains=cCustomAngleBracketStart,cCustomTemplateFunc
+ hi def link cCustomTemplateClass cCustomClass
+
+
+ " Remove 'template' from cppStructure and use a custom match
+ syn clear cppStructure
+ syn keyword cppStructure class typename namespace
+
+ syn match cCustomTemplate "\<template\>"
+ hi def link cCustomTemplate cppStructure
+ syn match cTemplateDeclare "\<template\_s*<\_[^;()]\{-}>"
+ \contains=cppStructure,cCustomTemplate,cCustomAngleBracketStart
+
+ " Remove 'operator' from cppStructure and use a custom match
+ syn clear cppOperator
+ syn keyword cppOperator typeid
+ syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq
+
+ syn match cCustomOperator "\<operator\>"
+ hi def link cCustomOperator cppStructure
+ syn match cTemplateOperatorDeclare "\<operator\_s*<\_[^;()]\{-}>[<>]=\?"
+ \contains=cppOperator,cCustomOperator,cCustomAngleBracketStart
endif
" Alternative syntax that is used in:
@@ -65,7 +99,7 @@ syn cluster cppSTLgroup contains=cppSTLfunction,cppSTLfunctional,cppSTLconst
" -----------------------------------------------------------------------------
" Standard library types and functions.
"
-" Mainly based on the excellent STL Syntax vim script by
+" Mainly based on the excellent STL Syntax vim script by
" Mizuchi <ytj000@gmail.com>
" http://www.vim.org/scripts/script.php?script_id=4293
" which in turn is based on the scripts
@@ -136,7 +170,6 @@ syntax keyword cppSTLfunctional binary_negate
syntax keyword cppSTLfunctional bit_and
syntax keyword cppSTLfunctional bit_not
syntax keyword cppSTLfunctional bit_or
-syntax keyword cppSTLfunctional bit_xor
syntax keyword cppSTLfunctional divides
syntax keyword cppSTLfunctional equal_to
syntax keyword cppSTLfunctional greater
@@ -1324,31 +1357,6 @@ if !exists("cpp_no_cpp14")
"dynarray
syntax keyword cppSTLtype dynarray
- "helper type traits types
- syntax keyword cppSTLtype remove_cv_t
- syntax keyword cppSTLtype remove_const_t
- syntax keyword cppSTLtype remove_volatile_t
- syntax keyword cppSTLtype add_cv_t
- syntax keyword cppSTLtype add_const_t
- syntax keyword cppSTLtype add_volatile_t
- syntax keyword cppSTLtype remove_reference_t
- syntax keyword cppSTLtype add_lvalue_reference_t
- syntax keyword cppSTLtype add_rvalue_reference_t
- syntax keyword cppSTLtype remove_pointer_t
- syntax keyword cppSTLtype add_pointer_t
- syntax keyword cppSTLtype remove_extent_t
- syntax keyword cppSTLtype remove_all_extents_t
- syntax keyword cppSTLtype make_signed_t
- syntax keyword cppSTLtype make_unsigned_t
- syntax keyword cppSTLtype aligned_storage_t
- syntax keyword cppSTLtype aligned_union_t
- syntax keyword cppSTLtype decay_t
- syntax keyword cppSTLtype enable_if_t
- syntax keyword cppSTLtype conditional_t
- syntax keyword cppSTLtype common_type_t
- syntax keyword cppSTLtype underlying_type_t
- syntax keyword cppSTLtype result_of_t
-
"thread
syntax keyword cppSTLtype shared_mutex
syntax keyword cppSTLtype shared_lock
@@ -1387,7 +1395,7 @@ if version >= 508 || !exists("did_cpp_syntax_inits")
HiLink cppSTLenum Typedef
HiLink cppSTLios Function
HiLink cppSTLcast Statement " be consistent with official syntax
- HiLink cppRawString String
+ HiLink cppRawString String
HiLink cppRawDelimiter Delimiter
delcommand HiLink
endif