Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlighing for Function, Label, Parens, Bracket, Braces #200

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions syntax/coffee.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,22 @@ syn match coffeeKeyword /\<for\s\+own\>/ contained containedin=coffeeRepeat
\ display
hi def link coffeeKeyword Keyword

syn match coffeeOperator /\<\%(instanceof\|typeof\|delete\)\>/ display
syn keyword coffeeOperator instanceof typeof delete length
\ display
hi def link coffeeOperator Operator

syn match coffeeLength /\%(\S\.\)length/hs=e-5 containedin=@coffeeAll
hi def link coffeeLength Label

syn match coffeeFunction /\s\?[-=]>/
hi def link coffeeFunction Function

" The first case matches symbol operators only if they have an operand before.
syn match coffeeExtendedOp /\%(\S\s*\)\@<=[+\-*/%&|\^=!<>?.]\{-1,}\|[-=]>\|--\|++\|:/
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
Expand Down Expand Up @@ -188,18 +191,22 @@ syn match coffeeProtoAccess /::\s*\%(\I\|\$\)\%(\i\|\$\)*/he=s+2 contains=@coffe
hi def link coffeeProtoAccess coffeeExtendedOp

" This is required for interpolations to work.
syn region coffeeCurlies matchgroup=coffeeCurly start=/{/ end=/}/
syn region coffeeCurlies matchgroup=coffeeBraces start=/{/ end=/}/
\ contains=@coffeeAll
syn region coffeeBrackets matchgroup=coffeeBracket start=/\[/ end=/\]/
\ contains=@coffeeAll
syn region coffeeParens matchgroup=coffeeParen start=/(/ end=/)/
syn region coffeeParens matchgroup=coffeeBlockParen 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
hi! def link coffeeParens Special
hi! def link coffeeBlockParen Operator

hi! def link coffeeCurlies Special
hi! def link coffeeBraces Function

hi! def link coffeeBrackets NONE
hi! def link coffeeBracket Function

" This is used instead of TOP to keep things coffee-specific for good
" embedding. `contained` groups aren't included.
Expand All @@ -214,7 +221,7 @@ syn cluster coffeeAll contains=coffeeStatement,coffeeRepeat,coffeeConditional,
\ coffeeHeredoc,coffeeSpaceError,
\ coffeeSemicolonError,coffeeDotAccess,
\ coffeeProtoAccess,coffeeCurlies,coffeeBrackets,
\ coffeeParens
\ coffeeParens,coffeeFunction,coffeeLength

if !exists('b:current_syntax')
let b:current_syntax = 'coffee'
Expand Down