Match freestanding macros in vim syntax

Any valid name beginning with `#` that isn't already a preprocessor
macro is now considered a freestanding macro. Previously, only
preprocessor macros were handled in the vim syntax file, e.g. `#if`.

For example, this properly handles the syntax for the `#expect` and the
`#require` macros used in Swift Testing.
This commit is contained in:
Jerry Chen
2024-09-13 18:13:55 -07:00
parent ff86a69dd7
commit 2ffccc286f

View File

@@ -207,6 +207,9 @@ syn match swiftTupleIndexNumber contains=swiftDecimal
syn match swiftDecimal contained
\ /[0-9]\+/
" This is a superset of the Preproc macros below, so it must come FIRST
syn match swiftFreestandingMacro
\ /#\<[A-Za-z_][A-Za-z_0-9]*\>/
syn match swiftPreproc
\ /#\(\<column\>\|\<dsohandle\>\|\<file\>\|\<line\>\|\<function\>\)/
syn match swiftPreproc
@@ -271,6 +274,7 @@ hi def link swiftLabel Operator
hi def link swiftMutating Statement
hi def link swiftPreproc PreCondit
hi def link swiftPreprocFalse Comment
hi def link swiftFreestandingMacro Macro
hi def link swiftAttribute Type
hi def link swiftTodo Todo
hi def link swiftNil Constant