summaryrefslogtreecommitdiffstats
path: root/syntax/purescript.vim
diff options
context:
space:
mode:
Diffstat (limited to 'syntax/purescript.vim')
-rw-r--r--syntax/purescript.vim32
1 files changed, 23 insertions, 9 deletions
diff --git a/syntax/purescript.vim b/syntax/purescript.vim
index 39ad579f..50e35395 100644
--- a/syntax/purescript.vim
+++ b/syntax/purescript.vim
@@ -21,13 +21,13 @@ syn keyword purescriptBoolean true false
syn match purescriptDelimiter "[,;|.()[\]{}]"
" Constructor
-syn match purescriptConstructor "\<[A-Z]\w*\>"
+syn match purescriptConstructor "\%(\<class\s\+\)\@15<!\<[A-Z]\w*\>"
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 "\%(\<class\s\+\)\@15<!\<[A-Z]\w*\>" contained
\ containedin=purescriptTypeAlias
\ nextgroup=purescriptType,purescriptTypeVar skipwhite
syn match purescriptTypeVar "\<[_a-z]\(\w\|\'\)*\>" contained
@@ -36,9 +36,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 "\%(\<instance\s\+\|\<class\s\+\)\@18<!\<[_a-z]\(\w\|\'\)*\>" contained
+" syn match purescriptFunction "\<[_a-z]\(\w\|\'\)*\>" contained
+syn match purescriptFunction "(\%(\<class\s\+\)\@18<!\(\W\&[^(),\"]\)\+)" contained extend
+syn match purescriptBacktick "`[_A-Za-z][A-Za-z0-9_\.]*`"
+
+" Class
+syn region purescriptClassDecl start="^\%(\s*\)class\>"ms=e-5 end="\<where\>\|$"
+ \ contains=purescriptClass,purescriptClassName,purescriptOperatorType,purescriptOperator,purescriptType,purescriptWhere
+ \ nextgroup=purescriptClass
+ \ skipnl
+syn match purescriptClass "\<class\>" containedin=purescriptClassDecl contained
+ \ nextgroup=purescriptClassName
+ \ skipnl
+syn match purescriptClassName "\<[A-Z]\w*\>" containedin=purescriptClassDecl contained
" Module
syn match purescriptModuleName "\(\w\+\.\?\)*" contained excludenl
@@ -46,8 +57,8 @@ syn match purescriptModuleKeyword "\<module\>"
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
@@ -86,8 +97,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
@@ -101,7 +113,7 @@ syn match purescriptInfix "^\(infix\|infixl\|infixr\)\>\s\+\([0-9]\+\)\s\+\(type
" Operators
syn match purescriptOperator "\([-!#$%&\*\+/<=>\?@\\^|~:]\|\<_\>\)"
-syn match purescriptOperatorType "\(::\|∷\)"
+syn match purescriptOperatorType "\%(\<instance\>.*\)\@40<!\(::\|∷\)"
\ nextgroup=purescriptForall,purescriptType skipwhite skipnl skipempty
syn match purescriptOperatorFunction "\(->\|<-\|[\\→←]\)"
syn match purescriptOperatorTypeSig "\(->\|<-\|=>\|<=\|::\|[∷∀→←⇒⇐]\)" contained
@@ -176,6 +188,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