Skip to content

Commit 72ad79f

Browse files
author
zeekay
committed
Add default to list of keywords and coffeeFunction highlighting.
1 parent 1eddf18 commit 72ad79f

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

syntax/coffee.vim

+21-11
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,24 @@ hi def link coffeeConditional Conditional
3232
syn match coffeeException /\<\%(try\|catch\|finally\)\>/ display
3333
hi def link coffeeException Exception
3434

35-
syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\|yield\|debugger\|import\|export\|await\)\>/
35+
syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\|yield\|debugger\|import\|export\|default\|await\)\>/
3636
\ display
3737
" The `own` keyword is only a keyword after `for`.
3838
syn match coffeeKeyword /\<for\s\+own\>/ contained containedin=coffeeRepeat
3939
\ display
4040
hi def link coffeeKeyword Keyword
4141

42-
syn match coffeeOperator /\<\%(instanceof\|typeof\|delete\)\>/ display
42+
43+
" syn match coffeeFunction /\s\?[-=]>/
44+
syn match coffeeFunction /@\?\I.*\w\+\ze\s*=\s*.*[-=]>/ contains=@coffeeIdentifier display
45+
hi def link coffeefunction Identifier
46+
47+
syn keyword coffeeOperator instanceof typeof delete length
48+
\ display
4349
hi def link coffeeOperator Operator
4450

4551
" The first case matches symbol operators only if they have an operand before.
46-
syn match coffeeExtendedOp /\%(\S\s*\)\@<=[+\-*/%&|\^=!<>?.]\{-1,}\|[-=]>\|--\|++\|:/
52+
syn match coffeeExtendedOp /\%(\S\s*\)\@<=[+\-*/%&|\^=!<>?.,;]\{-1,}\|--\|++\|:/
4753
\ display
4854
syn match coffeeExtendedOp /\<\%(and\|or\)=/ display
4955
hi def link coffeeExtendedOp coffeeOperator
@@ -107,7 +113,7 @@ hi def link coffeeFloat Float
107113

108114
" An error for reserved keywords, taken from the RESERVED array:
109115
" http://coffeescript.org/documentation/docs/lexer.html#section-67
110-
syn match coffeeReservedError /\<\%(case\|default\|function\|var\|void\|with\|const\|let\|enum\|native\|implements\|interface\|package\|private\|protected\|public\|static\)\>/
116+
syn match coffeeReservedError /\<\%(case\|function\|var\|void\|with\|const\|let\|enum\|native\|implements\|interface\|package\|private\|protected\|public\|static\)\>/
111117
\ display
112118
hi def link coffeeReservedError Error
113119

@@ -188,18 +194,22 @@ syn match coffeeProtoAccess /::\s*\%(\I\|\$\)\%(\i\|\$\)*/he=s+2 contains=@coffe
188194
hi def link coffeeProtoAccess coffeeExtendedOp
189195

190196
" This is required for interpolations to work.
191-
syn region coffeeCurlies matchgroup=coffeeCurly start=/{/ end=/}/
197+
syn region coffeeCurlies matchgroup=coffeeBraces start=/{/ end=/}/
192198
\ contains=@coffeeAll
193199
syn region coffeeBrackets matchgroup=coffeeBracket start=/\[/ end=/\]/
194200
\ contains=@coffeeAll
195-
syn region coffeeParens matchgroup=coffeeParen start=/(/ end=/)/
201+
syn region coffeeParens matchgroup=coffeeBlockParen start=/(/ end=/)/
196202
\ contains=@coffeeAll
197203

198204
" These are highlighted the same as commas since they tend to go together.
199-
hi def link coffeeBlock coffeeSpecialOp
200-
hi def link coffeeBracket coffeeBlock
201-
hi def link coffeeCurly coffeeBlock
202-
hi def link coffeeParen coffeeBlock
205+
hi! def link coffeeParens Special
206+
hi! def link coffeeBlockParen Operator
207+
208+
hi! def link coffeeCurlies Special
209+
hi! def link coffeeBraces Function
210+
211+
hi! def link coffeeBrackets NONE
212+
hi! def link coffeeBracket Function
203213

204214
" This is used instead of TOP to keep things coffee-specific for good
205215
" embedding. `contained` groups aren't included.
@@ -214,7 +224,7 @@ syn cluster coffeeAll contains=coffeeStatement,coffeeRepeat,coffeeConditional,
214224
\ coffeeHeredoc,coffeeSpaceError,
215225
\ coffeeSemicolonError,coffeeDotAccess,
216226
\ coffeeProtoAccess,coffeeCurlies,coffeeBrackets,
217-
\ coffeeParens
227+
\ coffeeParens,coffeeFunction
218228

219229
if !exists('b:current_syntax')
220230
let b:current_syntax = 'coffee'

0 commit comments

Comments
 (0)