annotate runtime/indent/matlab.vim @ 11629:1a6daa73590a v8.0.0697

patch 8.0.0697: recorded key sequences may become invalid commit https://github.com/vim/vim/commit/8858498516108432453526f07783f14c9196e112 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 7 13:32:14 2017 +0200 patch 8.0.0697: recorded key sequences may become invalid Problem: Recorded key sequences may become invalid. Solution: Add back KE_SNIFF removed in 7.4.1433. Use fixed numbers for the key_extra enum.
author Christian Brabandt <cb@256bit.org>
date Fri, 07 Jul 2017 13:45:03 +0200
parents 63b0b7b79b25
children 8b334e4cb97f
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 " Matlab indent file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: Matlab
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Christophe Poucet <christophe.poucet@pandora.be>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " Last Change: 6 January, 2001
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 " Some preliminary setting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 setlocal indentkeys=!,o,O=end,=case,=else,=elseif,=otherwise,=catch
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 setlocal indentexpr=GetMatlabIndent(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 if exists("*GetMatlabIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 function GetMatlabIndent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " Give up if this line is explicitly joined.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 if getline(a:lnum - 1) =~ '\\$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " Search backwards for the first non-empty line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let plnum = a:lnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 while plnum > 0 && getline(plnum) =~ '^\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 let plnum = plnum - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 if plnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 " This is the first non-empty line, use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let curind = indent(plnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 " If the current line is a stop-block statement...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 if getline(v:lnum) =~ '^\s*\(end\|else\|elseif\|case\|otherwise\|catch\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 " See if this line does not follow the line right after an openblock
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 if getline(plnum) =~ '^\s*\(for\|if\|else\|elseif\|case\|while\|switch\|try\|otherwise\|catch\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 " See if the user has already dedented
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
47 elseif indent(v:lnum) > curind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 " If not, recommend one dedent
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
49 let curind = curind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 " Otherwise, trust the user
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 " endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " If the previous line opened a block
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 elseif getline(plnum) =~ '^\s*\(for\|if\|else\|elseif\|case\|while\|switch\|try\|otherwise\|catch\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " See if the user has already indented
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
59 if indent(v:lnum) < curind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 "If not, recommend indent
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7
diff changeset
61 let curind = curind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " Otherwise, trust the user
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 " If we got to here, it means that the user takes the standardversion, so we return it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 return curind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 " vim:sw=2