annotate runtime/indent/config.vim @ 13525:7d0a8ca17f30 v8.0.1636

patch 8.0.1636: no test for term_dumpload() and term_dumpdiff() commit https://github.com/vim/vim/commit/45d2a64f964238753403017b6d0ef30be88ccf37 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 24 14:30:32 2018 +0100 patch 8.0.1636: no test for term_dumpload() and term_dumpdiff() Problem: No test for term_dumpload() and term_dumpdiff(). Solution: Add tests.
author Christian Brabandt <cb@256bit.org>
date Sat, 24 Mar 2018 14:45:06 +0100
parents 1218c5353e2b
children 11b656e74444
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
11062
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 1224
diff changeset
2 " Language: Autoconf configure.{ac,in} file
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 1224
diff changeset
3 " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 1224
diff changeset
4 " Latest Revision: 2006-12-20
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 1224
diff changeset
5 " TODO: how about nested [()]'s in one line
1224
edc1c9d6dab9 updated for version 7.1b
vimboss
parents: 856
diff changeset
6 " what's wrong with '\\\@!'?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
1224
edc1c9d6dab9 updated for version 7.1b
vimboss
parents: 856
diff changeset
13 runtime! indent/sh.vim " will set b:did_indent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 setlocal indentexpr=GetConfigIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 setlocal indentkeys=!^F,o,O,=then,=do,=else,=elif,=esac,=fi,=fin,=fil,=done
1224
edc1c9d6dab9 updated for version 7.1b
vimboss
parents: 856
diff changeset
17 setlocal nosmartindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 if exists("*GetConfigIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " get the offset (indent) of the end of the match of 'regexp' in 'line'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 function s:GetOffsetOf(line, regexp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let end = matchend(a:line, a:regexp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 let width = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 let i = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 while i < end
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 if a:line[i] != "\t"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 let width = width + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 let width = width + &ts - (width % &ts)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 let i = i + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 return width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 function GetConfigIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 " Hit the start of the file, use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 " where to put this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 let ind = GetShIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 let line = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 " if previous line has unmatched, unescaped opening parentheses,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 " indent to its position. TODO: not failsafe if multiple ('s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 if line =~ '\\\@<!([^)]*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 let ind = s:GetOffsetOf(line, '\\\@!(')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 " if previous line has unmatched opening bracket,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 " indent to its position. TODO: same as above
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 if line =~ '\[[^]]*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 let ind = s:GetOffsetOf(line, '\[')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 " if previous line had an unmatched closing parantheses,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 " indent to the matching opening parantheses
809
4f1b94b51e99 updated for version 7.0b02
vimboss
parents: 389
diff changeset
67 if line =~ '[^(]\+\\\@<!)$'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 call search(')', 'bW')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 let lnum = searchpair('\\\@<!(', '', ')', 'bWn')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 " if previous line had an unmatched closing bracket,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 " indent to the matching opening bracket
809
4f1b94b51e99 updated for version 7.0b02
vimboss
parents: 389
diff changeset
75 if line =~ '[^[]\+]$'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 call search(']', 'bW')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 let lnum = searchpair('\[', '', ']', 'bWn')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 endfunction