Mercurial > vim
comparison runtime/indent/ocaml.vim @ 3312:b7811ab264bf v7.3.423
updated for version 7.3.423
Problem: Small mistakes in comments, proto and indent.
Solution: Fix the mistakes.
Also update runtime files
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 04 Feb 2012 21:59:01 +0100 |
parents | e63691e7c504 |
children | c458ff35497e |
comparison
equal
deleted
inserted
replaced
3311:54d1536a1c8b | 3312:b7811ab264bf |
---|---|
1 " Vim indent file | 1 " Vim indent file |
2 " Language: OCaml | 2 " Language: OCaml |
3 " Maintainers: Jean-Francois Yuen <jfyuen@happycoders.org> | 3 " Maintainers: Jean-Francois Yuen <jfyuen@happycoders.org> |
4 " Mike Leary <leary@nwlink.com> | 4 " Mike Leary <leary@nwlink.com> |
5 " Markus Mottl <markus.mottl@gmail.com> | 5 " Markus Mottl <markus.mottl@gmail.com> |
6 " URL: http://www.ocaml.info/vim/indent/ocaml.vim | 6 " URL: http://www.ocaml.info/vim/indent/ocaml.vim |
7 " Last Change: 2005 Jun 25 - Fixed multiple bugs due to 'else\nreturn ind' working | 7 " Last Change: 2010 Sep 04 - Added an indentation improvement by Mark Weber |
8 " 2005 May 09 - Added an option to not indent OCaml-indents specially (MM) | 8 " 2005 Jun 25 - Fixed multiple bugs due to 'else\nreturn ind' working |
9 " 2005 Apr 11 - Fixed an indentation bug concerning "let" (MM) | 9 " 2005 May 09 - Added an option to not indent OCaml-indents specially (MM) |
10 | 10 |
11 " Only load this indent file when no other was loaded. | 11 " Only load this indent file when no other was loaded. |
12 if exists("b:did_indent") | 12 if exists("b:did_indent") |
13 finish | 13 finish |
14 endif | 14 endif |
42 let s:module = '\<\%(begin\|sig\|struct\|object\)\>' | 42 let s:module = '\<\%(begin\|sig\|struct\|object\)\>' |
43 let s:obj = '^\s*\(constraint\|inherit\|initializer\|method\|val\)\>\|\<\(object\|object\s*(.*)\)\s*$' | 43 let s:obj = '^\s*\(constraint\|inherit\|initializer\|method\|val\)\>\|\<\(object\|object\s*(.*)\)\s*$' |
44 let s:type = '^\s*\%(class\|let\|type\)\>.*=' | 44 let s:type = '^\s*\%(class\|let\|type\)\>.*=' |
45 | 45 |
46 " Skipping pattern, for comments | 46 " Skipping pattern, for comments |
47 function s:GetLineWithoutFullComment(lnum) | 47 function! s:GetLineWithoutFullComment(lnum) |
48 let lnum = prevnonblank(a:lnum - 1) | 48 let lnum = prevnonblank(a:lnum - 1) |
49 let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '') | 49 let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '') |
50 while lline =~ '^\s*$' && lnum > 0 | 50 while lline =~ '^\s*$' && lnum > 0 |
51 let lnum = prevnonblank(lnum - 1) | 51 let lnum = prevnonblank(lnum - 1) |
52 let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '') | 52 let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '') |
53 endwhile | 53 endwhile |
54 return lnum | 54 return lnum |
55 endfunction | 55 endfunction |
56 | 56 |
57 " Indent for ';;' to match multiple 'let' | 57 " Indent for ';;' to match multiple 'let' |
58 function s:GetInd(lnum, pat, lim) | 58 function! s:GetInd(lnum, pat, lim) |
59 let llet = search(a:pat, 'bW') | 59 let llet = search(a:pat, 'bW') |
60 let old = indent(a:lnum) | 60 let old = indent(a:lnum) |
61 while llet > 0 | 61 while llet > 0 |
62 let old = indent(llet) | 62 let old = indent(llet) |
63 let nb = s:GetLineWithoutFullComment(llet) | 63 let nb = s:GetLineWithoutFullComment(llet) |
68 endwhile | 68 endwhile |
69 return old | 69 return old |
70 endfunction | 70 endfunction |
71 | 71 |
72 " Indent pairs | 72 " Indent pairs |
73 function s:FindPair(pstart, pmid, pend) | 73 function! s:FindPair(pstart, pmid, pend) |
74 call search(a:pend, 'bW') | 74 call search(a:pend, 'bW') |
75 return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"')) | 75 return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"')) |
76 endfunction | 76 endfunction |
77 | 77 |
78 " Indent 'let' | 78 " Indent 'let' |
79 function s:FindLet(pstart, pmid, pend) | 79 function! s:FindLet(pstart, pmid, pend) |
80 call search(a:pend, 'bW') | 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" || getline(".") =~ "^\\s*let\\>.*=.*\\<in\\s*$" || getline(prevnonblank(".") - 1) =~ s:beflet')) | 81 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:beflet')) |
82 endfunction | 82 endfunction |
83 | 83 |
84 function GetOCamlIndent() | 84 function! GetOCamlIndent() |
85 " Find a non-commented line above the current line. | 85 " Find a non-commented line above the current line. |
86 let lnum = s:GetLineWithoutFullComment(v:lnum) | 86 let lnum = s:GetLineWithoutFullComment(v:lnum) |
87 | 87 |
88 " At the start of the file use zero indent. | 88 " At the start of the file use zero indent. |
89 if lnum == 0 | 89 if lnum == 0 |
237 | 237 |
238 " If this is a multiline comment then align '*': | 238 " If this is a multiline comment then align '*': |
239 elseif lline =~ '^\s*(\*' && line =~ '^\s*\*' | 239 elseif lline =~ '^\s*(\*' && line =~ '^\s*\*' |
240 let ind = ind + 1 | 240 let ind = ind + 1 |
241 | 241 |
242 else | |
243 " Don't change indentation of this line | |
244 " for new lines (indent==0) use indentation of previous line | |
245 | |
246 " This is for preventing removing indentation of these args: | |
247 " let f x = | |
248 " let y = x + 1 in | |
249 " Printf.printf | |
250 " "o" << here | |
251 " "oeuth" << don't touch indentation | |
252 | |
253 let i = indent(v:lnum) | |
254 return i == 0 ? ind : i | |
255 | |
242 endif | 256 endif |
243 | 257 |
244 " Subtract a 'shiftwidth' after lines matching 'match ... with parser': | 258 " Subtract a 'shiftwidth' after lines matching 'match ... with parser': |
245 if lline =~ '\<match\>.*\<with\>\s*\<parser\s*$' | 259 if lline =~ '\<match\>.*\<with\>\s*\<parser\s*$' |
246 let ind = ind - &sw | 260 let ind = ind - &sw |