mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-11 04:53:51 -05:00
Update all bundles
This commit is contained in:
269
syntax/swift.vim
269
syntax/swift.vim
@@ -1,68 +1,229 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'swift') == -1
|
||||
|
||||
" Language: Swift<https://developer.apple.com/swift/>
|
||||
" Maintainer: toyama satoshi <toyamarinyon@gmail.com>
|
||||
" URL: http://github.com/toyamarinyon/vim-swift
|
||||
" License: GPL
|
||||
" File: swift.vim
|
||||
" Author: Keith Smiley
|
||||
" Description: Runtime files for Swift
|
||||
" Last Modified: June 15, 2014
|
||||
|
||||
" Bail if our syntax is already loaded.
|
||||
if exists('b:current_syntax') && b:current_syntax == 'swift'
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" {{{ Whitespace and Comments
|
||||
syntax region swiftComment start=#\/\*# end=#\*\/#
|
||||
syntax match swiftComment /\/\/.*/
|
||||
" Comments
|
||||
" Shebang
|
||||
syntax match swiftShebang "\v#!.*$"
|
||||
|
||||
" Comment contained keywords
|
||||
syntax keyword swiftTodos contained TODO XXX FIXME NOTE
|
||||
syntax keyword swiftMarker contained MARK
|
||||
syntax match swiftDocString "\v^\s*-\s*parameter"hs=s+1 contained
|
||||
syntax match swiftDocString "\v^\s*-\s*returns"hs=s+1 contained
|
||||
|
||||
" Literals
|
||||
" Strings
|
||||
syntax region swiftString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=swiftInterpolatedWrapper
|
||||
syntax region swiftInterpolatedWrapper start="\v[^\\]\\\(\s*" end="\v\s*\)" contained containedin=swiftString contains=swiftInterpolatedString
|
||||
syntax match swiftInterpolatedString "\v\w+(\(\))?" contained containedin=swiftInterpolatedWrapper
|
||||
|
||||
" Numbers
|
||||
syntax match swiftNumber "\v<\d+>"
|
||||
syntax match swiftNumber "\v<(\d+_+)+\d+(\.\d+(_+\d+)*)?>"
|
||||
syntax match swiftNumber "\v<\d+\.\d+>"
|
||||
syntax match swiftNumber "\v<\d*\.?\d+([Ee]-?)?\d+>"
|
||||
syntax match swiftNumber "\v<0x\x+([Pp]-?)?\x+>"
|
||||
syntax match swiftNumber "\v<0b[01]+>"
|
||||
syntax match swiftNumber "\v<0o\o+>"
|
||||
|
||||
" BOOLs
|
||||
syntax keyword swiftBoolean
|
||||
\ true
|
||||
\ false
|
||||
|
||||
|
||||
" Operators
|
||||
syntax match swiftOperator "\v\~"
|
||||
syntax match swiftOperator "\v\s+!"
|
||||
syntax match swiftOperator "\v\%"
|
||||
syntax match swiftOperator "\v\^"
|
||||
syntax match swiftOperator "\v\&"
|
||||
syntax match swiftOperator "\v\*"
|
||||
syntax match swiftOperator "\v-"
|
||||
syntax match swiftOperator "\v\+"
|
||||
syntax match swiftOperator "\v\="
|
||||
syntax match swiftOperator "\v\|"
|
||||
syntax match swiftOperator "\v\/"
|
||||
syntax match swiftOperator "\v\."
|
||||
syntax match swiftOperator "\v\<"
|
||||
syntax match swiftOperator "\v\>"
|
||||
syntax match swiftOperator "\v\?\?"
|
||||
|
||||
" Methods/Functions
|
||||
syntax match swiftMethod "\(\.\)\@<=\w\+\((\)\@="
|
||||
|
||||
" Swift closure arguments
|
||||
syntax match swiftClosureArgument "\$\d\+\(\.\d\+\)\?"
|
||||
|
||||
syntax match swiftAvailability "\v((\*(\s*,\s*[a-zA-Z="0-9.]+)*)|(\w+\s+\d+(\.\d+(.\d+)?)?\s*,\s*)+\*)" contains=swiftString
|
||||
syntax keyword swiftPlatforms OSX iOS watchOS OSXApplicationExtension iOSApplicationExtension contained containedin=swiftAvailability
|
||||
syntax keyword swiftAvailabilityArg renamed unavailable introduced deprecated obsoleted message contained containedin=swiftAvailability
|
||||
|
||||
" Keywords {{{
|
||||
syntax keyword swiftKeywords
|
||||
\ as
|
||||
\ atexit
|
||||
\ break
|
||||
\ case
|
||||
\ catch
|
||||
\ class
|
||||
\ continue
|
||||
\ convenience
|
||||
\ default
|
||||
\ defer
|
||||
\ deinit
|
||||
\ didSet
|
||||
\ do
|
||||
\ dynamic
|
||||
\ else
|
||||
\ extension
|
||||
\ fallthrough
|
||||
\ final
|
||||
\ for
|
||||
\ func
|
||||
\ get
|
||||
\ guard
|
||||
\ if
|
||||
\ import
|
||||
\ in
|
||||
\ indirect
|
||||
\ infix
|
||||
\ init
|
||||
\ inout
|
||||
\ internal
|
||||
\ is
|
||||
\ lazy
|
||||
\ let
|
||||
\ mutating
|
||||
\ nil
|
||||
\ nonmutating
|
||||
\ operator
|
||||
\ optional
|
||||
\ override
|
||||
\ postfix
|
||||
\ prefix
|
||||
\ private
|
||||
\ protocol
|
||||
\ public
|
||||
\ repeat
|
||||
\ required
|
||||
\ rethrows
|
||||
\ return
|
||||
\ self
|
||||
\ set
|
||||
\ static
|
||||
\ subscript
|
||||
\ super
|
||||
\ switch
|
||||
\ throw
|
||||
\ throws
|
||||
\ try
|
||||
\ typealias
|
||||
\ unowned
|
||||
\ var
|
||||
\ weak
|
||||
\ where
|
||||
\ while
|
||||
\ willSet
|
||||
" }}}
|
||||
|
||||
" Names surrounded by backticks. This aren't limited to keywords because 1)
|
||||
" Swift doesn't limit them to keywords and 2) I couldn't make the keywords not
|
||||
" highlight at the same time
|
||||
syntax region swiftEscapedReservedWord start="`" end="`" oneline
|
||||
|
||||
syntax keyword swiftAttributes
|
||||
\ @assignment
|
||||
\ @autoclosure
|
||||
\ @available
|
||||
\ @convention
|
||||
\ @exported
|
||||
\ @IBAction
|
||||
\ @IBDesignable
|
||||
\ @IBInspectable
|
||||
\ @IBOutlet
|
||||
\ @noescape
|
||||
\ @nonobjc
|
||||
\ @noreturn
|
||||
\ @NSApplicationMain
|
||||
\ @NSCopying
|
||||
\ @NSManaged
|
||||
\ @objc
|
||||
\ @testable
|
||||
\ @UIApplicationMain
|
||||
\ @warn_unused_result
|
||||
|
||||
syntax keyword swiftConditionStatement #available
|
||||
|
||||
syntax keyword swiftStructure
|
||||
\ struct
|
||||
\ enum
|
||||
|
||||
syntax region swiftTypeWrapper start="\v:\s*" skip="\s*,\s*$*\s*" end="$" contains=swiftString,swiftBoolean,swiftNumber,swiftType,swiftGenericsWrapper transparent
|
||||
syntax region swiftGenericsWrapper start="\v\<" end="\v\>" contains=swiftType transparent oneline
|
||||
syntax region swiftLiteralWrapper start="\v\=\s*" skip="\v[^\[\]]\(\)" end="\v(\[\]|\(\))" contains=swiftType,swiftString transparent oneline
|
||||
syntax region swiftReturnWrapper start="\v-\>\s*" end="\v(\{|$)" contains=swiftType transparent oneline
|
||||
syntax match swiftType "\v<\u\w*" contained containedin=swiftGenericsWrapper,swiftTypeWrapper,swiftLiteralWrapper,swiftGenericsWrapper
|
||||
|
||||
syntax keyword swiftImports import
|
||||
|
||||
|
||||
" 'preprocesor' stuff
|
||||
syntax keyword swiftPreprocessor
|
||||
\ #if
|
||||
\ #elseif
|
||||
\ #else
|
||||
\ #endif
|
||||
|
||||
|
||||
" Comment patterns
|
||||
syntax match swiftComment "\v\/\/.*$"
|
||||
\ contains=swiftTodos,swiftDocString,swiftMarker,@Spell oneline
|
||||
syntax region swiftComment start="/\*" end="\*/"
|
||||
\ contains=swiftTodos,swiftDocString,swiftMarker,swiftComment,@Spell fold
|
||||
|
||||
|
||||
" Set highlights
|
||||
highlight default link swiftTodos Todo
|
||||
highlight default link swiftDocString String
|
||||
highlight default link swiftShebang Comment
|
||||
highlight default link swiftComment Comment
|
||||
" }}}
|
||||
highlight default link swiftMarker Comment
|
||||
|
||||
" {{{ Identifiers
|
||||
syntax match swiftIdentifier /[[:alpha:]_][[:alnum:]_]*/
|
||||
highlight default link swiftIdentifier Identifier
|
||||
" }}}
|
||||
highlight default link swiftString String
|
||||
highlight default link swiftInterpolatedWrapper Delimiter
|
||||
highlight default link swiftNumber Number
|
||||
highlight default link swiftBoolean Boolean
|
||||
|
||||
" {{{ Keywords
|
||||
" Keywords used in declarations:
|
||||
syntax keyword swiftDeclarationKeywords class deinit enum extension func import init let protocol static struct subscript typealias var
|
||||
highlight default link swiftDeclarationKeywords Keyword
|
||||
" Keywords used in statements:
|
||||
syntax keyword swiftStatementKeywords break case continue default do else fallthrough if in for return switch where while
|
||||
highlight default link swiftStatementKeywords Keyword
|
||||
" Keywords used in expressions and types:
|
||||
syntax keyword swiftExpressionTypeKeywords as dynamicType is new super self Self Type __COLUMN__ __FILE__ __FUNCTION__ __LINE__
|
||||
highlight default link swiftExpressionTypeKeywords Keyword
|
||||
" Keywords reserved in particular contexts:
|
||||
syntax keyword swiftReserveKeywords associativity didSet get infix inout left mutating none nonmutating operator override postfix precedence prefix right set unowned unowned(safe) unowned(unsafe) weak willSet
|
||||
highlight default link swiftReserveKeywords Keyword
|
||||
" }}}
|
||||
highlight default link swiftOperator Operator
|
||||
highlight default link swiftKeywords Keyword
|
||||
highlight default link swiftEscapedReservedWord Normal
|
||||
highlight default link swiftClosureArgument Operator
|
||||
highlight default link swiftAttributes PreProc
|
||||
highlight default link swiftConditionStatement PreProc
|
||||
highlight default link swiftStructure Structure
|
||||
highlight default link swiftType Type
|
||||
highlight default link swiftImports Include
|
||||
highlight default link swiftPreprocessor PreProc
|
||||
highlight default link swiftMethod Function
|
||||
|
||||
" {{{ Literals
|
||||
" Integer literal
|
||||
syntax match swiftIntegerLiteral /\<\d\+\%(_\d\+\)*\%(\.\d\+\%(_\d\+\)*\)\=\>/
|
||||
syntax match swiftIntegerLiteral /\<\d\+\%(_\d\+\)*\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)\>/
|
||||
syntax match swiftIntegerLiteral /\<0x\x\+\%(_\x\+\)*\>/
|
||||
syntax match swiftIntegerLiteral /\<0o\o\+\%(_\o\+\)*\>/
|
||||
syntax match swiftIntegerLiteral /\<0b[01]\+\%(_[01]\+\)*\>/
|
||||
highlight default link swiftIntegerLiteral Number
|
||||
" String literal
|
||||
syntax region swiftStringLiteral start=/"/ skip=/\\"/ end=/"/
|
||||
highlight default link swiftStringLiteral String
|
||||
" }}}
|
||||
highlight default link swiftConditionStatement PreProc
|
||||
highlight default link swiftAvailability Normal
|
||||
highlight default link swiftAvailabilityArg Normal
|
||||
highlight default link swiftPlatforms Keyword
|
||||
|
||||
" {{{ Operators
|
||||
syntax keyword swiftOperatorKeywords / = - + ! * % < > & \| ^ ~ .
|
||||
highlight default link swiftOperatorKeywords Operator
|
||||
" }}}
|
||||
" Force vim to sync at least x lines. This solves the multiline comment not
|
||||
" being highlighted issue
|
||||
syn sync minlines=100
|
||||
|
||||
" {{{ Type
|
||||
syntax match swiftTypeIdentifier /\<[[:alpha:]_][[:alnum:]_.]*/ contained
|
||||
syntax match swiftType /: .*/ contains=swiftTypeIdentifier
|
||||
highlight default link swiftType Operator
|
||||
highlight default link swiftTypeIdentifier Type
|
||||
" }}}
|
||||
|
||||
if !exists('b:current_syntax')
|
||||
let b:current_syntax = 'swift'
|
||||
endif
|
||||
let b:current_syntax = "swift"
|
||||
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user