clone url: git://git.m455.casa/fennel.vim
syntax/fennel.vim
1 | " Vim syntax file |
2 | " Language: FENNEL |
3 | " Maintainer: Calvin Rose |
4 |
|
5 | if exists("b:current_syntax") |
6 | finish |
7 | endif |
8 |
|
9 | let s:cpo_sav = &cpo |
10 | set cpo&vim |
11 |
|
12 | if has("folding") && exists("g:fennel_fold") && g:fennel_fold > 0 |
13 | setlocal foldmethod=syntax |
14 | endif |
15 |
|
16 | syntax keyword FennelCommentTodo contained FIXME XXX TODO FIXME: XXX: TODO: |
17 |
|
18 | " FENNEL comments |
19 | syn match FennelComment ";.*$" contains=FennelCommentTodo,@Spell |
20 |
|
21 | syntax match FennelStringEscape '\v\\%([abfnrtv'"\\]|x[[0-9a-fA-F]]\{2}|25[0-5]|2[0-4][0-9]|[0-1][0-9][0-9])' contained |
22 | syntax region FennelString matchgroup=FennelStringDelimiter start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=FennelStringEscape,@Spell |
23 | syntax region FennelString matchgroup=FennelStringDelimiter start=/'/ skip=/\\\\\|\\'/ end=/'/ contains=FennelStringEscape,@Spell |
24 |
|
25 | syn keyword FennelConstant nil |
26 |
|
27 | syn keyword FennelBoolean true |
28 | syn keyword FennelBoolean false |
29 |
|
30 | " Fennel special forms |
31 | syn keyword FennelSpecialForm # |
32 | syn keyword FennelSpecialForm % |
33 | syn keyword FennelSpecialForm * |
34 | syn keyword FennelSpecialForm + |
35 | syn keyword FennelSpecialForm - |
36 | syn keyword FennelSpecialForm -> |
37 | syn keyword FennelSpecialForm ->> |
38 | syn keyword FennelSpecialForm -?> |
39 | syn keyword FennelSpecialForm -?>> |
40 | syn keyword FennelSpecialForm . |
41 | syn keyword FennelSpecialForm .. |
42 | syn keyword FennelSpecialForm / |
43 | syn keyword FennelSpecialForm // |
44 | syn keyword FennelSpecialForm : |
45 | syn keyword FennelSpecialForm < |
46 | syn keyword FennelSpecialForm <= |
47 | syn keyword FennelSpecialForm = |
48 | syn keyword FennelSpecialForm > |
49 | syn keyword FennelSpecialForm >= |
50 | syn keyword FennelSpecialForm ^ |
51 | syn keyword FennelSpecialForm and |
52 | syn keyword FennelSpecialForm collect |
53 | syn keyword FennelSpecialForm comment |
54 | syn keyword FennelSpecialForm do |
55 | syn keyword FennelSpecialForm doc |
56 | syn keyword FennelSpecialForm doto |
57 | syn keyword FennelSpecialForm each |
58 | syn keyword FennelSpecialForm eval-compiler |
59 | syn keyword FennelSpecialForm fn |
60 | syn keyword FennelSpecialForm for |
61 | syn keyword FennelSpecialForm global |
62 | syn keyword FennelSpecialForm hashfn |
63 | syn keyword FennelSpecialForm icollect |
64 | syn keyword FennelSpecialForm if |
65 | syn keyword FennelSpecialForm include |
66 | syn keyword FennelSpecialForm lambda |
67 | syn keyword FennelSpecialForm length |
68 | syn keyword FennelSpecialForm let |
69 | syn keyword FennelSpecialForm local |
70 | syn keyword FennelSpecialForm lua |
71 | syn keyword FennelSpecialForm macro |
72 | syn keyword FennelSpecialForm macros |
73 | syn keyword FennelSpecialForm match |
74 | syn keyword FennelSpecialForm not |
75 | syn keyword FennelSpecialForm not= |
76 | syn keyword FennelSpecialForm or |
77 | syn keyword FennelSpecialForm partial |
78 | syn keyword FennelSpecialForm quote |
79 | syn keyword FennelSpecialForm require-macros |
80 | syn keyword FennelSpecialForm set |
81 | syn keyword FennelSpecialForm set-forcibly! |
82 | syn keyword FennelSpecialForm tset |
83 | syn keyword FennelSpecialForm values |
84 | syn keyword FennelSpecialForm var |
85 | syn keyword FennelSpecialForm when |
86 | syn keyword FennelSpecialForm while |
87 | syn keyword FennelSpecialForm with-open |
88 | syn keyword FennelSpecialForm ~= |
89 | syn keyword FennelSpecialForm λ |
90 |
|
91 | " Lua keywords |
92 | syntax keyword LuaSpecialValue |
93 | \ _G |
94 | \ _VERSION |
95 | \ assert |
96 | \ collectgarbage |
97 | \ dofile |
98 | \ error |
99 | \ getmetatable |
100 | \ ipairs |
101 | \ load |
102 | \ loadfile |
103 | \ next |
104 | \ pairs |
105 | \ pcall |
106 | \ print |
107 | \ rawequal |
108 | \ rawget |
109 | \ rawlen |
110 | \ rawset |
111 | \ require |
112 | \ select |
113 | \ setmetatable |
114 | \ tonumber |
115 | \ tostring |
116 | \ type |
117 | \ xpcall |
118 | \ coroutine |
119 | \ coroutine.create |
120 | \ coroutine.isyieldable |
121 | \ coroutine.resume |
122 | \ coroutine.running |
123 | \ coroutine.status |
124 | \ coroutine.wrap |
125 | \ coroutine.yield |
126 | \ debug |
127 | \ debug.debug |
128 | \ debug.gethook |
129 | \ debug.getinfo |
130 | \ debug.getlocal |
131 | \ debug.getmetatable |
132 | \ debug.getregistry |
133 | \ debug.getupvalue |
134 | \ debug.getuservalue |
135 | \ debug.sethook |
136 | \ debug.setlocal |
137 | \ debug.setmetatable |
138 | \ debug.setupvalue |
139 | \ debug.setuservalue |
140 | \ debug.traceback |
141 | \ debug.upvalueid |
142 | \ debug.upvaluejoin |
143 | \ io |
144 | \ io.close |
145 | \ io.flush |
146 | \ io.input |
147 | \ io.lines |
148 | \ io.open |
149 | \ io.output |
150 | \ io.popen |
151 | \ io.read |
152 | \ io.stderr |
153 | \ io.stdin |
154 | \ io.stdout |
155 | \ io.tmpfile |
156 | \ io.type |
157 | \ io.write |
158 | \ math |
159 | \ math.abs |
160 | \ math.acos |
161 | \ math.asin |
162 | \ math.atan |
163 | \ math.ceil |
164 | \ math.cos |
165 | \ math.deg |
166 | \ math.exp |
167 | \ math.floor |
168 | \ math.fmod |
169 | \ math.huge |
170 | \ math.log |
171 | \ math.max |
172 | \ math.maxinteger |
173 | \ math.min |
174 | \ math.mininteger |
175 | \ math.modf |
176 | \ math.pi |
177 | \ math.rad |
178 | \ math.random |
179 | \ math.randomseed |
180 | \ math.sin |
181 | \ math.sqrt |
182 | \ math.tan |
183 | \ math.tointeger |
184 | \ math.type |
185 | \ math.ult |
186 | \ os |
187 | \ os.clock |
188 | \ os.date |
189 | \ os.difftime |
190 | \ os.execute |
191 | \ os.exit |
192 | \ os.getenv |
193 | \ os.remove |
194 | \ os.rename |
195 | \ os.setlocale |
196 | \ os.time |
197 | \ os.tmpname |
198 | \ package |
199 | \ package.config |
200 | \ package.cpath |
201 | \ package.loaded |
202 | \ package.loadlib |
203 | \ package.path |
204 | \ package.preload |
205 | \ package.searchers |
206 | \ package.searchpath |
207 | \ string |
208 | \ string.byte |
209 | \ string.char |
210 | \ string.dump |
211 | \ string.find |
212 | \ string.format |
213 | \ string.gmatch |
214 | \ string.gsub |
215 | \ string.len |
216 | \ string.lower |
217 | \ string.match |
218 | \ string.pack |
219 | \ string.packsize |
220 | \ string.rep |
221 | \ string.reverse |
222 | \ string.sub |
223 | \ string.unpack |
224 | \ string.upper |
225 | \ table |
226 | \ table.concat |
227 | \ table.insert |
228 | \ table.move |
229 | \ table.pack |
230 | \ table.remove |
231 | \ table.sort |
232 | \ table.unpack |
233 | \ utf8 |
234 | \ utf8.char |
235 | \ utf8.charpattern |
236 | \ utf8.codepoint |
237 | \ utf8.codes |
238 | \ utf8.len |
239 | \ utf8.offset |
240 |
|
241 | " Fennel Symbols |
242 | let s:symcharnodig = '\!\$%\&\#\*\+\-./:<=>?A-Z^_a-z|\x80-\U10FFFF' |
243 | let s:symchar = '0-9' . s:symcharnodig |
244 | execute 'syn match FennelSymbol "\v<%([' . s:symcharnodig . '])%([' . s:symchar . '])*>"' |
245 | execute 'syn match FennelKeyword "\v<:%([' . s:symchar . '])*>"' |
246 | unlet! s:symchar s:symcharnodig |
247 |
|
248 | syn match FennelQuote "`" |
249 | syn match FennelQuote "@" |
250 |
|
251 | " FENNEL numbers |
252 | syntax match FennelNumber "\v\c<[-+]?\d*\.?\d*%([eE][-+]?\d+)?>" |
253 | syntax match FennelNumber "\v\c<[-+]?0x[0-9A-F]*\.?[0-9A-F]*>" |
254 |
|
255 | " Grammar root |
256 | syntax cluster FennelTop contains=@Spell,FennelComment,FennelConstant,FennelQuote,FennelKeyword,LuaSpecialValue,FennelSymbol,FennelNumber,FennelString,FennelList,FennelArray,FennelTable,FennelSpecialForm,FennelBoolean |
257 |
|
258 | syntax region FennelList matchgroup=FennelParen start="(" end=")" contains=@FennelTop fold |
259 | syntax region FennelArray matchgroup=FennelParen start="\[" end="]" contains=@FennelTop fold |
260 | syntax region FennelTable matchgroup=FennelParen start="{" end="}" contains=@FennelTop fold |
261 |
|
262 | " Highlight superfluous closing parens, brackets and braces. |
263 | syntax match FennelError "]\|}\|)" |
264 |
|
265 | syntax sync fromstart |
266 |
|
267 | " Highlighting |
268 | hi def link FennelComment Comment |
269 | hi def link FennelSymbol Normal |
270 | hi def link FennelNumber Number |
271 | hi def link FennelConstant Constant |
272 | hi def link FennelKeyword Keyword |
273 | hi def link FennelSpecialForm Statement |
274 | hi def link LuaSpecialValue Identifier |
275 | hi def link FennelString String |
276 | hi def link FennelStringEscape SpecialChar |
277 | hi def link FennelBuffer String |
278 | "hi def link Delimiter Normal |
279 | hi def link FennelStringDelimiter String |
280 | hi def link FennelBoolean Boolean |
281 |
|
282 | hi def link FennelQuote SpecialChar |
283 | hi def link FennelParen Normal |
284 |
|
285 | let b:current_syntax = "fennel" |
286 |
|
287 | let &cpo = s:cpo_sav |
288 | unlet! s:cpo_sav |