diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2014-08-13 00:17:05 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2014-08-13 00:17:51 +0200 |
commit | c0560d6199fe261dfd1aca6310558dc82f759fe3 (patch) | |
tree | 6d4595619983733f28d3567bc07b92c38bd76e89 | |
parent | 15db2d71206d1c67e80d2710577144e05e03b283 (diff) | |
download | vim-polyglot-c0560d6199fe261dfd1aca6310558dc82f759fe3.tar.gz vim-polyglot-c0560d6199fe261dfd1aca6310558dc82f759fe3.zip |
Add swift support :smile:, closes #32
-rwxr-xr-x | build | 1 | ||||
-rw-r--r-- | ftdetect/polyglot.vim | 1 | ||||
-rw-r--r-- | indent/swift.vim | 15 | ||||
-rw-r--r-- | syntax/swift.vim | 64 |
4 files changed, 81 insertions, 0 deletions
@@ -115,6 +115,7 @@ PACKS=" slim:slim-template/vim-slim stylus:wavded/vim-stylus systemd:kurayama/systemd-vim-syntax + swift:toyamarinyon/vim-swift textile:timcharper/textile.vim tmux:acustodioo/vim-tmux tomdoc:duwanis/tomdoc.vim diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 26103a5a..edfca72e 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -161,6 +161,7 @@ au BufRead,BufNewFile * call s:DetectScala() autocmd BufNewFile,BufRead *.slim set filetype=slim autocmd BufNewFile,BufReadPost *.styl set filetype=stylus autocmd BufNewFile,BufReadPost *.stylus set filetype=stylus +autocmd BufNewFile,BufRead *.swift set filetype=swift au BufNewFile,BufRead *.automount set filetype=systemd au BufNewFile,BufRead *.mount set filetype=systemd au BufNewFile,BufRead *.path set filetype=systemd diff --git a/indent/swift.vim b/indent/swift.vim new file mode 100644 index 00000000..8f0de62c --- /dev/null +++ b/indent/swift.vim @@ -0,0 +1,15 @@ +" Language: Swift<https://developer.apple.com/swift/> +" Maintainer: toyama satoshi <toyamarinyon@gmail.com> +" URL: http://github.com/toyamarinyon/vim-swift +" License: GPL + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +" C indenting is built-in, thus this is very simple +setlocal cindent + +let b:undo_indent = "setl cin<" diff --git a/syntax/swift.vim b/syntax/swift.vim new file mode 100644 index 00000000..e3c3dd07 --- /dev/null +++ b/syntax/swift.vim @@ -0,0 +1,64 @@ +" Language: Swift<https://developer.apple.com/swift/> +" Maintainer: toyama satoshi <toyamarinyon@gmail.com> +" URL: http://github.com/toyamarinyon/vim-swift +" License: GPL + +" Bail if our syntax is already loaded. +if exists('b:current_syntax') && b:current_syntax == 'swift' + finish +endif + +" {{{ Whitespace and Comments +syntax region swiftComment start=#\/\*# end=#\*\/# +syntax match swiftComment /\/\/.*/ +highlight default link swiftComment Comment +" }}} + +" {{{ Identifiers +syntax match swiftIdentifier /[[:alpha:]_][[:alnum:]_]*/ +highlight default link swiftIdentifier Identifier +" }}} + +" {{{ 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 +" }}} + +" {{{ 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 +" }}} + +" {{{ Operators +syntax keyword swiftOperatorKeywords / = - + ! * % < > & \| ^ ~ . +highlight default link swiftOperatorKeywords Operator +" }}} + +" {{{ 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 |