Skip to content

Commit 2ffccc2

Browse files
committed
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.
1 parent ff86a69 commit 2ffccc2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

utils/vim/syntax/swift.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ syn match swiftTupleIndexNumber contains=swiftDecimal
207207
syn match swiftDecimal contained
208208
\ /[0-9]\+/
209209

210+
" This is a superset of the Preproc macros below, so it must come FIRST
211+
syn match swiftFreestandingMacro
212+
\ /#\<[A-Za-z_][A-Za-z_0-9]*\>/
210213
syn match swiftPreproc
211214
\ /#\(\<column\>\|\<dsohandle\>\|\<file\>\|\<line\>\|\<function\>\)/
212215
syn match swiftPreproc
@@ -271,6 +274,7 @@ hi def link swiftLabel Operator
271274
hi def link swiftMutating Statement
272275
hi def link swiftPreproc PreCondit
273276
hi def link swiftPreprocFalse Comment
277+
hi def link swiftFreestandingMacro Macro
274278
hi def link swiftAttribute Type
275279
hi def link swiftTodo Todo
276280
hi def link swiftNil Constant

0 commit comments

Comments
 (0)