annotate runtime/indent/config.vim @ 30055:0acf2a20c357 v9.0.0365

patch 9.0.0365: file name used in test is unusual Commit: https://github.com/vim/vim/commit/91a874eb88eff2df9b8fdd64ccf98eed337823cf Author: Dominique Pelle <dominique.pelle@gmail.com> Date: Sat Sep 3 10:59:32 2022 +0100 patch 9.0.0365: file name used in test is unusual Problem: File name used in test is unusual. Solution: Rename it. (Dominique Pell?, closes https://github.com/vim/vim/issues/11044)
author Bram Moolenaar <Bram@vim.org>
date Sat, 03 Sep 2022 12:00:06 +0200
parents 9c221ad9634a
children
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
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
2 " Language: Autoconf configure.{ac,in} file
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
4 " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
5 " Last Change: 24 Sep 2021
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
6
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
7 " TODO: how about nested [()]'s in one line what's wrong with '\\\@!'?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
1224
edc1c9d6dab9 updated for version 7.1b
vimboss
parents: 856
diff changeset
14 runtime! indent/sh.vim " will set b:did_indent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 setlocal indentexpr=GetConfigIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 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
18 setlocal nosmartindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
20 let b:undo_indent = "setl inde< indk< si<"
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
21
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 if exists("*GetConfigIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 " get the offset (indent) of the end of the match of 'regexp' in 'line'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 function s:GetOffsetOf(line, regexp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 let end = matchend(a:line, a:regexp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let width = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 let i = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 while i < end
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 if a:line[i] != "\t"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let width = width + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 let width = width + &ts - (width % &ts)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let i = i + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 return width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 function GetConfigIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 " Hit the start of the file, use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 " where to put this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 let ind = GetShIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 let line = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " if previous line has unmatched, unescaped opening parentheses,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 " indent to its position. TODO: not failsafe if multiple ('s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 if line =~ '\\\@<!([^)]*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 let ind = s:GetOffsetOf(line, '\\\@!(')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 " if previous line has unmatched opening bracket,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " indent to its position. TODO: same as above
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 if line =~ '\[[^]]*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 let ind = s:GetOffsetOf(line, '\[')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
25773
11b656e74444 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
68 " if previous line had an unmatched closing parentheses,
11b656e74444 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
69 " indent to the matching opening parentheses
809
4f1b94b51e99 updated for version 7.0b02
vimboss
parents: 389
diff changeset
70 if line =~ '[^(]\+\\\@<!)$'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 call search(')', 'bW')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 let lnum = searchpair('\\\@<!(', '', ')', 'bWn')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " if previous line had an unmatched closing bracket,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 " indent to the matching opening bracket
809
4f1b94b51e99 updated for version 7.0b02
vimboss
parents: 389
diff changeset
78 if line =~ '[^[]\+]$'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 call search(']', 'bW')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 let lnum = searchpair('\[', '', ']', 'bWn')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 endfunction