if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'coffee-script') != -1 finish endif " Language: CoffeeScript " Maintainer: Mick Koch " URL: http://github.com/kchmck/vim-coffee-script " License: WTFPL " Bail if our syntax is already loaded. if exists('b:current_syntax') && b:current_syntax == 'coffee' finish endif " Include JavaScript for coffeeEmbed. syn include @coffeeJS syntax/javascript.vim silent! unlet b:current_syntax " Highlight long strings. syntax sync fromstart " 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\|from\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\|yield\|debugger\|import\|export\|default\|await\)\>/ \ display " The `own` keyword is only a keyword after `for`. syn match coffeeKeyword /\/ 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\|\$\)\@/ display syn match coffeeNumber /\<0[bB][01]\+\>/ display syn match coffeeNumber /\<0[oO][0-7]\+\>/ display syn match coffeeNumber /\<\%(Infinity\|NaN\)\>/ display hi def link coffeeNumber Number " A floating-point number, including a leading plus or minus syn match coffeeFloat /\%(\i\|\$\)\@/ \ 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\|\$\)\@