haskell-vim/syntax/haskell.vim

102 lines
4.5 KiB
VimL
Raw Normal View History

2014-06-17 18:32:44 +00:00
" 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
2014-07-03 17:12:52 +00:00
syn keyword haskellBlockKeywords data type family module where class instance contained
2014-07-04 14:45:16 +00:00
syn region haskellModuleBlock start="\<module\>" end="\<where\>"
2014-07-04 15:48:12 +00:00
\ contains=haskellType,haskellDelimiter,haskellDot,haskellOperators,haskellModule,haskellBlockKeywords,haskellLineComment,haskellBlockComment keepend
2014-07-04 15:28:52 +00:00
syn region haskellBlock start="\<\(class\|instance\)\>" end="\(\<where\>\|[\n]\)"
2014-07-04 14:45:16 +00:00
\ contains=haskellType,haskellDelimiter,haskellDot,haskellOperators,haskellModule,haskellBlockKeywords keepend
2014-07-04 15:28:52 +00:00
syn region haskellDataBlock start="\<\(data\|type\)\>\(\s\+\<family\>\)\?" end="\([=\n]\|\<where\>\)"
2014-07-04 14:45:16 +00:00
\ contains=haskellType,haskellDelimiter,haskellDot,haskellOperators,haskellModule,haskellBlockKeywords keepend
2014-06-18 21:40:03 +00:00
syn match haskellImport "\(\<import\>\(\s\+safe\)\?\|\<hiding\>\)"
syn match haskellForeign "\<foreign\>\s\+\<\(export\|import\)\>\(\s\+\(\<ccall\>\(\s\+\<\(\(un\)\?safe\|interruptible\)\>\)\?\|\<capi\>\|\<prim\>\)\>\)\?"
2014-06-18 08:04:52 +00:00
syn region haskellQualifiedImport start="\<qualified\>" contains=haskellType,haskellDot end="\<as\>"
2014-07-10 17:43:37 +00:00
syn keyword haskellStructure newtype deriving default
2014-07-03 17:12:52 +00:00
syn keyword haskellStatement do case of let in where
2014-06-25 13:13:49 +00:00
syn keyword haskellConditional if then else
2014-06-17 18:32:44 +00:00
syn match haskellNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>"
syn match haskellFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
2014-06-25 12:09:11 +00:00
syn match haskellDelimiter "(\|)\|\[\|\]\|,\|;\|{\|}"
2014-06-25 13:13:49 +00:00
syn keyword haskellInfix infix infixl infixr
2014-07-05 17:54:43 +00:00
syn keyword haskellBottom undefined error
2014-06-17 20:12:17 +00:00
syn match haskellOperators "\([-!#$%&\*\+/<=>\?@\\^|~:]\|\<_\>\)"
syn match haskellDot "\."
syn match haskellType "\<[A-Z][a-zA-Z0-9_]*\>"
2014-06-26 08:52:40 +00:00
syn match haskellLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=@Spell
2014-06-17 18:32:44 +00:00
syn match haskellChar "'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'"
2014-07-04 13:51:36 +00:00
syn match haskellBacktick "`[A-Za-z][A-Za-z0-9_\.]*\('\)*`"
2014-06-26 08:52:40 +00:00
syn region haskellString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell
syn region haskellBlockComment start="{-" end="-}" contains=haskellBlockComment,@Spell
2014-07-05 20:47:00 +00:00
syn match haskellIdentifier "[_a-z][a-zA-z0-9_]*\('\)*" contained
syn match haskellTopLevelDecl "\s*[_a-z][a-zA-z0-9_]*\('\)*\s*::" contains=haskellIdentifier,haskellOperators
2014-06-17 18:32:44 +00:00
2014-08-16 19:15:48 +00:00
if exists('g:haskell_enable_typeroles')
syn keyword haskellTypeRoles type role phantom representational nominal contained
syn region haskellTypeRoleBlock start="type\s\+role" end="[\n]"
\ contains=haskellType,haskellTypeRoles keepend
endif
2014-06-25 11:43:07 +00:00
if exists('g:haskell_enable_quantification')
2014-08-16 19:50:26 +00:00
syn keyword haskellForall forall contained
syn match haskellQuantification "\<\(forall\)\>\s\+[^.=]*\."
\ contains=haskellForall,haskellOperators,haskellDot,haskellDelimiter
2014-06-25 11:43:07 +00:00
endif
if exists('g:haskell_enable_recursivedo')
2014-06-25 13:13:49 +00:00
syn keyword haskellRecursiveDo mdo rec
2014-06-25 11:43:07 +00:00
endif
if exists('g:haskell_enable_arrowsyntax')
2014-06-25 13:13:49 +00:00
syn keyword haskellArrowSyntax proc
2014-06-25 11:43:07 +00:00
endif
2014-07-05 20:36:25 +00:00
if exists('g:haskell_enable_pattern_synonyms')
syn keyword haskellPatternSynonyms pattern
endif
2014-08-16 19:15:48 +00:00
2014-07-05 17:54:43 +00:00
highlight def link haskellBottom Macro
2014-07-03 17:12:52 +00:00
highlight def link haskellBlockKeywords Structure
2014-06-26 08:53:27 +00:00
highlight def link haskellIdentifier Identifier
2014-06-17 18:32:44 +00:00
highlight def link haskellImport Structure
2014-06-18 21:40:03 +00:00
highlight def link haskellForeign Structure
2014-06-17 20:12:17 +00:00
highlight def link haskellQualifiedImport Structure
2014-06-17 18:32:44 +00:00
highlight def link haskellStructure Structure
highlight def link haskellStatement Statement
highlight def link haskellConditional Conditional
highlight def link haskellNumber Number
highlight def link haskellFloat Float
highlight def link haskellDelimiter Delimiter
highlight def link haskellInfix PreProc
highlight def link haskellOperators Operator
2014-06-17 20:12:17 +00:00
highlight def link haskellDot Operator
2014-06-17 18:32:44 +00:00
highlight def link haskellType Include
highlight def link haskellLineComment Comment
highlight def link haskellBlockComment Comment
highlight def link haskellString String
highlight def link haskellChar String
highlight def link haskellBacktick Operator
2014-06-25 11:43:07 +00:00
if exists('g:haskell_enable_quantification')
2014-08-16 19:50:26 +00:00
highlight def link haskellForall Operator
2014-06-25 11:43:07 +00:00
endif
if exists('g:haskell_enable_recursivedo')
highlight def link haskellRecursiveDo Operator
endif
if exists('g:haskell_enable_arrowsyntax')
highlight def link haskellArrowSyntax Operator
endif
2014-07-05 20:36:25 +00:00
if exists('g:haskell_enable_pattern_synonyms')
highlight def link haskellPatternSynonyms Structure
endif
2014-08-16 19:15:48 +00:00
if exists('g:haskell_enable_typeroles')
highlight def link haskellTypeRoles Structure
endif
2014-06-25 11:43:07 +00:00
2014-06-17 18:32:44 +00:00
let b:current_syntax = "haskell"