Skip to content

Commit d1e7357

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents aeafa39 + f678273 commit d1e7357

88 files changed

Lines changed: 2184 additions & 908 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS_vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,15 @@ runtime/ftplugin/css.vim @dkearns
109109
runtime/ftplugin/cucumber.vim @tpope
110110
runtime/ftplugin/dosbatch.vim @mrdubya
111111
runtime/ftplugin/eiffel.vim @dkearns
112+
runtime/ftplugin/expect.vim @dkearns
112113
runtime/ftplugin/erlang.vim @hcs42
113114
runtime/ftplugin/eruby.vim @tpope @dkearns
115+
runtime/ftplugin/fennel.vim @gpanders
114116
runtime/ftplugin/fetchmail.vim @dkearns
115117
runtime/ftplugin/fpcmake.vim @dkearns
116118
runtime/ftplugin/freebasic.vim @dkearns
117119
runtime/ftplugin/fstab.vim @rid9
120+
runtime/ftplugin/gdb.vim @xeyownt
118121
runtime/ftplugin/git.vim @tpope
119122
runtime/ftplugin/gitcommit.vim @tpope
120123
runtime/ftplugin/gitconfig.vim @tpope
@@ -124,6 +127,7 @@ runtime/ftplugin/go.vim @dbarnett
124127
runtime/ftplugin/gprof.vim @dpelle
125128
runtime/ftplugin/haml.vim @tpope
126129
runtime/ftplugin/hgcommit.vim @k-takata
130+
runtime/ftplugin/html.vim @dkearns
127131
runtime/ftplugin/i3config.vim @hiqua
128132
runtime/ftplugin/icon.vim @dkearns
129133
runtime/ftplugin/indent.vim @dkearns
@@ -297,8 +301,10 @@ runtime/syntax/eiffel.vim @jocelyn
297301
runtime/syntax/elmfilt.vim @cecamp
298302
runtime/syntax/erlang.vim @hcs42
299303
runtime/syntax/eruby.vim @tpope @dkearns
304+
runtime/syntax/expect.vim @dkearns
300305
runtime/syntax/exports.vim @cecamp
301306
runtime/syntax/falcon.vim @steveno
307+
runtime/syntax/fennel.vim @gpanders
302308
runtime/syntax/fetchmail.vim @dkearns
303309
runtime/syntax/forth.vim @jkotlinski
304310
runtime/syntax/fpcmake.vim @dkearns
@@ -316,6 +322,7 @@ runtime/syntax/groff.vim @jmarshall
316322
runtime/syntax/haml.vim @tpope
317323
runtime/syntax/haskell.vim @coot
318324
runtime/syntax/hgcommit.vim @k-takata
325+
runtime/syntax/html.vim @dkearns
319326
runtime/syntax/i3config.vim @hiqua
320327
runtime/syntax/icon.vim @dkearns
321328
runtime/syntax/indent.vim @dkearns

