annotate runtime/indent/config.vim @ 5680:4d12112c5efa v7.4.186

updated for version 7.4.186 Problem: Insert in Visual mode sometimes gives incorrect results. (Dominique Pelle) Solution: Remember the original insert start position. (Christian Brabandt, Dominique Pelle)
author Bram Moolenaar <bram@vim.org>
date Sat, 22 Feb 2014 23:03:55 +0100
parents edc1c9d6dab9
children 1218c5353e2b
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
1224
edc1c9d6dab9 updated for version 7.1b
vimboss
parents: 856
diff changeset
2 " Language: Autoconf configure.{ac,in} file
edc1c9d6dab9 updated for version 7.1b
vimboss
parents: 856
diff changeset
3 " Maintainer: Nikolai Weibull <now@bitwi.se>
edc1c9d6dab9 updated for version 7.1b
vimboss
parents: 856
diff changeset
4 " Latest Revision: 2006-12-20
edc1c9d6dab9 updated for version 7.1b
vimboss
parents: 856
diff changeset
5 " TODO: how about nested [()]'s in one line
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