annotate runtime/indent/make.vim @ 32025:9085421fe397 v9.0.1344

patch 9.0.1344: check for OSC escape sequence doesn't work Commit: https://github.com/vim/vim/commit/a8f0835a6b5af5bf099dc9831bdc68edb8b69ba8 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Feb 23 13:54:01 2023 +0000 patch 9.0.1344: check for OSC escape sequence doesn't work Problem: Check for OSC escape sequence doesn't work. Solution: Fix typo in index.
author Bram Moolenaar <Bram@vim.org>
date Thu, 23 Feb 2023 15:00:04 +0100
parents 6dd88e45d47d
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: 24569
diff changeset
2 " Language: Makefile
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24569
diff changeset
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24569
diff changeset
4 " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
5 " Last Change: 2022 Apr 06
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
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 setlocal indentexpr=GetMakeIndent()
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
13 setlocal indentkeys=!^F,o,O,<:>,=else,=endif
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 839
diff changeset
14 setlocal nosmartindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
16 let b:undo_indent = "setl inde< indk< si<"
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 24569
diff changeset
17
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 if exists("*GetMakeIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
22 let s:comment_rx = '^\s*#'
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 375
diff changeset
23 let s:rule_rx = '^[^ \t#:][^#:]*:\{1,2}\%([^=:]\|$\)'
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
24 let s:continued_rule_rx = '^[^#:]*:\{1,2}\%([^=:]\|$\)'
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 375
diff changeset
25 let s:continuation_rx = '\\$'
24569
e3ec2ec8841a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11160
diff changeset
26 let s:assignment_rx = '^\s*\h\w*\s*[+:?]\==\s*\zs.*\\$'
e3ec2ec8841a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11160
diff changeset
27 let s:folded_assignment_rx = '^\s*\h\w*\s*[+:?]\=='
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
28 " TODO: This needs to be a lot more restrictive in what it matches.
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
29 let s:just_inserted_rule_rx = '^\s*[^#:]\+:\{1,2}$'
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
30 let s:conditional_directive_rx = '^ *\%(ifn\=\%(eq\|def\)\|else\)\>'
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
31 let s:end_conditional_directive_rx = '^\s*\%(else\|endif\)\>'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
33 function s:remove_continuation(line)
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
34 return substitute(a:line, s:continuation_rx, "", "")
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
35 endfunction
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
36
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 function GetMakeIndent()
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
38 " TODO: Should this perhaps be v:lnum -1?
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
39 " let prev_lnum = prevnonblank(v:lnum - 1)
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
40 let prev_lnum = v:lnum - 1
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
41 if prev_lnum == 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 endif
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
44 let prev_line = getline(prev_lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
46 let prev_prev_lnum = prev_lnum - 1
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
47 let prev_prev_line = prev_prev_lnum != 0 ? getline(prev_prev_lnum) : ""
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 375
diff changeset
48
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
49 " TODO: Deal with comments. In comments, continuations aren't interesting.
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
50 if prev_line =~ s:continuation_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
51 if prev_prev_line =~ s:continuation_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
52 return indent(prev_lnum)
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
53 elseif prev_line =~ s:rule_rx
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11062
diff changeset
54 return shiftwidth()
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
55 elseif prev_line =~ s:assignment_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
56 call cursor(prev_lnum, 1)
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
57 if search(s:assignment_rx, 'W') != 0
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
58 return virtcol('.') - 1
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
59 else
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
60 " TODO: ?
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11062
diff changeset
61 return shiftwidth()
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 839
diff changeset
62 endif
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
63 else
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
64 " TODO: OK, this might be a continued shell command, so perhaps indent
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
65 " properly here? Leave this out for now, but in the next release this
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
66 " should be using indent/sh.vim somehow.
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
67 "if prev_line =~ '^\t' " s:rule_command_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
68 " if prev_line =~ '^\s\+[@-]\%(if\)\>'
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
69 " return indent(prev_lnum) + 2
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
70 " endif
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
71 "endif
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11062
diff changeset
72 return indent(prev_lnum) + shiftwidth()
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 839
diff changeset
73 endif
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
74 elseif prev_prev_line =~ s:continuation_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
75 let folded_line = s:remove_continuation(prev_prev_line) . ' ' . s:remove_continuation(prev_line)
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
76 let lnum = prev_prev_lnum - 1
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
77 let line = getline(lnum)
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
78 while line =~ s:continuation_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
79 let folded_line = s:remove_continuation(line) . ' ' . folded_line
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 375
diff changeset
80 let lnum -= 1
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 375
diff changeset
81 let line = getline(lnum)
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 375
diff changeset
82 endwhile
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
83 let folded_lnum = lnum + 1
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
84 if folded_line =~ s:rule_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
85 if getline(v:lnum) =~ s:rule_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
86 return 0
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
87 else
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
88 return &ts
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
89 endif
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
90 else
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
91 " elseif folded_line =~ s:folded_assignment_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
92 if getline(v:lnum) =~ s:rule_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
93 return 0
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
94 else
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
95 return indent(folded_lnum)
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
96 endif
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
97 " else
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
98 " " TODO: ?
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
99 " return indent(prev_lnum)
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
100 endif
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
101 elseif prev_line =~ s:rule_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
102 if getline(v:lnum) =~ s:rule_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
103 return 0
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
104 else
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
105 return &ts
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
106 endif
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
107 elseif prev_line =~ s:conditional_directive_rx
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11062
diff changeset
108 return shiftwidth()
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 375
diff changeset
109 else
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
110 let line = getline(v:lnum)
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
111 if line =~ s:just_inserted_rule_rx
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
112 return 0
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
113 elseif line =~ s:end_conditional_directive_rx
11160
d0a20101ecb2 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11062
diff changeset
114 return v:lnum - 1 == 0 ? 0 : indent(v:lnum - 1) - shiftwidth()
1200
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
115 else
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
116 return v:lnum - 1 == 0 ? 0 : indent(v:lnum - 1)
f58cb9bf1260 updated for version 7.1b
vimboss
parents: 856
diff changeset
117 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 endfunction