Skip to content

vim: improve syntax highlighting rules #32350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions utils/vim/syntax/swift.vim
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ if exists("b:current_syntax")
endif

syn keyword swiftKeyword
\ associatedtype
\ break
\ case
\ catch
\ continue
\ default
\ defer
\ do
\ else
Expand All @@ -38,6 +39,10 @@ syn keyword swiftKeyword
syn match swiftMultiwordKeyword
\ "indirect case"

syn keyword swiftCoreTypes
\ Any
\ AnyObject

syn keyword swiftImport skipwhite skipempty nextgroup=swiftImportModule
\ import

Expand Down Expand Up @@ -88,10 +93,13 @@ syn keyword swiftTypeDefinition skipwhite skipempty nextgroup=swiftTypeName
\ class
\ enum
\ extension
\ operator
\ precedencegroup
\ protocol
\ struct

syn keyword swiftTypeAliasDefinition skipwhite skipempty nextgroup=swiftTypeAliasName
\ associatedtype
\ typealias

syn match swiftMultiwordTypeDefinition skipwhite skipempty nextgroup=swiftTypeName
Expand Down Expand Up @@ -197,7 +205,7 @@ syn match swiftDecimal contained
\ /[0-9]\+/

syn match swiftPreproc
\ /#\(\<file\>\|\<line\>\|\<function\>\)/
\ /#\(\<column\>\|\<dsohandle\>\|\<file\>\|\<line\>\|\<function\>\)/
syn match swiftPreproc
\ /^\s*#\(\<if\>\|\<else\>\|\<elseif\>\|\<endif\>\|\<error\>\|\<warning\>\)/
syn region swiftPreprocFalse
Expand All @@ -208,9 +216,9 @@ syn match swiftAttribute

syn keyword swiftTodo MARK TODO FIXME contained

syn match swiftCastOp skipwhite skipempty nextgroup=swiftType
syn match swiftCastOp skipwhite skipempty nextgroup=swiftType,swiftCoreTypes
\ "\<is\>"
syn match swiftCastOp skipwhite skipempty nextgroup=swiftType
syn match swiftCastOp skipwhite skipempty nextgroup=swiftType,swiftCoreTypes
\ "\<as\>[!?]\?"

syn match swiftNilOps
Expand All @@ -223,6 +231,7 @@ hi def link swiftImport Include
hi def link swiftImportModule Title
hi def link swiftImportComponent Identifier
hi def link swiftKeyword Statement
hi def link swiftCoreTypes Type
hi def link swiftMultiwordKeyword Statement
hi def link swiftTypeDefinition Define
hi def link swiftMultiwordTypeDefinition Define
Expand Down