runtime/autoload/bitbake.vim

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
" Support for bitbake indenting, see runtime/indent/bitbake.vim
2+
3+
function s:is_bb_python_func_def(lnum)
4+
let stack = synstack(a:lnum, 1)
5+
if len(stack) == 0
6+
return 0
7+
endif
8+
9+
return synIDattr(stack[0], "name") == "bbPyFuncDef"
10+
endfunction
11+
12+
function bitbake#Indent(lnum)
13+
if !has('syntax_items')
14+
return -1
15+
endif
16+
17+
let stack = synstack(a:lnum, 1)
18+
if len(stack) == 0
19+
return -1
20+
endif
21+
22+
let name = synIDattr(stack[0], "name")
23+
24+
" TODO: support different styles of indentation for assignments. For now,
25+
" we only support like this:
26+
" VAR = " \
27+
" value1 \
28+
" value2 \
29+
" "
30+
"
31+
" i.e. each value indented by shiftwidth(), with the final quote " completely unindented.
32+
if name == "bbVarValue"
33+
" Quote handling is tricky. kernel.bbclass has this line for instance:
34+
" EXTRA_OEMAKE = " HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" " HOSTCPP="${BUILD_CPP}""
35+
" Instead of trying to handle crazy cases like that, just assume that a
36+
" double-quote on a line by itself (following an assignment) means the
37+
" user is closing the assignment, and de-dent.
38+
if getline(a:lnum) =~ '^\s*"$'
39+
return 0
40+
endif
41+
42+
let prevstack = synstack(a:lnum - 1, 1)
43+
if len(prevstack) == 0
44+
return -1
45+
endif
46+
47+
let prevname = synIDattr(prevstack[0], "name")
48+
49+
" Only indent if there was actually a continuation character on
50+
" the previous line, to avoid misleading indentation.
51+
let prevlinelastchar = synIDattr(synID(a:lnum - 1, col([a:lnum - 1, "$"]) - 1, 1), "name")
52+
let prev_continued = prevlinelastchar == "bbContinue"
53+
54+
" Did the previous line introduce an assignment?
55+
if index(["bbVarDef", "bbVarFlagDef"], prevname) != -1
56+
if prev_continued
57+
return shiftwidth()
58+
endif
59+
endif
60+
61+
if !prev_continued
62+
return 0
63+
endif
64+
65+
" Autoindent can take it from here
66+
return -1
67+
endif
68+
69+
if index(["bbPyDefRegion", "bbPyFuncRegion"], name) != -1
70+
let ret = python#GetIndent(a:lnum, function('s:is_bb_python_func_def'))
71+
" Should normally always be indented by at least one shiftwidth; but allow
72+
" return of -1 (defer to autoindent) or -2 (force indent to 0)
73+
if ret == 0
74+
return shiftwidth()
75+
elseif ret == -2
76+
return 0
77+
endif
78+
return ret
79+
endif
80+
81+
" TODO: GetShIndent doesn't detect tasks prepended with 'fakeroot'
82+
" Need to submit a patch upstream to Vim to provide an extension point.
83+
" Unlike the Python indenter, the Sh indenter is way too large to copy and
84+
" modify here.
85+
if name == "bbShFuncRegion"
86+
return GetShIndent()
87+
endif
88+
89+
" TODO:
90+
" + heuristics for de-denting out of a bbPyDefRegion? e.g. when the user
91+
" types an obvious BB keyword like addhandler or addtask, or starts
92+
" writing a shell task. Maybe too hard to implement...
93+
94+
return -1
95+
endfunction

runtime/autoload/dist/ft.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ export def FTinc()
519519
# headers so assume POV-Ray
520520
elseif lines =~ '^\s*\%({\|(\*\)' || lines =~? ft_pascal_keywords
521521
setf pascal
522-
elseif lines =~# '\<\%(require\|inherit\)\>' || lines =~# '\w\+ = '
522+
elseif lines =~# '\<\%(require\|inherit\)\>' || lines =~# '[A-Z][A-Za-z0-9_:${}]*\s\+\%(??\|[?:+]\)\?= '
523523
setf bitbake
524524
else
525525
FTasmsyntax()

