Commit: runtime(c): classify type qualifiers, function specifiers and C23 attributes

1 view
Skip to first unread message

Christian Brabandt

unread,
Jun 1, 2026, 5:15:13 PM (yesterday) Jun 1
to vim...@googlegroups.com
runtime(c): classify type qualifiers, function specifiers and C23 attributes

Commit: https://github.com/vim/vim/commit/77b2376769a3f6b0dc21467a56986f3725fc270d
Author: Yasuhiro Matsumoto <matt...@gmail.com>
Date: Mon Jun 1 21:04:08 2026 +0000

runtime(c): classify type qualifiers, function specifiers and C23 attributes

Move const, volatile, restrict and _Atomic to a new cTypeQualifier group
and inline and _Noreturn to cFunctionSpec. Add the C23 standard attributes
deprecated, fallthrough, maybe_unused, nodiscard, unsequenced and
reproducible as cStandardAttribute, and reclassify the existing noreturn
into the same group.

The new groups link to cStorageClass, so the default highlighting and any
existing cStorageClass override are unchanged, while allowing finer-grained
customization.

fixes: #19574
closes: #20368

Signed-off-by: Yasuhiro Matsumoto <matt...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim
index 64bcd3e36..683810952 100644
--- a/runtime/syntax/c.vim
+++ b/runtime/syntax/c.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: C
" Maintainer: The Vim Project <https://github.com/vim/vim>
-" Last Change: 2026 Jan 13
+" Last Change: 2026 Jun 01
" Former Maintainer: Bram Moolenaar <Br...@vim.org>

" Quit when a (custom) syntax file was already loaded
@@ -278,9 +278,9 @@ if exists("c_gnu")
syn keyword cOperator __alignof__
syn keyword cOperator typeof __typeof__
syn keyword cOperator __real__ __imag__
- syn keyword cStorageClass __attribute__ __const__ __extension__
- syn keyword cStorageClass inline __inline __inline__
- syn keyword cStorageClass __restrict__ __volatile__ __noreturn__
+ syn keyword cStorageClass __attribute__ __extension__
+ syn keyword cTypeQualifier __const__ __restrict__ __volatile__
+ syn keyword cFunctionSpec inline __inline __inline__ __noreturn__
endif
syn keyword cType int long short char void
syn keyword cType signed unsigned float double
@@ -314,9 +314,11 @@ endif

syn keyword cTypedef typedef
syn keyword cStructure struct union enum
-syn keyword cStorageClass static register auto volatile extern const
+syn keyword cStorageClass static register auto extern
+syn keyword cTypeQualifier const volatile
if !exists("c_no_c99") && !s:in_cpp_family
- syn keyword cStorageClass inline restrict
+ syn keyword cFunctionSpec inline
+ syn keyword cTypeQualifier restrict
endif
if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp11"))
syn keyword cStorageClass constexpr
@@ -324,11 +326,11 @@ endif
if !exists("c_no_c11")
syn keyword cStorageClass _Alignas alignas
syn keyword cOperator _Alignof alignof
- syn keyword cStorageClass _Atomic
+ syn keyword cTypeQualifier _Atomic
syn keyword cOperator _Generic
- syn keyword cStorageClass _Noreturn
+ syn keyword cFunctionSpec _Noreturn
if !s:in_cpp_family
- syn keyword cStorageClass noreturn
+ syn keyword cStandardAttribute noreturn
endif
syn keyword cOperator _Static_assert static_assert
syn keyword cStorageClass _Thread_local thread_local
@@ -352,6 +354,11 @@ if !exists("c_no_c11")
syn keyword cType atomic_intmax_t atomic_uintmax_t
endif

+if !exists("c_no_c23") && !s:in_cpp_family
+ syn keyword cStandardAttribute deprecated fallthrough maybe_unused nodiscard
+ syn keyword cStandardAttribute unsequenced reproducible
+endif
+
if (s:ft ==# "c" && !exists("c_no_c23")) || (s:in_cpp_family && !exists("cpp_no_cpp20"))
syn keyword cType char8_t
endif
@@ -606,6 +613,9 @@ hi def link cOperator Operator
hi def link cStructure Structure
hi def link cTypedef Structure
hi def link cStorageClass StorageClass
+hi def link cTypeQualifier cStorageClass
+hi def link cFunctionSpec cStorageClass
+hi def link cStandardAttribute cStorageClass
hi def link cInclude Include
hi def link cPreProc PreProc
hi def link cDefine Macro
Reply all
Reply to author
Forward
0 new messages