From 6ad59ede99e64ba7c3f4317064e55b2364e0f2cc Mon Sep 17 00:00:00 2001 From: Christopher MCAdams Date: Thu, 17 Dec 2015 14:30:02 -0600 Subject: [PATCH 1/3] Length and Function highlighting --- syntax/coffee.vim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/syntax/coffee.vim b/syntax/coffee.vim index 88917fe..8a56995 100644 --- a/syntax/coffee.vim +++ b/syntax/coffee.vim @@ -39,11 +39,17 @@ syn match coffeeKeyword /\/ contained containedin=coffeeRepeat \ display hi def link coffeeKeyword Keyword -syn match coffeeOperator /\<\%(instanceof\|typeof\|delete\)\>/ display +syn keyword coffeeOperator instanceof typeof delete hi def link coffeeOperator Operator +syn match coffeeLength /\%(.*\)\.length/hs=e-5 +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 @@ -214,7 +220,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' From 9b0678960dd5e87199c4a7db0699db7e042d06be Mon Sep 17 00:00:00 2001 From: Christopher MCAdams Date: Fri, 25 Dec 2015 19:13:30 -0600 Subject: [PATCH 2/3] change region for parens, brackets, braces --- syntax/coffee.vim | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/syntax/coffee.vim b/syntax/coffee.vim index 8a56995..5ef5ae5 100644 --- a/syntax/coffee.vim +++ b/syntax/coffee.vim @@ -39,10 +39,11 @@ syn match coffeeKeyword /\/ contained containedin=coffeeRepeat \ display hi def link coffeeKeyword Keyword -syn keyword coffeeOperator instanceof typeof delete +syn keyword coffeeOperator instanceof typeof delete length +\ display hi def link coffeeOperator Operator -syn match coffeeLength /\%(.*\)\.length/hs=e-5 +syn match coffeeLength /\%(\S\.\)length/hs=e-5 containedin=@coffeeAll hi def link coffeeLength Label syn match coffeeFunction /\s\?[-=]>/ @@ -194,18 +195,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. From 066ab9c9cf277b8a18c93ae77b85639aa80f3fcd Mon Sep 17 00:00:00 2001 From: Christopher MCAdams Date: Fri, 25 Dec 2015 22:20:24 -0600 Subject: [PATCH 3/3] Fixes #173 --- syntax/coffee.vim | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/syntax/coffee.vim b/syntax/coffee.vim index 5ef5ae5..e17fbc2 100644 --- a/syntax/coffee.vim +++ b/syntax/coffee.vim @@ -50,15 +50,11 @@ 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