1 diff -Naur vim61.old/runtime/indent/ocaml.vim vim61/runtime/indent/ocaml.vim
2 --- vim61.old/runtime/indent/ocaml.vim Wed Oct 30 22:10:31 2002
3 +++ vim61/runtime/indent/ocaml.vim Wed Oct 30 22:12:09 2002
7 -" Maintainers: Mike Leary <leary@nwlink.com>
8 -" Markus Mottl <markus@oefai.at>
9 -" URL: http://www.ai.univie.ac.at/~markus/vim/indent/ocaml.vim
10 -" Last Change: 2001 Oct 03 - minor addition (MM)
11 -" 2001 Sep 02 - set option 'expandtab' (MM)
12 -" 2001 Aug 29 - revised all rules (MM)
13 +" Maintainers: Jean-Francois Yuen <jfyuen@ifrance.com>
14 +" Mike Leary <leary@nwlink.com>
15 +" Markus Mottl <markus@oefai.at>
16 +" URL: http://www.oefai.at/~markus/vim/indent/ocaml.vim
17 +" Last Change: 2002 Oct 28 - Fixed bug with indentation of ']' (MM)
18 +" 2002 Oct 22 - Major rewrite (JY)
19 +" 2002 Sep 08 - improved ';;' handling (JY)
21 " Only load this indent file when no other was loaded.
22 if exists("b:did_indent")
26 setlocal indentexpr=GetOCamlIndent()
27 -setlocal indentkeys+=0=done,0=end,0=if,0=then,0=else,0=and,0=in,0=with,0=>],0=\|],0},0],0)
28 +setlocal indentkeys+=0=and,0=constraint,0=done,0=else,0=end,0=exception,0=external,0=if,0=in,0=include,0=inherit,0=initializer,0=let,0=method,0=open,0=then,0=type,0=val,0=with,0=;;,0=>\],0=\|\],0=\|,0=*),0},0\],0)
30 setlocal nosmartindent
35 + set comments=sr:(*,mb:*,ex:*)
39 " Only define the function once.
40 if exists("*GetOCamlIndent")
44 +" Define some patterns:
45 +let s:beflet = '^\s*\(try\|method\)\|\(\<\(begin\|do\|else\|in\|then\|try\)\|->\|;\)\s*$'
46 +let s:letpat = '^\s*\(let\|type\|module\|class\|open\|exception\|val\|include\|external\)\>'
47 +let s:letlim = '\(\<\(sig\|struct\)\|;;\)\s*$'
48 +let s:lim = '^\s*\(exception\|external\|include\|let\|module\|open\|type\|val\)\>'
49 +let s:module = '\<\%(begin\|sig\|struct\|object\)\>'
50 +let s:obj = '^\s*\(constraint\|inherit\|initializer\|method\|val\)\>\|\<\(object\|object\s*(.*)\)\s*$'
51 +let s:type = '^\s*\%(let\|type\)\>.*='
52 +let s:val = '^\s*\(val\|external\)\>.*:'
54 +" Skipping pattern, for comments
55 +function s:SkipPattern(lnum, pat)
56 + let def = prevnonblank(a:lnum - 1)
57 + while def > 0 && getline(def) =~ a:pat
58 + let def = prevnonblank(def - 1)
63 +" Indent for ';;' to match multiple 'let'
64 +function s:GetInd(lnum, pat, lim)
65 + let llet = search(a:pat, 'bW')
66 + let old = indent(a:lnum)
68 + let old = indent(llet)
69 + let nb = s:SkipPattern(llet, '^\s*(\*.*\*)\s*$')
70 + if getline(nb) =~ a:lim
73 + let llet = search(a:pat, 'bW')
79 +function s:FindPair(pstart, pmid, pend)
80 + call search(a:pend, 'bW')
81 + return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"'))
85 +function s:FindLet(pstart, pmid, pend)
86 + call search(a:pend, 'bW')
87 + return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "^\\s*let\\>.*=.*\\<in\\s*$" || getline(prevnonblank(".") - 1) =~ "^\\s*let\\>.*=\\s*$\\|" . s:beflet'))
90 function GetOCamlIndent()
91 " Find a non-blank line above the current line.
92 let lnum = prevnonblank(v:lnum - 1)
97 - let ind=indent(lnum)
98 - let lline=getline(lnum)
99 + let ind = indent(lnum)
100 + let lline = getline(lnum)
102 " Return double 'shiftwidth' after lines matching:
103 if lline =~ '^\s*|.*->\s*$'
107 " Add a 'shiftwidth' after lines ending with:
108 - if lline =~ '\(:\|=\|->\|<-\|(\|[\|{\|[|\|[<\|(\*\|\<\(begin\|struct\|sig\|functor\|object\|try\|do\|if\|then\|else\|fun\|function\|parser\)\>\)\s*$'
109 + if lline =~ '\(:\|=\|->\|<-\|(\|[\|{\|[|\|[<\|\<\(begin\|struct\|sig\|functor\|object\|try\|do\|if\|then\|else\|fun\|function\|parser\)\|\<object\s*(.*)\)\s*$'
112 + " Back to normal indent after lines ending with ';;':
113 + elseif lline =~ ';;\s*$' && lline !~ '^\s*;;'
114 + let ind = s:GetInd(v:lnum, s:letpat, s:letlim)
116 + " Back to normal indent after lines ending with 'end':
117 + elseif lline =~ '\<end\s*$' && lline !~ '^\s*end\>'
118 + let ind = s:FindPair(s:module, '','\<end\>')
120 + " Back to normal indent after lines ending with 'in':
121 + elseif lline =~ '\<in\s*$' && lline !~ '^\s*in\>'
122 + let ind = s:FindPair('\<let\>', '', '\<in\>')
124 + " Back to normal indent after lines ending with 'done':
125 + elseif lline =~ '\<done\s*$' && lline !~ '^\s*done\>'
126 + let ind = s:FindPair('\<do\>', '','\<done\>')
128 + " Back to normal indent after lines ending with '}':
129 + elseif lline =~ '}\s*$' && lline !~ '^\s*}'
130 + let ind = s:FindPair('{', '','}')
132 + " Back to normal indent after lines ending with '>]':
133 + elseif lline =~ '>\]\s*$' && lline !~ '^\s*>\]'
134 + let ind = s:FindPair('\[<', '','>\]')
136 + " Back to normal indent after lines ending with '|]':
137 + elseif lline =~ '|\]\s*$' && lline !~ '^\s*|\]'
138 + let ind = s:FindPair('\[|', '','|\]')
140 + " Back to normal indent after lines ending with ']':
141 + elseif lline =~ '\]\s*$' && lline !~ '^\s*\]'
142 + let ind = s:FindPair('\[', '','\]')
144 + " Back to normal indent after comments:
145 + elseif lline =~ '\*)\s*$' && lline !~ '^\s*\*)'
146 + call search('\*)', 'bW')
147 + let ind = indent(searchpair('(\*', '', '\*)', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"'))
149 + " Back to normal indent after lines ending with ')':
150 + elseif lline =~ ')\s*$' && lline !~ '^\s*)'
151 + let ind = s:FindPair('(', '',')')
155 + " Subtract a 'shiftwidth' after lines matching 'match ... with parser':
156 + if lline =~ '^\s*match\>.*\<with\>\s*\<parser\s*$'
157 + let ind = ind - &sw
160 - let line=getline(v:lnum)
161 + let line = getline(v:lnum)
163 - " Subtract a 'shiftwidth' if current line begins with:
164 - if line =~ '^\s*\(\(done\|end\)\>\|>]\||]\|}\|]\|)\)'
166 + " Indent if current line begins with 'end'
167 + " for 'sig', 'struct', 'object' and 'begin':
168 + if line =~ '^\s*end\>'
169 + return s:FindPair(s:module, '','\<end\>')
171 + " Indent if current line begins with 'done' for 'do':
172 + elseif line =~ '^\s*done\>'
173 + return s:FindPair('\<do\>', '','\<done\>')
175 + " Indent if current line begins with '}':
176 + elseif line =~ '^\s*}'
177 + return s:FindPair('{', '','}')
179 + " Indent if current line begins with '>]':
180 + elseif line =~ '^\s*>\]'
181 + return s:FindPair('\[<', '','>\]')
183 + " Indent if current line begins with '|]':
184 + elseif line =~ '^\s*|\]'
185 + return s:FindPair('\[|', '','|\]')
187 + " Indent if current line begins with ']':
188 + elseif line =~ '^\s*\]'
189 + return s:FindPair('\[', '','\]')
191 + " Indent if current line begins with ')':
192 + elseif line =~ '^\s*)'
193 + return s:FindPair('(', '',')')
195 + " Indent if current line begins with 'let'
196 + " and last line does not begin with 'let' or end with 'in' or ';;':
197 + elseif line =~ '^\s*let\>'
198 + if lline !~ s:lim . '\|' . s:letlim . '\|' . s:beflet
199 + return s:FindLet(s:type, '','\<let\s*$')
203 - " Subtract a 'shiftwidth' if current line begins with 'if' and last
204 + " Indent if current line begins with 'type'
205 + " and last line does not end with 'and' or ';;':
206 + elseif line =~ '^\s*type\>'
207 + if lline !~ s:lim . '\|\<and\s*$\|' . s:letlim
208 + return s:FindLet(s:type, '','\<type\s*$')
212 + " Indent for pattern matching:
213 + elseif line =~ '^\s*|'
214 + if lline !~ '^\s*\(|\|\(match\|with\|type\)\>\)\|\<\(function\|parser\|with\)\s*$'
215 + return s:FindPair('^\s*\(type\|match\)\>\|\<\(with\|function\|parser\)\s*$', '', '|')
219 + " Indent if current line begins with ';;':
220 + elseif line =~ '^\s*;;'
221 + if lline !~ ';;\s*$'
222 + return s:GetInd(v:lnum, s:letpat, s:letlim)
225 + " Subtract a 'shiftwidth' if current line begins with 'if' and previous
226 " line ends with 'else':
227 elseif line =~ '^\s*if\>'
228 if lline =~ '\<else\s*$'
229 @@ -61,39 +215,114 @@
233 - " Subtract a 'shiftwidth' if current line begins with 'in' and last
234 + " Indent if current line begins with 'in' and previous
235 " line does not start with 'let' or 'and':
236 elseif line =~ '^\s*in\>'
237 if lline !~ '^\s*\(let\|and\)\>'
239 + return s:FindPair('\<let\>', '', '\<in\>')
243 - " Subtract a 'shiftwidth' if current line begins with 'else' or 'then'
244 - " and previous line does not start with 'if', 'then' or 'else'
245 - elseif line =~ '^\s*\(else\|then\)\>'
246 + " Indent if current line begins with 'else'
247 + " and previous line does not start with 'if', 'then' or 'else':
248 + elseif line =~ '^\s*else\>'
249 if lline !~ '^\s*\(if\|else\|then\)\>'
251 + return s:FindPair('\<if\>', '', '\<else\>')
255 - " Subtract a 'shiftwidth' if current line begins with 'and' and previous
256 - " line does not start with 'let', 'and' or 'type' or end with 'end'
258 + " Indent if current line begins with 'then'
259 + " and previous line does not start with 'if', 'then' or 'else':
260 + elseif line =~ '^\s*then\>'
261 + if lline !~ '^\s*\(if\|else\|then\)\>'
262 + return s:FindPair('\<if\>', '', '\<then\>')
266 + " Indent if current line begins with 'and' and previous
267 + " line does not start with 'let', 'and' or 'type':
268 elseif line =~ '^\s*and\>'
269 - if lline !~ '^\s*\(let\|and\|type\)\>\|\<end\s*$'
271 + if lline !~ '^\s*\(and\|let\|type\)\>'
272 + return s:FindPair('^\s*\%(let\|type\|class\)\>', '', '\<and\>')
276 - " Subtract a 'shiftwidth' if current line begins with 'with'
277 + " Indent if current line begins with 'with'
278 " and previous line does not start with 'match' or 'try':
279 elseif line =~ '^\s*with\>'
280 if lline !~ '^\s*\(match\|try\)\>'
282 + return s:FindPair('\<\%(match\|try\)\>', '','\<with\>')
286 + " Indent if current line begins with 'exception':
287 + elseif line =~ '^\s*exception\>'
288 + if lline !~ s:lim . '\|' . s:letlim
289 + return indent(search(s:val . '\|^\s*\(external\|include\|open\|type\)\>'))
293 + " Indent if current line begins with 'external':
294 + elseif line =~ '^\s*external\>'
295 + if lline !~ s:lim . '\|' . s:letlim
296 + return indent(search(s:val . '\|^\s*\(exception\|include\|open\|type\)\>'))
300 + " Indent if current line begins with 'include':
301 + elseif line =~ '^\s*include\>'
302 + if lline !~ s:lim . '\|' . s:letlim
303 + return indent(search(s:val . '\|^\s*\(exception\|external\|open\|type\)\>'))
307 + " Indent if current line begins with 'open':
308 + elseif line =~ '^\s*open\>'
309 + if lline !~ s:lim . '\|' . s:letlim
310 + return indent(search(s:val . '\|^\s*\(exception\|external\|include\|type\)\>'))
314 + " Indent if current line begins with 'val':
315 + elseif line =~ '^\s*val\>'
316 + if lline !~ '^\s*\(exception\|external\|include\|open\)\>\|' . s:obj . '\|' . s:letlim
317 + return indent(search(s:val . '\|^\s*\(exception\|include\|initializer\|method\|open\|type\)\>', 'bW'))
321 + " Indent if current line begins with 'constraint':
322 + elseif line =~ '^\s*constraint\>'
324 + return indent(search('^\s*\(inherit\|initializer\|method\|val\)\>'))
328 + " Indent if current line begins with 'inherit':
329 + elseif line =~ '^\s*inherit\>'
331 + return indent(search('^\s*\(constraint\|initializer\|method\|val\)\>'))
335 + " Indent if current line begins with 'inherit':
336 + elseif line =~ '^\s*initializer\>'
338 + return indent(search('^\s*\(constraint\|inherit\|method\|val\)\>'))
342 + " Indent if current line begins with 'method':
343 + elseif line =~ '^\s*method\>'
345 + return indent(search('^\s*\(constraint\|inherit\|initializer\|val\)\>'))
349 + " Indent back to normal after comments:
350 + elseif line =~ '^\s*\*)'
351 + call search('\*)', 'bW')
352 + return indent(searchpair('(\*', '', '\*)', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"'))
357 diff -Naur vim61.old/runtime/syntax/ocaml.vim vim61/runtime/syntax/ocaml.vim
358 --- vim61.old/runtime/syntax/ocaml.vim Wed Oct 30 22:10:33 2002
359 +++ vim61/runtime/syntax/ocaml.vim Wed Oct 30 22:11:41 2002
361 " Filenames: *.ml *.mli *.mll *.mly
362 " Maintainers: Markus Mottl <markus@oefai.at>
363 " Karl-Heinz Sylla <Karl-Heinz.Sylla@gmd.de>
364 -" URL: http://www.ai.univie.ac.at/~markus/vim/syntax/ocaml.vim
365 -" Last Change: 2001 Nov 20 - Fixed small bug with modules (MM)
366 -" 2001 Sep 01 - Fixed small bug with '\'' (MM)
367 -" 2001 Aug 29 - Added rules for scripting directives (MM)
368 -" 2001 Aug 28 - Upgraded URL & mail address (MM)
369 -" 2001 Apr 26 - upgraded for new Vim version (MM)
370 +" Issac Trotts <<ijtrotts@ucdavis.edu>
371 +" URL: http://www.oefai.at/~markus/vim/syntax/ocaml.vim
372 +" Last Change: 2002 Oct 30 - New variable "ocaml_revised" (MM)
373 +" 2002 Oct 24 - Small fix for "module type" (MM)
374 +" 2002 Jun 16 - Added "&&", "<" and ">" as operators (MM)
376 " For version 5.x: Clear all syntax items
377 " For version 6.x: Quit when a syntax file was already loaded
380 syn match ocamlCountErr "\<downto\>"
381 syn match ocamlCountErr "\<to\>"
382 -syn match ocamlDoErr "\<do\>"
384 +if !exists("ocaml_revised")
385 + syn match ocamlDoErr "\<do\>"
388 syn match ocamlDoneErr "\<done\>"
389 syn match ocamlThenErr "\<then\>"
395 -syn region ocamlEnd matchgroup=ocamlKeyword start="\<begin\>" matchgroup=ocamlKeyword end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr
396 +if !exists("ocaml_revised")
397 + syn region ocamlEnd matchgroup=ocamlKeyword start="\<begin\>" matchgroup=ocamlKeyword end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr
406 -syn region ocamlDo matchgroup=ocamlKeyword start="\<do\>" matchgroup=ocamlKeyword end="\<done\>" contains=ALLBUT,@ocamlContained,ocamlDoneErr
408 +if !exists("ocaml_revised")
409 + syn region ocamlDo matchgroup=ocamlKeyword start="\<do\>" matchgroup=ocamlKeyword end="\<done\>" contains=ALLBUT,@ocamlContained,ocamlDoneErr
413 syn region ocamlNone matchgroup=ocamlKeyword start="\<if\>" matchgroup=ocamlKeyword end="\<then\>" contains=ALLBUT,@ocamlContained,ocamlThenErr
414 @@ -134,12 +140,13 @@
415 syn region ocamlWithRest start="[^)]" end=")"me=e-1 contained contains=ALLBUT,@ocamlContained
418 -syn region ocamlKeyword start="\<module\s*type\>" matchgroup=ocamlModule end="\<\w\(\w\|'\)*\>" contains=ocamlComment skipwhite skipempty nextgroup=ocamlMTDef
419 +syn region ocamlKeyword start="\<module\>\s*\<type\>" matchgroup=ocamlModule end="\<\w\(\w\|'\)*\>" contains=ocamlComment skipwhite skipempty nextgroup=ocamlMTDef
420 syn match ocamlMTDef "=\s*\w\(\w\|'\)*\>"hs=s+1,me=s
422 syn keyword ocamlKeyword and as assert class
423 syn keyword ocamlKeyword constraint else
424 -syn keyword ocamlKeyword exception external fun function
425 +syn keyword ocamlKeyword exception external fun
427 syn keyword ocamlKeyword in inherit initializer
428 syn keyword ocamlKeyword land lazy let match
429 syn keyword ocamlKeyword method mutable new of
430 @@ -147,12 +154,20 @@
431 syn keyword ocamlKeyword try type
432 syn keyword ocamlKeyword val virtual when while with
434 +if exists("ocaml_revised")
435 + syn keyword ocamlKeyword do value
436 + syn keyword ocamlBoolean True False
438 + syn keyword ocamlKeyword function
439 + syn keyword ocamlBoolean true false
440 + syn match ocamlKeyChar "!"
443 syn keyword ocamlType array bool char exn float format int
444 syn keyword ocamlType list option string unit
446 -syn keyword ocamlOperator asr lor lsl lsr lxor mod not or
447 +syn keyword ocamlOperator asr lor lsl lsr lxor mod not
449 -syn keyword ocamlBoolean true false
450 syn match ocamlConstructor "(\s*)"
451 syn match ocamlConstructor "\[\s*\]"
452 syn match ocamlConstructor "\[|\s*>|]"
454 syn match ocamlTopStop ";;"
455 syn match ocamlOperator "\^"
456 syn match ocamlOperator "::"
457 -syn match ocamlOperator "<-"
459 +syn match ocamlOperator "&&"
460 +syn match ocamlOperator "<"
461 +syn match ocamlOperator ">"
462 syn match ocamlAnyVar "\<_\>"
463 -syn match ocamlKeyChar "!"
464 syn match ocamlKeyChar "|[^\]]"me=e-1
465 syn match ocamlKeyChar ";"
466 syn match ocamlKeyChar "\~"
468 syn match ocamlKeyChar "\*"
469 syn match ocamlKeyChar "="
471 +if exists("ocaml_revised")
472 + syn match ocamlErr "<-"
474 + syn match ocamlOperator "<-"
477 syn match ocamlNumber "\<-\=\d\+\>"
478 syn match ocamlNumber "\<-\=0[x|X]\x\+\>"
479 syn match ocamlNumber "\<-\=0[o|O]\o\+\>"
482 syn sync maxlines=500
484 -syn sync match ocamlDoSync grouphere ocamlDo "\<do\>"
485 -syn sync match ocamlDoSync groupthere ocamlDo "\<done\>"
486 -syn sync match ocamlEndSync grouphere ocamlEnd "\<\(begin\|object\)\>"
487 +if !exists("ocaml_revised")
488 + syn sync match ocamlDoSync grouphere ocamlDo "\<do\>"
489 + syn sync match ocamlDoSync groupthere ocamlDo "\<done\>"
492 +if exists("ocaml_revised")
493 + syn sync match ocamlEndSync grouphere ocamlEnd "\<\(object\)\>"
495 + syn sync match ocamlEndSync grouphere ocamlEnd "\<\(begin\|object\)\>"
498 syn sync match ocamlEndSync groupthere ocamlEnd "\<end\>"
499 syn sync match ocamlStructSync grouphere ocamlStruct "\<struct\>"
500 syn sync match ocamlStructSync groupthere ocamlStruct "\<end\>"
503 HiLink ocamlCharErr Error
505 + HiLink ocamlErr Error
507 HiLink ocamlComment Comment
509 HiLink ocamlModPath Include