From 02c7d9e3fe9647c72d36ea7cb49e885072e3fcbd Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Thu, 15 Dec 2011 12:37:21 -0500 Subject: adding coffescript vim support --- vim/syntax/coffee.vim | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++ vim/syntax/eco.vim | 62 +++++++++++++ 2 files changed, 298 insertions(+) create mode 100755 vim/syntax/coffee.vim create mode 100755 vim/syntax/eco.vim (limited to 'vim/syntax') diff --git a/vim/syntax/coffee.vim b/vim/syntax/coffee.vim new file mode 100755 index 0000000..c324435 --- /dev/null +++ b/vim/syntax/coffee.vim @@ -0,0 +1,236 @@ +" 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 + +" Highlight long strings. +syn sync minlines=100 + +" 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 /\/ 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*\)\@<=[+\-*/%&|\^=!<>?.]\+\|[-=]>\|--\|++\|::/ +\ 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 +" An @-variable +syn match coffeeSpecialVar /@\%(\I\i*\)\?/ display +hi def link coffeeSpecialVar Special + +" 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,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 +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 +endif + +" This is separate from `coffeeExtendedOp` since assignments require it. +syn match coffeeAssignOp /:/ contained display +hi def link coffeeAssignOp coffeeOperator + +" Strings used in string assignments, which can't have interpolations +syn region coffeeAssignString start=/"/ skip=/\\\\\|\\"/ end=/"/ contained +\ contains=@coffeeBasicString +syn region coffeeAssignString start=/'/ skip=/\\\\\|\\'/ end=/'/ contained +\ contains=@coffeeBasicString +hi def link coffeeAssignString String + +" A normal object assignment +syn match coffeeObjAssign /@\?\I\i*\s*:\@/ contains=@coffeeTop containedin=ALLBUT,@ecoRegions keepend +syn region ecoExpression matchgroup=ecoDelimiter start=/<%[=\-]/ end=/%>/ contains=@coffeeTop containedin=ALLBUT,@ecoRegions keepend +syn region ecoComment matchgroup=ecoComment start=/<%#/ end=/%>/ contains=@coffeeTodo,@Spell containedin=ALLBUT,@ecoRegions keepend + +" eco features not in coffeescript proper +syn keyword ecoEnd end containedin=@ecoRegions +syn match ecoIndentColon /\s+\w+:/ containedin=@ecoRegions + +" Define the default highlighting. + +hi def link ecoDelimiter Delimiter +hi def link ecoComment Comment +hi def link ecoEnd coffeeConditional +hi def link ecoIndentColon None + +let b:current_syntax = 'eco' + +" vim: nowrap sw=2 sts=2 ts=8: -- cgit v1.2.3