annotate runtime/indent/ocaml.vim @ 19378:e548f5ed3645 v8.2.0247

patch 8.2.0247: misleading comment in NSIS installer script Commit: https://github.com/vim/vim/commit/3b0ef8cfdbb6cb5a9cb2dc093132b78d7a52c667 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 12 21:03:32 2020 +0100 patch 8.2.0247: misleading comment in NSIS installer script Problem: Misleading comment in NSIS installer script. Solution: Negate the meaning of the comment. (Ken Takata, closes https://github.com/vim/vim/issues/5627)
author Bram Moolenaar <Bram@vim.org>
date Wed, 12 Feb 2020 21:15:04 +0100
parents 63b0b7b79b25
children 15fa3923cc49
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim indent file
20
4ac1dce8dd5e updated for version 7.0012
vimboss
parents: 7
diff changeset
2 " Language: OCaml
3312
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
3 " Maintainers: Jean-Francois Yuen <jfyuen@happycoders.org>
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
4 " Mike Leary <leary@nwlink.com>
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
5 " Markus Mottl <markus.mottl@gmail.com>
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
6 " URL: http://www.ocaml.info/vim/indent/ocaml.vim
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5055
diff changeset
7 " Last Change: 2017 Jun 13
3312
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
8 " 2005 Jun 25 - Fixed multiple bugs due to 'else\nreturn ind' working
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
9 " 2005 May 09 - Added an option to not indent OCaml-indents specially (MM)
5055
c458ff35497e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3312
diff changeset
10 " 2013 June - commented textwidth (Marc Weber)
c458ff35497e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3312
diff changeset
11 "
c458ff35497e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3312
diff changeset
12 " Marc Weber's comment: This file may contain a lot of (very custom) stuff
c458ff35497e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3312
diff changeset
13 " which eventually should be moved somewhere else ..
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 if exists("b:did_indent")
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
17 finish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 setlocal expandtab
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 setlocal indentexpr=GetOCamlIndent()
20
4ac1dce8dd5e updated for version 7.0012
vimboss
parents: 7
diff changeset
23 setlocal indentkeys+=0=and,0=class,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)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 setlocal nolisp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 setlocal nosmartindent
5055
c458ff35497e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3312
diff changeset
26
c458ff35497e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3312
diff changeset
27 " At least Marc Weber and Markus Mottl do not like this:
c458ff35497e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3312
diff changeset
28 " setlocal textwidth=80
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 " Comment formatting
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
31 if !exists("no_ocaml_comments")
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
32 if (has("comments"))
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
33 setlocal comments=sr:(*,mb:*,ex:*)
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
34 setlocal fo=cqort
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
35 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 if exists("*GetOCamlIndent")
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
40 finish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 " Define some patterns:
20
4ac1dce8dd5e updated for version 7.0012
vimboss
parents: 7
diff changeset
44 let s:beflet = '^\s*\(initializer\|method\|try\)\|\(\<\(begin\|do\|else\|in\|then\|try\)\|->\|<-\|=\|;\|(\)\s*$'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 let s:letpat = '^\s*\(let\|type\|module\|class\|open\|exception\|val\|include\|external\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 let s:letlim = '\(\<\(sig\|struct\)\|;;\)\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 let s:lim = '^\s*\(exception\|external\|include\|let\|module\|open\|type\|val\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 let s:module = '\<\%(begin\|sig\|struct\|object\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 let s:obj = '^\s*\(constraint\|inherit\|initializer\|method\|val\)\>\|\<\(object\|object\s*(.*)\)\s*$'
20
4ac1dce8dd5e updated for version 7.0012
vimboss
parents: 7
diff changeset
50 let s:type = '^\s*\%(class\|let\|type\)\>.*='
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 " Skipping pattern, for comments
3312
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
53 function! s:GetLineWithoutFullComment(lnum)
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
54 let lnum = prevnonblank(a:lnum - 1)
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
55 let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
56 while lline =~ '^\s*$' && lnum > 0
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
57 let lnum = prevnonblank(lnum - 1)
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
58 let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
59 endwhile
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
60 return lnum
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " Indent for ';;' to match multiple 'let'
3312
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
64 function! s:GetInd(lnum, pat, lim)
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
65 let llet = search(a:pat, 'bW')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
66 let old = indent(a:lnum)
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
67 while llet > 0
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
68 let old = indent(llet)
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
69 let nb = s:GetLineWithoutFullComment(llet)
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
70 if getline(nb) =~ a:lim
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
71 return old
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
72 endif
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
73 let llet = search(a:pat, 'bW')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
74 endwhile
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
75 return old
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 " Indent pairs
3312
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
79 function! s:FindPair(pstart, pmid, pend)
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
80 call search(a:pend, 'bW')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
81 return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"'))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 " Indent 'let'
3312
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
85 function! s:FindLet(pstart, pmid, pend)
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
86 call search(a:pend, 'bW')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
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:beflet'))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3312
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
90 function! GetOCamlIndent()
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
91 " Find a non-commented line above the current line.
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
92 let lnum = s:GetLineWithoutFullComment(v:lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
94 " At the start of the file use zero indent.
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
95 if lnum == 0
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
96 return 0
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
97 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
99 let ind = indent(lnum)
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
100 let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
102 " Return double 'shiftwidth' after lines matching:
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
103 if lline =~ '^\s*|.*->\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5055
diff changeset
104 return ind + 2 * shiftwidth()
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
105 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
107 let line = getline(v:lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
109 " Indent if current line begins with 'end':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
110 if line =~ '^\s*end\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
111 return s:FindPair(s:module, '','\<end\>')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
113 " Indent if current line begins with 'done' for 'do':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
114 elseif line =~ '^\s*done\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
115 return s:FindPair('\<do\>', '','\<done\>')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
117 " Indent if current line begins with '}' or '>}':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
118 elseif line =~ '^\s*\(\|>\)}'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
119 return s:FindPair('{', '','}')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
121 " Indent if current line begins with ']', '|]' or '>]':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
122 elseif line =~ '^\s*\(\||\|>\)\]'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
123 return s:FindPair('\[', '','\]')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
125 " Indent if current line begins with ')':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
126 elseif line =~ '^\s*)'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
127 return s:FindPair('(', '',')')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
129 " Indent if current line begins with 'let':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
130 elseif line =~ '^\s*let\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
131 if lline !~ s:lim . '\|' . s:letlim . '\|' . s:beflet
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
132 return s:FindLet(s:type, '','\<let\s*$')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
133 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
135 " Indent if current line begins with 'class' or 'type':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
136 elseif line =~ '^\s*\(class\|type\)\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
137 if lline !~ s:lim . '\|\<and\s*$\|' . s:letlim
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
138 return s:FindLet(s:type, '','\<\(class\|type\)\s*$')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
139 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
141 " Indent for pattern matching:
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
142 elseif line =~ '^\s*|'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
143 if lline !~ '^\s*\(|[^\]]\|\(match\|type\|with\)\>\)\|\<\(function\|parser\|private\|with\)\s*$'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
144 call search('|', 'bW')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
145 return indent(searchpair('^\s*\(match\|type\)\>\|\<\(function\|parser\|private\|with\)\s*$', '', '^\s*|', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") !~ "^\\s*|.*->"'))
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
146 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
148 " Indent if current line begins with ';;':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
149 elseif line =~ '^\s*;;'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
150 if lline !~ ';;\s*$'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
151 return s:GetInd(v:lnum, s:letpat, s:letlim)
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
152 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
154 " Indent if current line begins with 'in':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
155 elseif line =~ '^\s*in\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
156 if lline !~ '^\s*\(let\|and\)\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
157 return s:FindPair('\<let\>', '', '\<in\>')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
158 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
160 " Indent if current line begins with 'else':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
161 elseif line =~ '^\s*else\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
162 if lline !~ '^\s*\(if\|then\)\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
163 return s:FindPair('\<if\>', '', '\<else\>')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
164 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
166 " Indent if current line begins with 'then':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
167 elseif line =~ '^\s*then\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
168 if lline !~ '^\s*\(if\|else\)\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
169 return s:FindPair('\<if\>', '', '\<then\>')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
170 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
172 " Indent if current line begins with 'and':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
173 elseif line =~ '^\s*and\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
174 if lline !~ '^\s*\(and\|let\|type\)\>\|\<end\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5055
diff changeset
175 return ind - shiftwidth()
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
176 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
178 " Indent if current line begins with 'with':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
179 elseif line =~ '^\s*with\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
180 if lline !~ '^\s*\(match\|try\)\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
181 return s:FindPair('\<\%(match\|try\)\>', '','\<with\>')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
182 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
184 " Indent if current line begins with 'exception', 'external', 'include' or
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
185 " 'open':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
186 elseif line =~ '^\s*\(exception\|external\|include\|open\)\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
187 if lline !~ s:lim . '\|' . s:letlim
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
188 call search(line)
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
189 return indent(search('^\s*\(\(exception\|external\|include\|open\|type\)\>\|val\>.*:\)', 'bW'))
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
190 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
192 " Indent if current line begins with 'val':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
193 elseif line =~ '^\s*val\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
194 if lline !~ '^\s*\(exception\|external\|include\|open\)\>\|' . s:obj . '\|' . s:letlim
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
195 return indent(search('^\s*\(\(exception\|include\|initializer\|method\|open\|type\|val\)\>\|external\>.*:\)', 'bW'))
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
196 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
198 " Indent if current line begins with 'constraint', 'inherit', 'initializer'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
199 " or 'method':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
200 elseif line =~ '^\s*\(constraint\|inherit\|initializer\|method\)\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
201 if lline !~ s:obj
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5055
diff changeset
202 return indent(search('\<\(object\|object\s*(.*)\)\s*$', 'bW')) + shiftwidth()
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
203 endif
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
204
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
205 endif
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
206
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
207 " Add a 'shiftwidth' after lines ending with:
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
208 if lline =~ '\(:\|=\|->\|<-\|(\|\[\|{\|{<\|\[|\|\[<\|\<\(begin\|do\|else\|fun\|function\|functor\|if\|initializer\|object\|parser\|private\|sig\|struct\|then\|try\)\|\<object\s*(.*)\)\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5055
diff changeset
209 let ind = ind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
211 " Back to normal indent after lines ending with ';;':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
212 elseif lline =~ ';;\s*$' && lline !~ '^\s*;;'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
213 let ind = s:GetInd(v:lnum, s:letpat, s:letlim)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
215 " Back to normal indent after lines ending with 'end':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
216 elseif lline =~ '\<end\s*$'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
217 let ind = s:FindPair(s:module, '','\<end\>')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
219 " Back to normal indent after lines ending with 'in':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
220 elseif lline =~ '\<in\s*$' && lline !~ '^\s*in\>'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
221 let ind = s:FindPair('\<let\>', '', '\<in\>')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
223 " Back to normal indent after lines ending with 'done':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
224 elseif lline =~ '\<done\s*$'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
225 let ind = s:FindPair('\<do\>', '','\<done\>')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
227 " Back to normal indent after lines ending with '}' or '>}':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
228 elseif lline =~ '\(\|>\)}\s*$'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
229 let ind = s:FindPair('{', '','}')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
231 " Back to normal indent after lines ending with ']', '|]' or '>]':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
232 elseif lline =~ '\(\||\|>\)\]\s*$'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
233 let ind = s:FindPair('\[', '','\]')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
235 " Back to normal indent after comments:
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
236 elseif lline =~ '\*)\s*$'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
237 call search('\*)', 'bW')
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
238 let ind = indent(searchpair('(\*', '', '\*)', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"'))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
240 " Back to normal indent after lines ending with ')':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
241 elseif lline =~ ')\s*$'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
242 let ind = s:FindPair('(', '',')')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
244 " If this is a multiline comment then align '*':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
245 elseif lline =~ '^\s*(\*' && line =~ '^\s*\*'
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
246 let ind = ind + 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247
3312
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
248 else
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
249 " Don't change indentation of this line
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
250 " for new lines (indent==0) use indentation of previous line
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
251
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
252 " This is for preventing removing indentation of these args:
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
253 " let f x =
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
254 " let y = x + 1 in
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
255 " Printf.printf
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
256 " "o" << here
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
257 " "oeuth" << don't touch indentation
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
258
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
259 let i = indent(v:lnum)
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
260 return i == 0 ? ind : i
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 1121
diff changeset
261
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
262 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
264 " Subtract a 'shiftwidth' after lines matching 'match ... with parser':
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
265 if lline =~ '\<match\>.*\<with\>\s*\<parser\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5055
diff changeset
266 let ind = ind - shiftwidth()
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
267 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268
551
7dfd6f1443a7 updated for version 7.0156
vimboss
parents: 20
diff changeset
269 return ind
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 " vim:sw=2