-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fadd4fc
commit 87d71a3
Showing
2 changed files
with
290 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,275 @@ | ||
" 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 == 'coffee' | ||
finish | ||
endif | ||
|
||
" {{{ Whitespace and Comments | ||
syntax region swiftComment start=#\/\*# end=#\*\/# | ||
syntax match swiftComment /\/\/.*/ | ||
highlight link swiftComment Comment | ||
" }}} | ||
|
||
" {{{ Identifiers | ||
syntax match swiftIdentifer /[a-zA-Z_][a-zA-Z_0-9]*/ | ||
highlight link swiftIdentifer Identifier | ||
" }}} | ||
|
||
" {{{ Keywords | ||
" Keywords used in declarations: | ||
syntax keyword swiftDeclarationKeywords class deinit enum extension func import init let protocol static struct subscript typealias var | ||
highlight 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 link swiftDeclarationKeywords Keyword | ||
" Keywords used in expressions and types: | ||
syntax keyword swiftExpressionTypeKeywords as dynamicType is new super self Self Type __COLUMN__ __FILE__ __FUNCTION__ __LINE__ | ||
highlight 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 link swiftReserveKeywords Keyword | ||
" }}} | ||
|
||
" {{{ Literals | ||
" Integer literal | ||
syntax match swiftIntegerLiteral /\<[0-9a-fA-F\.]\+\>/ | ||
syntax match swiftIntegerLiteral /\<0x[0-9]\+\>/ | ||
syntax match swiftIntegerLiteral /\<0o[0-9]\+\>/ | ||
highlight link swiftIntegerLiteral Number | ||
" String literal | ||
syntax region swiftStringLiteral start=/"/ skip=/\\"/ end=/"/ | ||
highlight link swiftStringLiteral String | ||
" }}} | ||
|
||
" {{{ Operators | ||
syntax keyword swiftOperatorKeywords / = - + ! * % < > & \| ^ ~ . | ||
highlight link swiftOperatorKeywords Operator | ||
" }}} | ||
|
||
" {{{ Type | ||
syntax match swiftTypeIdentifier /[a-zA-Z_][a-zA-Z_0-9\.]*/ contained | ||
syntax match swiftType /: .*/ contains=swiftTypeIdentifier | ||
highlight link swiftType Operator | ||
highlight link swiftTypeIdentifier Type | ||
" }}} | ||
|
||
|
||
" {{{ coffee | ||
" Include JavaScript for coffeeEmbed. | ||
" syn include @coffeeJS syntax/javascript.vim | ||
" silent! unlet b:current_syntax | ||
|
||
" " Highlight long strings. | ||
" syntax sync fromstart | ||
" | ||
" " CoffeeScript identifiers can have dollar signs. | ||
" setlocal isident+=$ | ||
" | ||
" " These are `matches` instead of `keywords` because vim's highlighting | ||
" " priority for keywords is higher than matches. This causes keywords to be | ||
" " highlighted inside matches, even if a match says it shouldn't contain them -- | ||
" " like with coffeeAssign and coffeeDot. | ||
" syn match coffeeStatement /\<\%(return\|break\|continue\|throw\)\>/ display | ||
" hi def link coffeeStatement Statement | ||
" | ||
" syn match coffeeRepeat /\<\%(for\|while\|until\|loop\)\>/ display | ||
" hi def link coffeeRepeat Repeat | ||
" | ||
" syn match coffeeConditional /\<\%(if\|else\|unless\|switch\|when\|then\)\>/ | ||
" \ display | ||
" hi def link coffeeConditional Conditional | ||
" | ||
" syn match coffeeException /\<\%(try\|catch\|finally\)\>/ display | ||
" hi def link coffeeException Exception | ||
" | ||
" syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\)\>/ | ||
" \ display | ||
" " The `own` keyword is only a keyword after `for`. | ||
" syn match coffeeKeyword /\<for\s\+own\>/ contained containedin=coffeeRepeat | ||
" \ display | ||
" hi def link coffeeKeyword Keyword | ||
" | ||
" syn match coffeeOperator /\<\%(instanceof\|typeof\|delete\)\>/ display | ||
" hi def link coffeeOperator Operator | ||
" | ||
" " The first case matches symbol operators only if they have an operand before. | ||
" syn match coffeeExtendedOp /\%(\S\s*\)\@<=[+\-*/%&|\^=!<>?.]\{-1,}\|[-=]>\|--\|++\|:/ | ||
" \ display | ||
" syn match coffeeExtendedOp /\<\%(and\|or\)=/ display | ||
" hi def link coffeeExtendedOp coffeeOperator | ||
" | ||
" " This is separate from `coffeeExtendedOp` to help differentiate commas from | ||
" " dots. | ||
" syn match coffeeSpecialOp /[,;]/ display | ||
" hi def link coffeeSpecialOp SpecialChar | ||
" | ||
" syn match coffeeBoolean /\<\%(true\|on\|yes\|false\|off\|no\)\>/ display | ||
" hi def link coffeeBoolean Boolean | ||
" | ||
" syn match coffeeGlobal /\<\%(null\|undefined\)\>/ display | ||
" hi def link coffeeGlobal Type | ||
" | ||
" " A special variable | ||
" syn match coffeeSpecialVar /\<\%(this\|prototype\|arguments\)\>/ display | ||
" hi def link coffeeSpecialVar Special | ||
" | ||
" " An @-variable | ||
" syn match coffeeSpecialIdent /@\%(\I\i*\)\?/ display | ||
" hi def link coffeeSpecialIdent Identifier | ||
" | ||
" " A class-like name that starts with a capital letter | ||
" syn match coffeeObject /\<\u\w*\>/ display | ||
" hi def link coffeeObject Structure | ||
" | ||
" " A constant-like name in SCREAMING_CAPS | ||
" syn match coffeeConstant /\<\u[A-Z0-9_]\+\>/ display | ||
" hi def link coffeeConstant Constant | ||
" | ||
" " A variable name | ||
" syn cluster coffeeIdentifier contains=coffeeSpecialVar,coffeeSpecialIdent, | ||
" \ coffeeObject,coffeeConstant | ||
" | ||
" " A non-interpolated string | ||
" syn cluster coffeeBasicString contains=@Spell,coffeeEscape | ||
" " An interpolated string | ||
" syn cluster coffeeInterpString contains=@coffeeBasicString,coffeeInterp | ||
" | ||
" " Regular strings | ||
" syn region coffeeString start=/"/ skip=/\\\\\|\\"/ end=/"/ | ||
" \ contains=@coffeeInterpString | ||
" syn region coffeeString start=/'/ skip=/\\\\\|\\'/ end=/'/ | ||
" \ contains=@coffeeBasicString | ||
" hi def link coffeeString String | ||
" | ||
" " A integer, including a leading plus or minus | ||
" syn match coffeeNumber /\i\@<![-+]\?\d\+\%([eE][+-]\?\d\+\)\?/ display | ||
" " A hex, binary, or octal number | ||
" syn match coffeeNumber /\<0[xX]\x\+\>/ display | ||
" syn match coffeeNumber /\<0[bB][01]\+\>/ display | ||
" syn match coffeeNumber /\<0[oO][0-7]\+\>/ display | ||
" hi def link coffeeNumber Number | ||
" | ||
" " A floating-point number, including a leading plus or minus | ||
" syn match coffeeFloat /\i\@<![-+]\?\d*\.\@<!\.\d\+\%([eE][+-]\?\d\+\)\?/ | ||
" \ display | ||
" hi def link coffeeFloat Float | ||
" | ||
" " An error for reserved keywords, taken from the RESERVED array: | ||
" " http://coffeescript.org/documentation/docs/lexer.html#section-67 | ||
" syn match coffeeReservedError /\<\%(case\|default\|function\|var\|void\|with\|const\|let\|enum\|export\|import\|native\|__hasProp\|__extends\|__slice\|__bind\|__indexOf\|implements\|interface\|package\|private\|protected\|public\|static\|yield\)\>/ | ||
" \ display | ||
" hi def link coffeeReservedError Error | ||
" | ||
" " A normal object assignment | ||
" syn match coffeeObjAssign /@\?\I\i*\s*\ze::\@!/ contains=@coffeeIdentifier display | ||
" hi def link coffeeObjAssign Identifier | ||
" | ||
" syn keyword coffeeTodo TODO FIXME XXX contained | ||
" hi def link coffeeTodo Todo | ||
" | ||
" syn match coffeeComment /#.*/ contains=@Spell,coffeeTodo | ||
" hi def link coffeeComment Comment | ||
" | ||
" syn region coffeeBlockComment start=/####\@!/ end=/###/ | ||
" \ contains=@Spell,coffeeTodo | ||
" hi def link coffeeBlockComment coffeeComment | ||
" | ||
" " A comment in a heregex | ||
" syn region coffeeHeregexComment start=/#/ end=/\ze\/\/\/\|$/ contained | ||
" \ contains=@Spell,coffeeTodo | ||
" hi def link coffeeHeregexComment coffeeComment | ||
" | ||
" " Embedded JavaScript | ||
" syn region coffeeEmbed matchgroup=coffeeEmbedDelim | ||
" \ start=/`/ skip=/\\\\\|\\`/ end=/`/ keepend | ||
" \ contains=@coffeeJS | ||
" hi def link coffeeEmbedDelim Delimiter | ||
" | ||
" syn region coffeeInterp matchgroup=coffeeInterpDelim start=/#{/ end=/}/ contained | ||
" \ contains=@coffeeAll | ||
" hi def link coffeeInterpDelim PreProc | ||
" | ||
" " A string escape sequence | ||
" syn match coffeeEscape /\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\./ contained display | ||
" hi def link coffeeEscape SpecialChar | ||
" | ||
" " A regex -- must not follow a parenthesis, number, or identifier, and must not | ||
" " be followed by a number | ||
" syn region coffeeRegex start=#\%(\%()\|\i\@<!\d\)\s*\|\i\)\@<!/=\@!\s\@!# | ||
" \ end=#/[gimy]\{,4}\d\@!# | ||
" \ oneline contains=@coffeeBasicString,coffeeRegexCharSet | ||
" syn region coffeeRegexCharSet start=/\[/ end=/]/ contained | ||
" \ contains=@coffeeBasicString | ||
" hi def link coffeeRegex String | ||
" hi def link coffeeRegexCharSet coffeeRegex | ||
" | ||
" " A heregex | ||
" syn region coffeeHeregex start=#///# end=#///[gimy]\{,4}# | ||
" \ contains=@coffeeInterpString,coffeeHeregexComment, | ||
" \ coffeeHeregexCharSet | ||
" \ fold | ||
" syn region coffeeHeregexCharSet start=/\[/ end=/]/ contained | ||
" \ contains=@coffeeInterpString | ||
" hi def link coffeeHeregex coffeeRegex | ||
" hi def link coffeeHeregexCharSet coffeeHeregex | ||
" | ||
" " Heredoc strings | ||
" syn region coffeeHeredoc start=/"""/ end=/"""/ contains=@coffeeInterpString | ||
" \ fold | ||
" syn region coffeeHeredoc start=/'''/ end=/'''/ contains=@coffeeBasicString | ||
" \ fold | ||
" hi def link coffeeHeredoc String | ||
" | ||
" " An error for trailing whitespace, as long as the line isn't just whitespace | ||
" syn match coffeeSpaceError /\S\@<=\s\+$/ display | ||
" hi def link coffeeSpaceError Error | ||
" | ||
" " An error for trailing semicolons, for help transitioning from JavaScript | ||
" syn match coffeeSemicolonError /;$/ display | ||
" hi def link coffeeSemicolonError Error | ||
" | ||
" " Ignore reserved words in dot accesses. | ||
" syn match coffeeDotAccess /\.\@<!\.\s*\I\i*/he=s+1 contains=@coffeeIdentifier | ||
" hi def link coffeeDotAccess coffeeExtendedOp | ||
" | ||
" " Ignore reserved words in prototype accesses. | ||
" syn match coffeeProtoAccess /::\s*\I\i*/he=s+2 contains=@coffeeIdentifier | ||
" hi def link coffeeProtoAccess coffeeExtendedOp | ||
" | ||
" " This is required for interpolations to work. | ||
" syn region coffeeCurlies matchgroup=coffeeCurly start=/{/ end=/}/ | ||
" \ contains=@coffeeAll | ||
" syn region coffeeBrackets matchgroup=coffeeBracket start=/\[/ end=/\]/ | ||
" \ contains=@coffeeAll | ||
" syn region coffeeParens matchgroup=coffeeParen start=/(/ end=/)/ | ||
" \ contains=@coffeeAll | ||
" | ||
" " These are highlighted the same as commas since they tend to go together. | ||
" hi def link coffeeBlock coffeeSpecialOp | ||
" hi def link coffeeBracket coffeeBlock | ||
" hi def link coffeeCurly coffeeBlock | ||
" hi def link coffeeParen coffeeBlock | ||
" | ||
" " This is used instead of TOP to keep things coffee-specific for good | ||
" " embedding. `contained` groups aren't included. | ||
" syn cluster coffeeAll contains=coffeeStatement,coffeeRepeat,coffeeConditional, | ||
" \ coffeeException,coffeeKeyword,coffeeOperator, | ||
" \ coffeeExtendedOp,coffeeSpecialOp,coffeeBoolean, | ||
" \ coffeeGlobal,coffeeSpecialVar,coffeeSpecialIdent, | ||
" \ coffeeObject,coffeeConstant,coffeeString, | ||
" \ coffeeNumber,coffeeFloat,coffeeReservedError, | ||
" \ coffeeObjAssign,coffeeComment,coffeeBlockComment, | ||
" \ coffeeEmbed,coffeeRegex,coffeeHeregex, | ||
" \ coffeeHeredoc,coffeeSpaceError, | ||
" \ coffeeSemicolonError,coffeeDotAccess, | ||
" \ coffeeProtoAccess,coffeeCurlies,coffeeBrackets, | ||
" \ coffeeParens | ||
" }}} coffee | ||
|
||
if !exists('b:current_syntax') | ||
let b:current_syntax = 'swift' | ||
endif |