robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqvim-patch:57352b2: runtime: mention subscription only ml, fix typo in maintainer email (#37222)db210dd2a4

master
9.3 KiB196 linesraw
1" Vim syntax file
2" Language:		Haskell
3" Maintainer:		Haskell Cafe mailinglist <haskell-cafe@haskell.org>
4" 			(need to be subscribed to post)
5" Last Change:		2024 Mar 28 by Enrico Maria De Angelis <enricomaria.dean6elis@gmail.com>
6"			2025 Nov 20 by Vim Project: Allow spaces in backticks #18776
7" Original Author:	John Williams <jrw@pobox.com>
8"
9" Thanks to Ryan Crumley for suggestions and John Meacham for
10" pointing out bugs. Also thanks to Ian Lynagh and Donald Bruce Stewart
11" for providing the inspiration for the inclusion of the handling
12" of C preprocessor directives, and for pointing out a bug in the
13" end-of-line comment handling.
14"
15" Options-assign a value to these variables to turn the option on:
16"
17" hs_highlight_delimiters - Highlight delimiter characters--users
18"			    with a light-colored background will
19"			    probably want to turn this on.
20" hs_highlight_boolean - Treat True and False as keywords.
21" hs_highlight_types - Treat names of primitive types as keywords.
22" hs_highlight_more_types - Treat names of other common types as keywords.
23" hs_highlight_debug - Highlight names of debugging functions.
24" hs_allow_hash_operator - Don't highlight seemingly incorrect C
25"			   preprocessor directives but assume them to be
26"			   operators
27"
28" 2004 Feb 19: Added C preprocessor directive handling, corrected eol comments
29"	       cleaned away literate haskell support (should be entirely in
30"	       lhaskell.vim)
31" 2004 Feb 20: Cleaned up C preprocessor directive handling, fixed single \
32"	       in eol comment character class
33" 2004 Feb 23: Made the leading comments somewhat clearer where it comes
34"	       to attribution of work.
35" 2008 Dec 15: Added comments as contained element in import statements
36
37" quit when a syntax file was already loaded
38if exists("b:current_syntax")
39  finish
40endif
41
42" (Qualified) identifiers (no default highlighting)
43syn match ConId "\(\<[A-Z][a-zA-Z0-9_']*\.\)*\<[A-Z][a-zA-Z0-9_']*\>" contains=@NoSpell
44syn match VarId "\(\<[A-Z][a-zA-Z0-9_']*\.\)*\<[a-z][a-zA-Z0-9_']*\>" contains=@NoSpell
45
46" Infix operators--most punctuation characters and any (qualified) identifier
47" enclosed in `backquotes`. An operator starting with : is a constructor,
48" others are variables (e.g. functions).
49syn match hsVarSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[-!#$%&\*\+/<=>\?@\\^|~.][-!#$%&\*\+/<=>\?@\\^|~:.]*"
50syn match hsConSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=:[-!#$%&\*\+./<=>\?@\\^|~:]*"
51syn match hsVarSym "` *\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[a-z][a-zA-Z0-9_']* *`"
52syn match hsConSym "` *\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[A-Z][a-zA-Z0-9_']* *`"
53
54" (Non-qualified) identifiers which start with # are labels
55syn match hsLabel "#[a-z][a-zA-Z0-9_']*\>"
56
57" Reserved symbols--cannot be overloaded.
58syn match hsDelimiter  "(\|)\|\[\|\]\|,\|;\|{\|}"
59
60" Strings and constants
61syn match   hsSpecialChar	contained "\\\([0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"\\'&\\abfnrtv]\|^[A-Z^_\[\\\]]\)"
62syn 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\)"
63syn match   hsSpecialCharError	contained "\\&\|'''\+"
64syn region  hsString		start=+"+  skip=+\\\\\|\\"+  end=+"+  contains=hsSpecialChar,@NoSpell
65syn match   hsCharacter		"[^a-zA-Z0-9_']'\([^\\]\|\\[^']\+\|\\'\)'"lc=1 contains=hsSpecialChar,hsSpecialCharError
66syn match   hsCharacter		"^'\([^\\]\|\\[^']\+\|\\'\)'" contains=hsSpecialChar,hsSpecialCharError
67syn match   hsNumber		"\v<[0-9]%(_*[0-9])*>|<0[xX]_*[0-9a-fA-F]%(_*[0-9a-fA-F])*>|<0[oO]_*%(_*[0-7])*>|<0[bB]_*[01]%(_*[01])*>"
68syn match   hsFloat		"\v<[0-9]%(_*[0-9])*\.[0-9]%(_*[0-9])*%(_*[eE][-+]?[0-9]%(_*[0-9])*)?>|<[0-9]%(_*[0-9])*_*[eE][-+]?[0-9]%(_*[0-9])*>|<0[xX]_*[0-9a-fA-F]%(_*[0-9a-fA-F])*\.[0-9a-fA-F]%(_*[0-9a-fA-F])*%(_*[pP][-+]?[0-9]%(_*[0-9])*)?>|<0[xX]_*[0-9a-fA-F]%(_*[0-9a-fA-F])*_*[pP][-+]?[0-9]%(_*[0-9])*>"
69
70" Keyword definitions.
71syn keyword hsModule		module
72syn match   hsImportGroup	"\<import\>.*" contains=hsImport,hsImportModuleName,hsImportMod,hsLineComment,hsBlockComment,hsImportList,@NoSpell nextgroup=hsImport
73syn keyword hsImport import contained nextgroup=hsImportModuleName
74syn match   hsImportModuleName '\<[A-Z][A-Za-z.]*' contained
75syn region  hsImportList start='(' skip='([^)]\{-})' end=')' keepend contained contains=ConId,VarId,hsDelimiter,hsBlockComment,hsTypedef,@NoSpell
76
77syn keyword hsImportMod contained as qualified hiding
78syn keyword hsInfix infix infixl infixr
79syn keyword hsStructure class data deriving instance default where
80syn keyword hsTypedef type
81syn keyword hsNewtypedef newtype
82syn keyword hsTypeFam family
83syn keyword hsStatement mdo do case of let in
84syn keyword hsConditional if then else
85
86" Not real keywords, but close.
87if exists("hs_highlight_boolean")
88  " Boolean constants from the standard prelude.
89  syn keyword hsBoolean True False
90endif
91if exists("hs_highlight_types")
92  " Primitive types from the standard prelude and libraries.
93  syn keyword hsType Int Integer Char Bool Float Double IO Void Addr Array String
94endif
95if exists("hs_highlight_more_types")
96  " Types from the standard prelude libraries.
97  syn keyword hsType Maybe Either Ratio Complex Ordering IOError IOResult ExitCode
98  syn keyword hsMaybe Nothing
99  syn keyword hsExitCode ExitSuccess
100  syn keyword hsOrdering GT LT EQ
101endif
102if exists("hs_highlight_debug")
103  " Debugging functions from the standard prelude.
104  syn keyword hsDebug undefined error trace
105endif
106
107
108" Comments
109syn match   hsLineComment      "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=hsTodo,@Spell
110syn region  hsBlockComment     start="{-"  end="-}" contains=hsBlockComment,hsTodo,@Spell
111syn region  hsPragma	       start="{-#" end="#-}"
112
113syn keyword hsTodo	        contained FIXME TODO XXX NOTE
114
115" C Preprocessor directives. Shamelessly ripped from c.vim and trimmed
116" First, see whether to flag directive-like lines or not
117if (!exists("hs_allow_hash_operator"))
118    syn match	cError		display "^\s*\(%:\|#\).*$"
119endif
120" Accept %: for # (C99)
121syn region	cPreCondit	start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=cComment,cCppString,cCommentError
122syn match	cPreCondit	display "^\s*\(%:\|#\)\s*\(else\|endif\)\>"
123syn region	cCppOut		start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2
124syn region	cCppOut2	contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=cCppSkip
125syn region	cCppSkip	contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cCppSkip
126syn region	cIncluded	display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
127syn match	cIncluded	display contained "<[^>]*>"
128syn match	cInclude	display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
129syn cluster	cPreProcGroup	contains=cPreCondit,cIncluded,cInclude,cDefine,cCppOut,cCppOut2,cCppSkip,cCommentStartError
130syn region	cDefine		matchgroup=cPreCondit start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$"
131syn region	cPreProc	matchgroup=cPreCondit start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend
132
133syn region	cComment	matchgroup=cCommentStart start="/\*" end="\*/" contains=cCommentStartError,cSpaceError contained
134syntax match	cCommentError	display "\*/" contained
135syntax match	cCommentStartError display "/\*"me=e-1 contained
136syn region	cCppString	start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial contained
137
138" Define the default highlighting.
139" Only when an item doesn't have highlighting yet
140
141hi def link hsModule			  hsStructure
142hi def link hsImport			  Include
143hi def link hsImportMod			  hsImport
144hi def link hsInfix			  PreProc
145hi def link hsStructure			  Structure
146hi def link hsStatement			  Statement
147hi def link hsConditional		  Conditional
148hi def link hsSpecialChar		  SpecialChar
149hi def link hsTypedef			  Typedef
150hi def link hsNewtypedef		  Typedef
151hi def link hsVarSym			  hsOperator
152hi def link hsConSym			  hsOperator
153hi def link hsOperator			  Operator
154hi def link hsTypeFam			  Structure
155if exists("hs_highlight_delimiters")
156" Some people find this highlighting distracting.
157hi def link hsDelimiter			  Delimiter
158endif
159hi def link hsSpecialCharError		  Error
160hi def link hsString			  String
161hi def link hsCharacter			  Character
162hi def link hsNumber			  Number
163hi def link hsFloat			  Float
164hi def link hsConditional			  Conditional
165hi def link hsLiterateComment		  hsComment
166hi def link hsBlockComment		  hsComment
167hi def link hsLineComment			  hsComment
168hi def link hsComment			  Comment
169hi def link hsTodo			  Todo
170hi def link hsPragma			  SpecialComment
171hi def link hsBoolean			  Boolean
172hi def link hsType			  Type
173hi def link hsMaybe			  hsEnumConst
174hi def link hsOrdering			  hsEnumConst
175hi def link hsEnumConst			  Constant
176hi def link hsDebug			  Debug
177hi def link hsLabel			  Special
178
179hi def link cCppString			  hsString
180hi def link cCommentStart		  hsComment
181hi def link cCommentError		  hsError
182hi def link cCommentStartError		  hsError
183hi def link cInclude			  Include
184hi def link cPreProc			  PreProc
185hi def link cDefine			  Macro
186hi def link cIncluded			  hsString
187hi def link cError			  Error
188hi def link cPreCondit			  PreCondit
189hi def link cComment			  Comment
190hi def link cCppSkip			  cCppOut
191hi def link cCppOut2			  cCppOut
192hi def link cCppOut			  Comment
193
194let b:current_syntax = "haskell"
195
196" Options for vi: ts=8 sw=2 sts=2 nowrap noexpandtab ft=vim