Skip to content

Commit bc46ab5

Browse files
author
Max Moiseev
committed
Minor tweaks to vim syntax highlighting
Highlighting #if/#endif, @attributes, mutating and some more keywords
1 parent 76be22c commit bc46ab5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

utils/vim/ftplugin/swift.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
setlocal comments=s1:/*,mb:*,ex:*/,:///,://
2+
setlocal expandtab
3+
setlocal ts=2
4+
setlocal sw=2
5+
setlocal smartindent

utils/vim/syntax/swift.vim

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ syn keyword swiftImport import skipwhite nextgroup=swiftImportModule
1212
syn match swiftImportModule /\<[A-Za-z_][A-Za-z_0-9]*\>/ contained nextgroup=swiftImportComponent
1313
syn match swiftImportComponent /\.\<[A-Za-z_][A-Za-z_0-9]*\>/ contained nextgroup=swiftImportComponent
1414

15-
syn keyword swiftKeyword break case continue default do else for if in static switch repeat return where while public internal private skipwhite
15+
syn keyword swiftKeyword break case continue default do else for if in static switch repeat return where while public internal private mutating nonmutating var let typealias protocol extension skipwhite
1616

1717
syn keyword swiftTypeDefinition class extension protocol struct typealias enum skipwhite nextgroup=swiftTypeName
1818
syn region swiftTypeAttributes start="\[" end="\]" skipwhite contained nextgroup=swiftTypeName
1919
syn match swiftTypeName /\<[A-Za-z_][A-Za-z_0-9\.]*\>/ contained nextgroup=swiftTypeParameters
2020

2121
syn region swiftTypeParameters start="<" end=">" skipwhite contained
2222

23+
syn keyword swiftMutating mutating skipwhite nextgroup=swiftFuncDefinition
2324
syn keyword swiftFuncDefinition func skipwhite nextgroup=swiftFuncAttributes,swiftFuncName,swiftOperator
2425
syn region swiftFuncAttributes start="\[" end="\]" skipwhite contained nextgroup=swiftFuncName,swiftOperator
2526
syn match swiftFuncName /\<[A-Za-z_][A-Za-z_0-9]*\>/ skipwhite contained nextgroup=swiftTypeParameters
@@ -57,7 +58,11 @@ syn match swiftOperator "\.\.[<.]" skipwhite nextgroup=swiftTypeParameters
5758

5859
syn match swiftChar /'\([^'\\]\|\\\(["'tnr0\\]\|x[0-9a-fA-F]\{2}\|u[0-9a-fA-F]\{4}\|U[0-9a-fA-F]\{8}\)\)'/
5960

60-
syn match swiftLabel /\(get\|set\):\@=/
61+
syn match swiftLabel /\(\<get\>\|\<set\>\):\@=/
62+
63+
syn match swiftPreproc /^#\<if\>\|^#\<endif\>/
64+
65+
syn match swiftAttribute /@\<\w\+\>/ skipwhite
6166

6267
hi def link swiftImport Include
6368
hi def link swiftImportModule Title
@@ -90,5 +95,8 @@ hi def link swiftOperator Function
9095
hi def link swiftChar Character
9196
hi def link swiftLabel Label
9297
hi def link swiftNew Operator
98+
hi def link swiftMutating Statement
99+
hi def link swiftPreproc PreCondit
100+
hi def link swiftAttribute Type
93101

94102
let b:current_syntax = "swift"

0 commit comments

Comments
 (0)