annotate runtime/indent/sml.vim @ 34159:58a6e51b437b v9.1.0040

patch 9.1.0040: issue with prompt buffer and hidden buffer Commit: https://github.com/vim/vim/commit/f267847017976ab85117bdf75b45e769836f8d69 Author: zeertzjq <zeertzjq@outlook.com> Date: Wed Jan 17 21:22:59 2024 +0100 patch 9.1.0040: issue with prompt buffer and hidden buffer Problem: Modifying a hidden buffer still interferes with prompt buffer mode changes. Solution: Save and restore b_prompt_insert. (zeertzjq) closes: #13875 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org> Modifying hidden buffer still interferes with prompt buffer mode changes
author Christian Brabandt <cb@256bit.org>
date Wed, 17 Jan 2024 21:30:03 +0100
parents 6dd88e45d47d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
1 " Vim indent file
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
2 " Language: SML
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
3 " Maintainer: Saikat Guha <sg266@cornell.edu>
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
4 " Hubert Chao <hc85@cornell.edu>
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
5 " Original OCaml Version:
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
6 " Jean-Francois Yuen <jfyuen@ifrance.com>
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
7 " Mike Leary <leary@nwlink.com>
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
8 " Markus Mottl <markus@oefai.at>
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
9 " OCaml URL: http://www.oefai.at/~markus/vim/indent/ocaml.vim
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
10 " Last Change: 2022 Apr 06
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
11 " 2002 Nov 06 - Some fixes (JY)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
12 " 2002 Oct 28 - Fixed bug with indentation of ']' (MM)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
13 " 2002 Oct 22 - Major rewrite (JY)
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
14 " 2022 April: b:undo_indent added by Doug Kearns
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
15
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
16 " Only load this indent file when no other was loaded.
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
17 if exists("b:did_indent")
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
18 finish
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
19 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
20 let b:did_indent = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
21
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
22 setlocal expandtab
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
23 setlocal indentexpr=GetSMLIndent()
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
24 setlocal indentkeys+=0=and,0=else,0=end,0=handle,0=if,0=in,0=let,0=then,0=val,0=fun,0=\|,0=*),0)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
25 setlocal nolisp
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
26 setlocal nosmartindent
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
27 setlocal textwidth=80
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
28 setlocal shiftwidth=2
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
29
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
30 let b:undo_indent = "setl et< inde< indk< lisp< si< sw< tw<"
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
31
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
32 " Comment formatting
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
33 if (has("comments"))
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
34 set comments=sr:(*,mb:*,ex:*)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
35 set fo=cqort
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
36 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
37
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
38 " Only define the function once.
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
39 "if exists("*GetSMLIndent")
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
40 "finish
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
41 "endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
42
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
43 " Define some patterns:
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
44 let s:beflet = '^\s*\(initializer\|method\|try\)\|\(\<\(begin\|do\|else\|in\|then\|try\)\|->\|;\)\s*$'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
45 let s:letpat = '^\s*\(let\|type\|module\|class\|open\|exception\|val\|include\|external\)\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
46 let s:letlim = '\(\<\(sig\|struct\)\|;;\)\s*$'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
47 let s:lim = '^\s*\(exception\|external\|include\|let\|module\|open\|type\|val\)\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
48 let s:module = '\<\%(let\|sig\|struct\)\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
49 let s:obj = '^\s*\(constraint\|inherit\|initializer\|method\|val\)\>\|\<\(object\|object\s*(.*)\)\s*$'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
50 let s:type = '^\s*\%(let\|type\)\>.*='
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
51 let s:val = '^\s*\(val\|external\)\>.*:'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
52
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
53 " Skipping pattern, for comments
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
54 function! s:SkipPattern(lnum, pat)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
55 let def = prevnonblank(a:lnum - 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
56 while def > 0 && getline(def) =~ a:pat
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
57 let def = prevnonblank(def - 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
58 endwhile
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
59 return def
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
60 endfunction
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
61
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
62 " Indent for ';;' to match multiple 'let'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
63 function! s:GetInd(lnum, pat, lim)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
64 let llet = search(a:pat, 'bW')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
65 let old = indent(a:lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
66 while llet > 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
67 let old = indent(llet)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
68 let nb = s:SkipPattern(llet, '^\s*(\*.*\*)\s*$')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
69 if getline(nb) =~ a:lim
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
70 return old
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
71 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
72 let llet = search(a:pat, 'bW')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
73 endwhile
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
74 return old
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
75 endfunction
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
76
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
77 " Indent pairs
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
78 function! s:FindPair(pstart, pmid, pend)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
79 call search(a:pend, 'bW')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
80 " return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"'))
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
81 let lno = searchpair(a:pstart, a:pmid, a:pend, 'bW', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
82 if lno == -1
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
83 return indent(lno)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
84 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
85 return col(".") - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
86 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
87 endfunction
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
88
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
89 function! s:FindLet(pstart, pmid, pend)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
90 call search(a:pend, 'bW')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
91 " return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"'))
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
92 let lno = searchpair(a:pstart, a:pmid, a:pend, 'bW', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
93 let moduleLine = getline(lno)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
94 if lno == -1 || moduleLine =~ '^\s*\(fun\|structure\|signature\)\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
95 return indent(lno)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
96 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
97 return col(".") - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
98 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
99 endfunction
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
100
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
101 " Indent 'let'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
102 "function! s:FindLet(pstart, pmid, pend)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
103 " call search(a:pend, 'bW')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
104 " 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'))
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
105 "endfunction
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
106
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
107 function! GetSMLIndent()
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
108 " Find a non-blank line above the current line.
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
109 let lnum = prevnonblank(v:lnum - 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
110
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
111 " At the start of the file use zero indent.
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
112 if lnum == 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
113 return 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
114 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
115
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
116 let ind = indent(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
117 let lline = getline(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
118
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
119 " Return double 'shiftwidth' after lines matching:
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
120 if lline =~ '^\s*|.*=>\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 839
diff changeset
121 return ind + 2 *shiftwidth()
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
122 elseif lline =~ '^\s*val\>.*=\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 839
diff changeset
123 return ind + shiftwidth()
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
124 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
125
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
126 let line = getline(v:lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
127
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
128 " Indent lines starting with 'end' to matching module
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
129 if line =~ '^\s*end\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
130 return s:FindLet(s:module, '', '\<end\>')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
131
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
132 " Match 'else' with 'if'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
133 elseif line =~ '^\s*else\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
134 if lline !~ '^\s*\(if\|else\|then\)\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
135 return s:FindPair('\<if\>', '', '\<then\>')
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 532
diff changeset
136 else
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 532
diff changeset
137 return ind
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
138 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
139
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
140 " Match 'then' with 'if'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
141 elseif line =~ '^\s*then\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
142 if lline !~ '^\s*\(if\|else\|then\)\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
143 return s:FindPair('\<if\>', '', '\<then\>')
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 532
diff changeset
144 else
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 532
diff changeset
145 return ind
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
146 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
147
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
148 " Indent if current line begins with ']'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
149 elseif line =~ '^\s*\]'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
150 return s:FindPair('\[','','\]')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
151
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
152 " Indent current line starting with 'in' to last matching 'let'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
153 elseif line =~ '^\s*in\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
154 let ind = s:FindLet('\<let\>','','\<in\>')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
155
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
156 " Indent from last matching module if line matches:
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
157 elseif line =~ '^\s*\(fun\|val\|open\|structure\|and\|datatype\|type\|exception\)\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
158 cursor(lnum,1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
159 let lastModule = indent(searchpair(s:module, '', '\<end\>', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"'))
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
160 if lastModule == -1
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
161 return 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
162 else
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 839
diff changeset
163 return lastModule + shiftwidth()
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
164 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
165
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
166 " Indent lines starting with '|' from matching 'case', 'handle'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
167 elseif line =~ '^\s*|'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
168 " cursor(lnum,1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
169 let lastSwitch = search('\<\(case\|handle\|fun\|datatype\)\>','bW')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
170 let switchLine = getline(lastSwitch)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
171 let switchLineIndent = indent(lastSwitch)
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
172 if lline =~ '^\s*|'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
173 return ind
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
174 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
175 if switchLine =~ '\<case\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
176 return col(".") + 2
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
177 elseif switchLine =~ '\<handle\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 839
diff changeset
178 return switchLineIndent + shiftwidth()
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
179 elseif switchLine =~ '\<datatype\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
180 call search('=')
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
181 return col(".") - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
182 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
183 return switchLineIndent + 2
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
184 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
185
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
186
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
187 " Indent if last line ends with 'sig', 'struct', 'let', 'then', 'else',
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
188 " 'in'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
189 elseif lline =~ '\<\(sig\|struct\|let\|in\|then\|else\)\s*$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 839
diff changeset
190 let ind = ind + shiftwidth()
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
191
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
192 " Indent if last line ends with 'of', align from 'case'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
193 elseif lline =~ '\<\(of\)\s*$'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
194 call search('\<case\>',"bW")
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
195 let ind = col(".")+4
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
196
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
197 " Indent if current line starts with 'of'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
198 elseif line =~ '^\s*of\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
199 call search('\<case\>',"bW")
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
200 let ind = col(".")+1
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
201
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
202
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
203 " Indent if last line starts with 'fun', 'case', 'fn'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
204 elseif lline =~ '^\s*\(fun\|fn\|case\)\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 839
diff changeset
205 let ind = ind + shiftwidth()
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
206
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
207 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
208
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
209 " Don't indent 'let' if last line started with 'fun', 'fn'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
210 if line =~ '^\s*let\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
211 if lline =~ '^\s*\(fun\|fn\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 839
diff changeset
212 let ind = ind - shiftwidth()
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
213 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
214 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
215
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
216 return ind
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
217
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
218 endfunction
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
219
7052f11a3dc9 updated for version 7.0150
vimboss
parents:
diff changeset
220 " vim:sw=2