2015-10-18 10:08:51 -04:00
|
|
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haskell') == -1
|
|
|
|
|
|
|
|
" syntax highlighting for haskell
|
|
|
|
"
|
|
|
|
" Heavily modified version of the haskell syntax
|
|
|
|
" highlighter to support haskell.
|
|
|
|
"
|
|
|
|
" author: raichoo (raichoo@googlemail.com)
|
|
|
|
|
|
|
|
if version < 600
|
|
|
|
syn clear
|
|
|
|
elseif exists("b:current_syntax")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
|
|
|
syn match haskellRecordField contained containedin=haskellBlock
|
|
|
|
\ "[_a-z][a-zA-Z0-9_']*\(,\s*[_a-z][a-zA-Z0-9_']*\)*\(\s*::\|\n\s\+::\)"
|
|
|
|
\ contains=
|
|
|
|
\ haskellIdentifier,
|
|
|
|
\ haskellOperators,
|
|
|
|
\ haskellSeparator,
|
2016-05-02 04:42:37 -04:00
|
|
|
\ haskellParens
|
2015-10-18 10:08:51 -04:00
|
|
|
syn match haskellTypeSig
|
|
|
|
\ "^\s*\(where\s\+\|let\s\+\|default\s\+\)\?[_a-z][a-zA-Z0-9_']*\(,\s*[_a-z][a-zA-Z0-9_']*\)*\(\s*::\|\n\s\+::\)"
|
|
|
|
\ contains=
|
|
|
|
\ haskellWhere,
|
|
|
|
\ haskellLet,
|
2016-05-02 04:42:37 -04:00
|
|
|
\ haskellDefault,
|
2015-10-18 10:08:51 -04:00
|
|
|
\ haskellIdentifier,
|
|
|
|
\ haskellOperators,
|
|
|
|
\ haskellSeparator,
|
2016-05-02 04:42:37 -04:00
|
|
|
\ haskellParens
|
2015-10-18 10:08:51 -04:00
|
|
|
syn keyword haskelLWhere where
|
|
|
|
syn keyword haskellLet let
|
|
|
|
syn keyword haskellDeclKeyword module class instance newtype deriving in
|
|
|
|
syn match haskellDecl "\<\(type\|data\)\>\s\+\(\<family\>\)\?"
|
|
|
|
syn keyword haskellDefault default
|
|
|
|
syn keyword haskellImportKeywords import qualified safe as hiding contained
|
|
|
|
syn keyword haskellForeignKeywords foreign export import ccall safe unsafe interruptible capi prim contained
|
|
|
|
syn region haskellForeignImport start="\<foreign\>" end="::" keepend
|
|
|
|
\ contains=
|
|
|
|
\ haskellString,
|
|
|
|
\ haskellOperators,
|
|
|
|
\ haskellForeignKeywords,
|
|
|
|
\ haskellIdentifier
|
|
|
|
syn match haskellImport "^\<import\>\s\+\(\<safe\>\s\+\)\?\(\<qualified\>\s\+\)\?.\+\(\s\+\<as\>\s\+.\+\)\?\(\s\+\<hiding\>\)\?"
|
|
|
|
\ contains=
|
|
|
|
\ haskellParens,
|
|
|
|
\ haskellOperators,
|
|
|
|
\ haskellImportKeywords,
|
|
|
|
\ haskellType,
|
|
|
|
\ haskellLineComment,
|
|
|
|
\ haskellBlockComment,
|
2016-05-02 04:42:37 -04:00
|
|
|
\ haskellPragma
|
|
|
|
syn keyword haskellKeyword do case of
|
2015-10-18 10:08:51 -04:00
|
|
|
if exists('g:haskell_enable_static_pointers') && g:haskell_enable_static_pointers == 1
|
|
|
|
syn keyword haskellStatic static
|
|
|
|
endif
|
|
|
|
syn keyword haskellConditional if then else
|
|
|
|
syn match haskellNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>\|\<0[bB][10]\+\>"
|
|
|
|
syn match haskellFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
|
|
|
|
syn match haskellSeparator "[,;]"
|
|
|
|
syn region haskellParens matchgroup=haskellDelimiter start="(" end=")" contains=TOP,haskellTypeSig
|
|
|
|
syn region haskellBrackets matchgroup=haskellDelimiter start="\[" end="]" contains=TOP,haskellTypeSig
|
|
|
|
syn region haskellBlock matchgroup=haskellDelimiter start="{" end="}" contains=TOP
|
|
|
|
syn keyword haskellInfix infix infixl infixr
|
|
|
|
syn keyword haskellBottom undefined error
|
|
|
|
syn match haskellOperators "[-!#$%&\*\+/<=>\?@\\^|~:.]\+\|\<_\>"
|
|
|
|
syn match haskellQuote "\<'\+" contained
|
|
|
|
syn match haskellQuotedType "[A-Z][a-zA-Z0-9_']*\>" contained
|
|
|
|
syn region haskellQuoted start="\<'\+" end="\>"
|
|
|
|
\ contains=
|
|
|
|
\ haskellType,
|
|
|
|
\ haskellQuote,
|
|
|
|
\ haskellQuotedType,
|
|
|
|
\ haskellSeparator,
|
|
|
|
\ haskellParens,
|
|
|
|
\ haskellOperators,
|
|
|
|
\ haskellIdentifier
|
|
|
|
syn match haskellLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$"
|
|
|
|
\ contains=
|
|
|
|
\ haskellTodo,
|
|
|
|
\ @Spell
|
|
|
|
syn match haskellBacktick "`[A-Za-z_][A-Za-z0-9_\.']*`"
|
|
|
|
syn region haskellString start=+"+ skip=+\\\\\|\\"+ end=+"+
|
|
|
|
\ contains=@Spell
|
|
|
|
syn match haskellIdentifier "[_a-z][a-zA-z0-9_']*" contained
|
|
|
|
syn match haskellChar "\<'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'\>"
|
|
|
|
syn match haskellType "\<[A-Z][a-zA-Z0-9_']*\>"
|
|
|
|
syn region haskellBlockComment start="{-" end="-}"
|
|
|
|
\ contains=
|
|
|
|
\ haskellBlockComment,
|
|
|
|
\ haskellTodo,
|
|
|
|
\ @Spell
|
|
|
|
syn region haskellPragma start="{-#" end="#-}"
|
|
|
|
syn match haskellQuasiQuoted "." containedin=haskellQuasiQuote contained
|
|
|
|
syn region haskellQuasiQuote matchgroup=haskellTH start="\[[_a-z][a-zA-z0-9_']*|" end="|\]"
|
|
|
|
syn region haskellTHBlock matchgroup=haskellTH start="\[\(d\|t\|p\)\?|" end="|]" contains=TOP
|
|
|
|
syn region haskellTHDoubleBlock matchgroup=haskellTH start="\[||" end="||]" contains=TOP
|
|
|
|
syn match haskellPreProc "^#.*$"
|
|
|
|
syn keyword haskellTodo TODO FIXME contained
|
|
|
|
" Treat a shebang line at the start of the file as a comment
|
|
|
|
syn match haskellShebang "\%^#!.*$"
|
|
|
|
if exists('g:haskell_enable_typeroles') && g:haskell_enable_typeroles == 1
|
|
|
|
syn keyword haskellTypeRoles phantom representational nominal contained
|
|
|
|
syn region haskellTypeRoleBlock matchgroup=haskellTypeRoles start="type\s\+role" end="$" keepend
|
|
|
|
\ contains=
|
|
|
|
\ haskellType,
|
|
|
|
\ haskellTypeRoles
|
|
|
|
endif
|
|
|
|
if exists('g:haskell_enable_quantification') && g:haskell_enable_quantification == 1
|
|
|
|
syn keyword haskellForall forall
|
|
|
|
endif
|
|
|
|
if exists('g:haskell_enable_recursivedo') && g:haskell_enable_recursivedo == 1
|
|
|
|
syn keyword haskellRecursiveDo mdo rec
|
|
|
|
endif
|
|
|
|
if exists('g:haskell_enable_arrowsyntax') && g:haskell_enable_arrowsyntax == 1
|
|
|
|
syn keyword haskellArrowSyntax proc
|
|
|
|
endif
|
|
|
|
if exists('g:haskell_enable_pattern_synonyms') && g:haskell_enable_pattern_synonyms == 1
|
|
|
|
syn keyword haskellPatternKeyword pattern
|
|
|
|
endif
|
|
|
|
|
|
|
|
highlight def link haskellBottom Macro
|
|
|
|
highlight def link haskellTH Boolean
|
|
|
|
highlight def link haskellIdentifier Identifier
|
|
|
|
highlight def link haskellForeignKeywords Structure
|
2016-05-02 04:42:37 -04:00
|
|
|
highlight def link haskellKeyword Keyword
|
|
|
|
highlight def link haskellDefault Keyword
|
2015-10-18 10:08:51 -04:00
|
|
|
highlight def link haskellConditional Conditional
|
|
|
|
highlight def link haskellNumber Number
|
|
|
|
highlight def link haskellFloat Float
|
|
|
|
highlight def link haskellSeparator Delimiter
|
|
|
|
highlight def link haskellDelimiter Delimiter
|
2016-05-02 04:42:37 -04:00
|
|
|
highlight def link haskellInfix Keyword
|
2015-10-18 10:08:51 -04:00
|
|
|
highlight def link haskellOperators Operator
|
|
|
|
highlight def link haskellQuote Operator
|
|
|
|
highlight def link haskellShebang Comment
|
|
|
|
highlight def link haskellLineComment Comment
|
|
|
|
highlight def link haskellBlockComment Comment
|
|
|
|
highlight def link haskellPragma SpecialComment
|
|
|
|
highlight def link haskellString String
|
|
|
|
highlight def link haskellChar String
|
|
|
|
highlight def link haskellBacktick Operator
|
|
|
|
highlight def link haskellQuasiQuoted String
|
2016-05-02 04:42:37 -04:00
|
|
|
highlight def link haskellTodo Todo
|
|
|
|
if exists('g:haskell_classic_highlighting') && g:haskell_classic_highlighting == 1
|
|
|
|
highlight def link haskellPreProc PreProc
|
|
|
|
highlight def link haskellAssocType Type
|
|
|
|
highlight def link haskellImportKeywords Include
|
|
|
|
highlight def link haskellDeclKeyword Keyword
|
|
|
|
highlight def link haskellDecl Keyword
|
|
|
|
highlight def link haskellWhere Keyword
|
|
|
|
highlight def link haskellLet Keyword
|
|
|
|
highlight def link haskellQuotedType Type
|
|
|
|
highlight def link haskellType Type
|
|
|
|
else
|
|
|
|
highlight def link haskellPreProc Macro
|
|
|
|
highlight def link haskellAssocType Structure
|
|
|
|
highlight def link haskellImportKeywords Structure
|
|
|
|
highlight def link haskellDeclKeyword Structure
|
|
|
|
highlight def link haskellDecl Structure
|
|
|
|
highlight def link haskellWhere Structure
|
|
|
|
highlight def link haskellLet Structure
|
|
|
|
highlight def link haskellQuotedType Include
|
|
|
|
highlight def link haskellType Include
|
|
|
|
endif
|
2015-10-18 10:08:51 -04:00
|
|
|
|
|
|
|
if exists('g:haskell_enable_quantification') && g:haskell_enable_quantification == 1
|
|
|
|
highlight def link haskellForall Operator
|
|
|
|
endif
|
|
|
|
if exists('g:haskell_enable_recursivedo') && g:haskell_enable_recursivedo == 1
|
2016-05-02 04:42:37 -04:00
|
|
|
highlight def link haskellRecursiveDo Keyword
|
2015-10-18 10:08:51 -04:00
|
|
|
endif
|
|
|
|
if exists('g:haskell_enable_arrowsyntax') && g:haskell_enable_arrowsyntax == 1
|
2016-05-02 04:42:37 -04:00
|
|
|
highlight def link haskellArrowSyntax Keyword
|
2015-10-18 10:08:51 -04:00
|
|
|
endif
|
|
|
|
if exists('g:haskell_enable_static_pointers') && g:haskell_enable_static_pointers == 1
|
2016-05-02 04:42:37 -04:00
|
|
|
highlight def link haskellStatic Keyword
|
|
|
|
endif
|
|
|
|
if exists('g:haskell_classic_highlighting') && g:haskell_classic_highlighting == 1
|
|
|
|
if exists('g:haskell_enable_pattern_synonyms') && g:haskell_enable_pattern_synonyms == 1
|
|
|
|
highlight def link haskellPatternKeyword Keyword
|
|
|
|
endif
|
|
|
|
if exists('g:haskell_enable_typeroles') && g:haskell_enable_typeroles == 1
|
|
|
|
highlight def link haskellTypeRoles Keyword
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
if exists('g:haskell_enable_pattern_synonyms') && g:haskell_enable_pattern_synonyms == 1
|
|
|
|
highlight def link haskellPatternKeyword Structure
|
|
|
|
endif
|
|
|
|
if exists('g:haskell_enable_typeroles') && g:haskell_enable_typeroles == 1
|
|
|
|
highlight def link haskellTypeRoles Structure
|
|
|
|
endif
|
2015-10-18 10:08:51 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
let b:current_syntax = "haskell"
|
|
|
|
|
|
|
|
endif
|