summaryrefslogtreecommitdiffstats
path: root/syntax/c.vim
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2021-03-01 13:44:50 +0100
committerAdam Stankiewicz <sheerun@sher.pl>2021-03-01 13:44:50 +0100
commitcc63193ce82c1e7b9ee2ad7d0ddd14e8394211ef (patch)
tree260360b1a32ca19635f8c8884b81fcec9ed51168 /syntax/c.vim
parent4c10562d2cc9b084518284c49a158558da5180a7 (diff)
downloadvim-polyglot-cc63193ce82c1e7b9ee2ad7d0ddd14e8394211ef.tar.gz
vim-polyglot-cc63193ce82c1e7b9ee2ad7d0ddd14e8394211ef.zip
Update
Diffstat (limited to 'syntax/c.vim')
-rw-r--r--syntax/c.vim28
1 files changed, 17 insertions, 11 deletions
diff --git a/syntax/c.vim b/syntax/c.vim
index cb52a22f..a11a95a2 100644
--- a/syntax/c.vim
+++ b/syntax/c.vim
@@ -5,7 +5,7 @@ endif
" Vim syntax file
" Language: C
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2019 Nov 29
+" Last Change: 2021 Jan 11
" Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax")
@@ -17,6 +17,9 @@ set cpo&vim
let s:ft = matchstr(&ft, '^\([^.]\)\+')
+" check if this was included from cpp.vim
+let s:in_cpp_family = exists("b:filetype_in_cpp_family")
+
" Optional embedded Autodoc parsing
" To enable it add: let g:c_autodoc = 1
" to your .vimrc
@@ -59,7 +62,7 @@ if !exists("c_no_cformat")
endif
" cCppString: same as cString, but ends at end of line
-if s:ft ==# "cpp" && !exists("cpp_no_cpp11") && !exists("c_no_cformat")
+if s:in_cpp_family && !exists("cpp_no_cpp11") && !exists("c_no_cformat")
" ISO C++11
syn region cString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend
syn region cCppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell
@@ -91,7 +94,7 @@ syn match cSpecialCharacter display "L\='\\\o\{1,3}'"
syn match cSpecialCharacter display "'\\x\x\{1,2}'"
syn match cSpecialCharacter display "L'\\x\x\+'"
-if (s:ft ==# "c" && !exists("c_no_c11")) || (s:ft ==# "cpp" && !exists("cpp_no_cpp11"))
+if (s:ft ==# "c" && !exists("c_no_c11")) || (s:in_cpp_family && !exists("cpp_no_cpp11"))
" ISO C11 or ISO C++ 11
if exists("c_no_cformat")
syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend
@@ -134,7 +137,7 @@ endif
" But avoid matching <::.
syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom
if exists("c_no_curly_error")
- if s:ft ==# 'cpp' && !exists("cpp_no_cpp11")
+ if s:in_cpp_family && !exists("cpp_no_cpp11")
syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell
" cCppParen: same as cParen but ends at end-of-line; used in cDefine
syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell
@@ -148,7 +151,7 @@ if exists("c_no_curly_error")
syn match cErrInParen display contained "^[{}]\|^<%\|^%>"
endif
elseif exists("c_no_bracket_error")
- if s:ft ==# 'cpp' && !exists("cpp_no_cpp11")
+ if s:in_cpp_family && !exists("cpp_no_cpp11")
syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell
" cCppParen: same as cParen but ends at end-of-line; used in cDefine
syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell
@@ -162,7 +165,7 @@ elseif exists("c_no_bracket_error")
syn match cErrInParen display contained "[{}]\|<%\|%>"
endif
else
- if s:ft ==# 'cpp' && !exists("cpp_no_cpp11")
+ if s:in_cpp_family && !exists("cpp_no_cpp11")
syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell
" cCppParen: same as cParen but ends at end-of-line; used in cDefine
syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell
@@ -276,12 +279,13 @@ if exists("c_gnu")
syn keyword cType __label__ __complex__ __volatile__
endif
-syn keyword cStructure struct union enum typedef
+syn keyword cTypedef typedef
+syn keyword cStructure struct union enum
syn keyword cStorageClass static register auto volatile extern const
if exists("c_gnu")
syn keyword cStorageClass inline __attribute__
endif
-if !exists("c_no_c99") && s:ft !=# 'cpp'
+if !exists("c_no_c99") && !s:in_cpp_family
syn keyword cStorageClass inline restrict
endif
if !exists("c_no_c11")
@@ -315,8 +319,7 @@ if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu")
if exists("c_gnu")
syn keyword cConstant __GNUC__ __FUNCTION__ __PRETTY_FUNCTION__ __func__
endif
- syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__
- syn keyword cConstant __STDC_VERSION__
+ syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __STDC_HOSTED__
syn keyword cConstant CHAR_BIT MB_LEN_MAX MB_CUR_MAX
syn keyword cConstant UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX
syn keyword cConstant CHAR_MIN INT_MIN LONG_MIN SHRT_MIN
@@ -350,6 +353,8 @@ if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu")
syn keyword cConstant SIGSTOP SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2
syn keyword cConstant _IOFBF _IOLBF _IONBF BUFSIZ EOF WEOF FOPEN_MAX FILENAME_MAX L_tmpnam
syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET TMP_MAX stderr stdin stdout EXIT_FAILURE EXIT_SUCCESS RAND_MAX
+ " used in assert.h
+ syn keyword cConstant NDEBUG
" POSIX 2001
syn keyword cConstant SIGBUS SIGPOLL SIGPROF SIGSYS SIGURG SIGVTALRM SIGXCPU SIGXFSZ
" non-POSIX signals
@@ -422,7 +427,7 @@ endif
syn cluster cLabelGroup contains=cUserLabel
syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup
syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup
-if s:ft ==# 'cpp'
+if s:in_cpp_family
syn match cUserCont display "^\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
syn match cUserCont display ";\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
else
@@ -479,6 +484,7 @@ hi def link cSpecialError cError
hi def link cCurlyError cError
hi def link cOperator Operator
hi def link cStructure Structure
+hi def link cTypedef Structure
hi def link cStorageClass StorageClass
hi def link cInclude Include
hi def link cPreProc PreProc