runtime/autoload/python.vim

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
" Support for Python indenting, see runtime/indent/python.vim
2+
3+
let s:keepcpo= &cpo
4+
set cpo&vim
5+
6+
" See if the specified line is already user-dedented from the expected value.
7+
function s:Dedented(lnum, expected)
8+
return indent(a:lnum) <= a:expected - shiftwidth()
9+
endfunction
10+
11+
let s:maxoff = 50 " maximum number of lines to look backwards for ()
12+
13+
" Some other filetypes which embed Python have slightly different indent
14+
" rules (e.g. bitbake). Those filetypes can pass an extra funcref to this
15+
" function which is evaluated below.
16+
function python#GetIndent(lnum, ...)
17+
let ExtraFunc = a:0 > 0 ? a:1 : 0
18+
19+
" If this line is explicitly joined: If the previous line was also joined,
20+
" line it up with that one, otherwise add two 'shiftwidth'
21+
if getline(a:lnum - 1) =~ '\\$'
22+
if a:lnum > 1 && getline(a:lnum - 2) =~ '\\$'
23+
return indent(a:lnum - 1)
24+
endif
25+
return indent(a:lnum - 1) + (exists("g:pyindent_continue") ? eval(g:pyindent_continue) : (shiftwidth() * 2))
26+
endif
27+
28+
" If the start of the line is in a string don't change the indent.
29+
if has('syntax_items')
30+
\ && synIDattr(synID(a:lnum, 1, 1), "name") =~ "String$"
31+
return -1
32+
endif
33+
34+
" Search backwards for the previous non-empty line.
35+
let plnum = prevnonblank(v:lnum - 1)
36+
37+
if plnum == 0
38+
" This is the first non-empty line, use zero indent.
39+
return 0
40+
endif
41+
42+
call cursor(plnum, 1)
43+
44+
" Identing inside parentheses can be very slow, regardless of the searchpair()
45+
" timeout, so let the user disable this feature if he doesn't need it
46+
let disable_parentheses_indenting = get(g:, "pyindent_disable_parentheses_indenting", 0)
47+
48+
if disable_parentheses_indenting == 1
49+
let plindent = indent(plnum)
50+
let plnumstart = plnum
51+
else
52+
" searchpair() can be slow sometimes, limit the time to 150 msec or what is
53+
" put in g:pyindent_searchpair_timeout
54+
let searchpair_stopline = 0
55+
let searchpair_timeout = get(g:, 'pyindent_searchpair_timeout', 150)
56+
57+
" If the previous line is inside parenthesis, use the indent of the starting
58+
" line.
59+
" Trick: use the non-existing "dummy" variable to break out of the loop when
60+
" going too far back.
61+
let parlnum = searchpair('(\|{\|\[', '', ')\|}\|\]', 'nbW',
62+
\ "line('.') < " . (plnum - s:maxoff) . " ? dummy :"
63+
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
64+
\ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
65+
\ searchpair_stopline, searchpair_timeout)
66+
if parlnum > 0
67+
if a:0 > 0 && ExtraFunc(parlnum)
68+
" We may have found the opening brace of a bitbake Python task, e.g. 'python do_task {'
69+
" If so, ignore it here - it will be handled later.
70+
let parlnum = 0
71+
let plindent = indent(plnum)
72+
let plnumstart = plnum
73+
else
74+
let plindent = indent(parlnum)
75+
let plnumstart = parlnum
76+
endif
77+
else
78+
let plindent = indent(plnum)
79+
let plnumstart = plnum
80+
endif
81+
82+
" When inside parenthesis: If at the first line below the parenthesis add
83+
" two 'shiftwidth', otherwise same as previous line.
84+
" i = (a
85+
" + b
86+
" + c)
87+
call cursor(a:lnum, 1)
88+
let p = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
89+
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
90+
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
91+
\ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
92+
\ searchpair_stopline, searchpair_timeout)
93+
if p > 0
94+
if a:0 > 0 && ExtraFunc(p)
95+
" Currently only used by bitbake
96+
" Handle first non-empty line inside a bitbake Python task
97+
if p == plnum
98+
return shiftwidth()
99+
endif
100+
101+
" Handle the user actually trying to close a bitbake Python task
102+
let line = getline(a:lnum)
103+
if line =~ '^\s*}'
104+
return -2
105+
endif
106+
107+
" Otherwise ignore the brace
108+
let p = 0
109+
else
110+
if p == plnum
111+
" When the start is inside parenthesis, only indent one 'shiftwidth'.
112+
let pp = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
113+
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
114+
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
115+
\ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
116+
\ searchpair_stopline, searchpair_timeout)
117+
if pp > 0
118+
return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyindent_nested_paren) : shiftwidth())
119+
endif
120+
return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyindent_open_paren) : (shiftwidth() * 2))
121+
endif
122+
if plnumstart == p
123+
return indent(plnum)
124+
endif
125+
return plindent
126+
endif
127+
endif
128+
endif
129+
130+
131+
" Get the line and remove a trailing comment.
132+
" Use syntax highlighting attributes when possible.
133+
let pline = getline(plnum)
134+
let pline_len = strlen(pline)
135+
if has('syntax_items')
136+
" If the last character in the line is a comment, do a binary search for
137+
" the start of the comment. synID() is slow, a linear search would take
138+
" too long on a long line.
139+
if synIDattr(synID(plnum, pline_len, 1), "name") =~ "\\(Comment\\|Todo\\)$"
140+
let min = 1
141+
let max = pline_len
142+
while min < max
143+
let col = (min + max) / 2
144+
if synIDattr(synID(plnum, col, 1), "name") =~ "\\(Comment\\|Todo\\)$"
145+
let max = col
146+
else
147+
let min = col + 1
148+
endif
149+
endwhile
150+
let pline = strpart(pline, 0, min - 1)
151+
endif
152+
else
153+
let col = 0
154+
while col < pline_len
155+
if pline[col] == '#'
156+
let pline = strpart(pline, 0, col)
157+
break
158+
endif
159+
let col = col + 1
160+
endwhile
161+
endif
162+
163+
" If the previous line ended with a colon, indent this line
164+
if pline =~ ':\s*$'
165+
return plindent + shiftwidth()
166+
endif
167+
168+
" If the previous line was a stop-execution statement...
169+
if getline(plnum) =~ '^\s*\(break\|continue\|raise\|return\|pass\)\>'
170+
" See if the user has already dedented
171+
if s:Dedented(a:lnum, indent(plnum))
172+
" If so, trust the user
173+
return -1
174+
endif
175+
" If not, recommend one dedent
176+
return indent(plnum) - shiftwidth()
177+
endif
178+
179+
" If the current line begins with a keyword that lines up with "try"
180+
if getline(a:lnum) =~ '^\s*\(except\|finally\)\>'
181+
let lnum = a:lnum - 1
182+
while lnum >= 1
183+
if getline(lnum) =~ '^\s*\(try\|except\)\>'
184+
let ind = indent(lnum)
185+
if ind >= indent(a:lnum)
186+
return -1 " indent is already less than this
187+
endif
188+
return ind " line up with previous try or except
189+
endif
190+
let lnum = lnum - 1
191+
endwhile
192+
return -1 " no matching "try"!
193+
endif
194+
195+
" If the current line begins with a header keyword, dedent
196+
if getline(a:lnum) =~ '^\s*\(elif\|else\)\>'
197+
198+
" Unless the previous line was a one-liner
199+
if getline(plnumstart) =~ '^\s*\(for\|if\|elif\|try\)\>'
200+
return plindent
201+
endif
202+
203+
" Or the user has already dedented
204+
if s:Dedented(a:lnum, plindent)
205+
return -1
206+
endif
207+
208+
return plindent - shiftwidth()
209+
endif
210+
211+
" When after a () construct we probably want to go back to the start line.
212+
" a = (b
213+
" + c)
214+
" here
215+
if parlnum > 0
216+
" ...unless the user has already dedented
217+
if s:Dedented(a:lnum, plindent)
218+
return -1
219+
else
220+
return plindent
221+
endif
222+
endif
223+
224+
return -1
225+
endfunction
226+
227+
let &cpo = s:keepcpo
228+
unlet s:keepcpo

runtime/doc/autocmd.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ User Never executed automatically. To be used for
12821282
if exists('#User#MyEvent')
12831283
doautocmd User MyEvent
12841284
endif
1285-
1285+
<
12861286
*SigUSR1*
12871287
SigUSR1 After the SIGUSR1 signal has been detected.
12881288
Could be used if other ways of notifying Vim

0 commit comments

Comments
 (0)