3 " Maintainer: John Williams <jrw@pobox.com>
4 " Last Change: 2001 May 10
5 " Thanks to Ryan Crumley for suggestions and John Meacham for
8 " Options-assign a value to these variables to turn the option on:
10 " hs_highlight_delimiters - Highlight delimiter characters--users
11 " with a light-colored background will
12 " probably want to turn this on.
13 " hs_highlight_boolean - Treat True and False as keywords.
14 " hs_highlight_types - Treat names of primitive types as keywords.
15 " hs_highlight_more_types - Treat names of other common types as keywords.
16 " hs_highlight_debug - Highlight names of debugging functions.
18 " Remove any old syntax stuff hanging around
21 elseif exists("b:current_syntax")
25 " (Qualified) identifiers (no default highlighting)
26 syn match ConId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[A-Z][a-zA-Z0-9_']*\>"
27 syn match VarId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[a-z][a-zA-Z0-9_']*\>"
29 " Infix operators--most punctuation characters and any (qualified) identifier
30 " enclosed in `backquotes`. An operator starting with : is a constructor,
31 " others are variables (e.g. functions).
32 syn match hsVarSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[-!#$%&\*\+/<=>\?@\\^|~.][-!#$%&\*\+/<=>\?@\\^|~:.]*"
33 syn match hsConSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=:[-!#$%&\*\+./<=>\?@\\^|~:]*"
34 syn match hsVarSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[a-z][a-zA-Z0-9_']*`"
35 syn match hsConSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[A-Z][a-zA-Z0-9_']*`"
37 " Reserved symbols--cannot be overloaded.
38 syn match hsDelimiter "(\|)\|\[\|\]\|,\|;\|_\|{\|}"
40 " Strings and constants
41 syn match hsSpecialChar contained "\\\([0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"\\'&\\abfnrtv]\|^[A-Z^_\[\\\]]\)"
42 syn match hsSpecialChar contained "\\\(NUL\|SOH\|STX\|ETX\|EOT\|ENQ\|ACK\|BEL\|BS\|HT\|LF\|VT\|FF\|CR\|SO\|SI\|DLE\|DC1\|DC2\|DC3\|DC4\|NAK\|SYN\|ETB\|CAN\|EM\|SUB\|ESC\|FS\|GS\|RS\|US\|SP\|DEL\)"
43 syn match hsSpecialCharError contained "\\&\|'''\+"
44 syn region hsString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=hsSpecialChar
45 syn match hsCharacter "[^a-zA-Z0-9_']'\([^\\]\|\\[^']\+\|\\'\)'"lc=1 contains=hsSpecialChar,hsSpecialCharError
46 syn match hsCharacter "^'\([^\\]\|\\[^']\+\|\\'\)'" contains=hsSpecialChar,hsSpecialCharError
47 syn match hsNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>"
48 syn match hsFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
50 " Keyword definitions. These must be patters instead of keywords
51 " because otherwise they would match as keywords at the start of a
52 " "literate" comment (see lhs.vim).
53 syn match hsModule "\<module\>"
54 syn match hsImport "\<import\>.*"he=s+6 contains=hsImportMod
55 syn match hsImportMod contained "\<\(as\|qualified\|hiding\)\>"
56 syn match hsInfix "\<\(infix\|infixl\|infixr\)\>"
57 syn match hsStructure "\<\(class\|data\|deriving\|instance\|default\|where\)\>"
58 syn match hsTypedef "\<\(type\|newtype\)\>"
59 syn match hsStatement "\<\(do\|case\|of\|let\|in\)\>"
60 syn match hsConditional "\<\(if\|then\|else\)\>"
62 " Not real keywords, but close.
63 if exists("hs_highlight_boolean")
64 " Boolean constants from the standard prelude.
65 syn match hsBoolean "\<\(True\|False\)\>"
67 if exists("hs_highlight_types")
68 " Primitive types from the standard prelude and libraries.
69 syn match hsType "\<\(Int\|Integer\|Char\|Bool\|Float\|Double\|IO\|Void\|Addr\|Array\|String\)\>"
71 if exists("hs_highlight_more_types")
72 " Types from the standard prelude libraries.
73 syn match hsType "\<\(Maybe\|Either\|Ratio\|Complex\|Ordering\|IOError\|IOResult\|ExitCode\)\>"
74 syn match hsMaybe "\<Nothing\>"
75 syn match hsExitCode "\<\(ExitSuccess\)\>"
76 syn match hsOrdering "\<\(GT\|LT\|EQ\)\>"
78 if exists("hs_highlight_debug")
79 " Debugging functions from the standard prelude.
80 syn match hsDebug "\<\(undefined\|error\|trace\)\>"
85 syn match hsLineComment "--.*"
86 syn region hsBlockComment start="{-" end="-}" contains=hsBlockComment
87 syn region hsPragma start="{-#" end="#-}"
89 " Literate comments--any line not starting with '>' is a comment.
90 if exists("b:hs_literate_comments")
91 syn region hsLiterateComment start="^" end="^>"
94 if !exists("hs_minlines")
97 exec "syn sync lines=" . hs_minlines
99 if version >= 508 || !exists("did_hs_syntax_inits")
101 let did_hs_syntax_inits = 1
102 command -nargs=+ HiLink hi link <args>
104 command -nargs=+ HiLink hi def link <args>
107 hi link hsModule hsStructure
108 hi link hsImport Include
109 hi link hsImportMod hsImport
110 hi link hsInfix PreProc
111 hi link hsStructure Structure
112 hi link hsStatement Statement
113 hi link hsConditional Conditional
114 hi link hsSpecialChar SpecialChar
115 hi link hsTypedef Typedef
116 hi link hsVarSym hsOperator
117 hi link hsConSym hsOperator
118 hi link hsOperator Operator
119 if exists("hs_highlight_delimiters")
120 " Some people find this highlighting distracting.
121 hi link hsDelimiter Delimiter
123 hi link hsSpecialCharError Error
124 hi link hsString String
125 hi link hsCharacter Character
126 hi link hsNumber Number
127 hi link hsFloat Float
128 hi link hsConditional Conditional
129 hi link hsLiterateComment hsComment
130 hi link hsBlockComment hsComment
131 hi link hsLineComment hsComment
132 hi link hsComment Comment
133 hi link hsPragma SpecialComment
134 hi link hsBoolean Boolean
136 hi link hsMaybe hsEnumConst
137 hi link hsOrdering hsEnumConst
138 hi link hsEnumConst Constant
139 hi link hsDebug Debug
144 let b:current_syntax = "haskell"
146 " Options for vi: ts=8 sw=2 sts=2 nowrap noexpandtab ft=vim