diff --git a/syntax/purescript.vim b/syntax/purescript.vim index c319638..60f8c01 100644 --- a/syntax/purescript.vim +++ b/syntax/purescript.vim @@ -19,13 +19,13 @@ syn keyword purescriptBoolean true false syn match purescriptDelimiter "[,;|.()[\]{}]" " Constructor -syn match purescriptConstructor "\<[A-Z]\w*\>" +syn match purescriptConstructor "\%(\" syn region purescriptConstructorDecl matchgroup=purescriptConstructor start="\<[A-Z]\w*\>" end="\(|\|$\)"me=e-1,re=e-1 contained \ containedin=purescriptData,purescriptNewtype \ contains=purescriptType,purescriptTypeVar,purescriptDelimiter,purescriptOperatorType,purescriptOperatorTypeSig,@purescriptComment " Type -syn match purescriptType "\<[A-Z]\w*\>" contained +syn match purescriptType "\%(\" contained \ containedin=purescriptTypeAlias \ nextgroup=purescriptType,purescriptTypeVar skipwhite syn match purescriptTypeVar "\<[_a-z]\(\w\|\'\)*\>" contained @@ -34,9 +34,20 @@ syn region purescriptTypeExport matchgroup=purescriptType start="\<[A-Z]\(\S\&[^ \ contains=purescriptConstructor,purescriptDelimiter " Function -syn match purescriptFunction "\<[_a-z]\(\w\|\'\)*\>" contained -syn match purescriptFunction "(\(\W\&[^(),\"]\)\+)" contained extend -syn match purescriptBacktick "`[_A-Za-z][A-Za-z0-9_]*`" +syn match purescriptFunction "\%(\" contained +" syn match purescriptFunction "\<[_a-z]\(\w\|\'\)*\>" contained +syn match purescriptFunction "(\%(\" containedin=purescriptClassDecl contained + \ nextgroup=purescriptClassName + \ skipnl +syn match purescriptClassName "\<[A-Z]\w*\>" containedin=purescriptClassDecl contained " Module syn match purescriptModuleName "\(\w\+\.\?\)*" contained excludenl @@ -44,8 +55,8 @@ syn match purescriptModuleKeyword "\" syn match purescriptModule "^module\>\s\+\<\(\w\+\.\?\)*\>" \ contains=purescriptModuleKeyword,purescriptModuleName \ nextgroup=purescriptModuleParams skipwhite skipnl skipempty -syn region purescriptModuleParams start="(" end=")" fold contained keepend - \ contains=purescriptDelimiter,purescriptType,purescriptTypeExport,purescriptFunction,purescriptStructure,purescriptModuleKeyword,@purescriptComment +syn region purescriptModuleParams start="(" skip="([^)]\{-})" end=")" fold contained keepend + \ contains=purescriptClassDecl,purescriptClass,purescriptClassName,purescriptDelimiter,purescriptType,purescriptTypeExport,purescriptFunction,purescriptStructure,purescriptModuleKeyword,@purescriptComment \ nextgroup=purescriptImportParams skipwhite " Import @@ -84,8 +95,9 @@ syn match purescriptForall "∀" syn keyword purescriptConditional if then else syn keyword purescriptStatement do case of in syn keyword purescriptLet let +" syn keyword purescriptClass class syn keyword purescriptWhere where -syn match purescriptStructure "\<\(data\|newtype\|type\|class\|kind\)\>" +syn match purescriptStructure "\<\(data\|newtype\|type\|kind\)\>" \ nextgroup=purescriptType skipwhite syn keyword purescriptStructure derive syn keyword purescriptStructure instance @@ -99,7 +111,7 @@ syn match purescriptInfix "^\(infix\|infixl\|infixr\)\>\s\+\([0-9]\+\)\s\+\(type " Operators syn match purescriptOperator "\([-!#$%&\*\+/<=>\?@\\^|~:]\|\<_\>\)" -syn match purescriptOperatorType "\(::\|∷\)" +syn match purescriptOperatorType "\%(\.*\)\@40\|<-\|[\\→←]\)" syn match purescriptOperatorTypeSig "\(->\|<-\|=>\|<=\|::\|[∷∀→←⇒⇐]\)" contained @@ -174,6 +186,8 @@ highlight def link purescriptLineComment purescriptComment highlight def link purescriptBlockComment purescriptComment " purescript general highlights +highlight def link purescriptClass purescriptKeyword +highlight def link purescriptClassName Type highlight def link purescriptStructure purescriptKeyword highlight def link purescriptKeyword Keyword highlight def link purescriptStatement Statement