@@ -58,23 +58,11 @@ endif
58
58
let s: stop_statement = ' ^\s*\(break\|continue\|raise\|return\|pass\)\>'
59
59
60
60
" Skip strings and comments. Return 1 for chars to skip.
61
- " jedi* refers to syntax definitions from jedi-vim for call signatures, which
62
- " are inserted temporarily into the buffer.
63
61
let s: skip_special_chars = ' synIDattr(synID(line("."), col("."), 0), "name") ' .
64
- \ ' =~? "\\vstring|comment|jedi\\S "'
62
+ \ ' =~? "\\vstring|comment"'
65
63
66
64
let s: skip_after_opening_paren = ' synIDattr(synID(line("."), col("."), 0), "name") ' .
67
- \ ' =~? "\\vcomment|jedi\\S"'
68
-
69
- " Also ignore anything concealed.
70
- " Wrapper around synconcealed for older Vim (7.3.429, used on Travis CI).
71
- function ! s: is_concealed (line , col )
72
- let concealed = synconcealed (a: line , a: col )
73
- return len (concealed) && concealed[0 ]
74
- endfunction
75
- if has (' conceal' )
76
- let s: skip_special_chars .= ' || s:is_concealed(line("."), col("."))'
77
- endif
65
+ \ ' =~? "\\vcomment"'
78
66
79
67
80
68
let s: skip_search = ' synIDattr(synID(line("."), col("."), 0), "name") ' .
@@ -130,8 +118,8 @@ endfunction
130
118
function ! s: find_start_of_multiline_statement (lnum)
131
119
let lnum = a: lnum
132
120
while lnum > 0
133
- if getline (lnum - 1 ) = ~# ' \\$'
134
- let lnum = prevnonblank (lnum - 1 )
121
+ if s: getline (lnum - 1 ) = ~# ' \\$'
122
+ let lnum = s: prevnonblank (lnum - 1 )
135
123
else
136
124
let [paren_lnum, _] = s: find_opening_paren (lnum)
137
125
if paren_lnum < 1
@@ -155,7 +143,7 @@ function! s:find_start_of_block(lnum, types, multiple)
155
143
if indent < last_indent
156
144
for type in types
157
145
let re = ' \v^\s*' .type .' >'
158
- if getline (lnum) = ~# re
146
+ if s: getline (lnum) = ~# re
159
147
if ! a: multiple
160
148
return [indent ]
161
149
endif
@@ -168,15 +156,15 @@ function! s:find_start_of_block(lnum, types, multiple)
168
156
endfor
169
157
let last_indent = indent (lnum)
170
158
endif
171
- let lnum = prevnonblank (lnum - 1 )
159
+ let lnum = s: prevnonblank (lnum - 1 )
172
160
endwhile
173
161
return r
174
162
endfunction
175
163
176
164
" Is "expr" true for every position in "lnum", beginning at "start"?
177
165
" (optionally up to a:1 / 4th argument)
178
166
function ! s: match_expr_on_line (expr , lnum, start , ... )
179
- let text = getline (a: lnum )
167
+ let text = s: getline (a: lnum )
180
168
let end = a: 0 ? a: 1 : len (text)
181
169
if a: start > end
182
170
return 1
@@ -200,12 +188,12 @@ function! s:indent_like_opening_paren(lnum)
200
188
if paren_lnum <= 0
201
189
return -2
202
190
endif
203
- let text = getline (paren_lnum)
191
+ let text = s: getline (paren_lnum)
204
192
let base = indent (paren_lnum)
205
193
206
194
let nothing_after_opening_paren = s: match_expr_on_line (
207
195
\ s: skip_after_opening_paren , paren_lnum, paren_col+ 1 )
208
- let starts_with_closing_paren = getline (a: lnum ) = ~# ' ^\s*[])}]'
196
+ let starts_with_closing_paren = s: getline (a: lnum ) = ~# ' ^\s*[])}]'
209
197
210
198
let hang_closing = get (b: , ' python_pep8_indent_hang_closing' ,
211
199
\ get (g: , ' python_pep8_indent_hang_closing' , 0 ))
@@ -233,7 +221,7 @@ endfunction
233
221
234
222
" Match indent of first block of this type.
235
223
function ! s: indent_like_block (lnum)
236
- let text = getline (a: lnum )
224
+ let text = s: getline (a: lnum )
237
225
for [multiple, block_rules] in [
238
226
\ [0 , s: block_rules ],
239
227
\ [1 , s: block_rules_multiple ]]
@@ -263,15 +251,45 @@ function! s:indent_like_block(lnum)
263
251
return -2
264
252
endfunction
265
253
254
+ " Wrapper around getline that looks up jedi-vim's b:_jedi_callsig_orig to get
255
+ " the original line.
256
+ function ! s: getline (lnum) abort
257
+ let line = get (get (b: , ' _jedi_callsig_orig' , {}), a: lnum , 0 )
258
+ if line is 0
259
+ return getline (a: lnum )
260
+ endif
261
+ return line
262
+ endfunction
263
+
264
+ " Wrapper around prevnonblank that looks up jedi-vim's b:_jedi_callsig_orig to
265
+ " check the original line's contents additionally.
266
+ function ! s: prevnonblank (lnum) abort
267
+ let lnum = a: lnum
268
+ while 1
269
+ let lnum = prevnonblank (lnum)
270
+ if lnum < 1
271
+ return lnum
272
+ endif
273
+ let orig_line = get (get (b: , ' _jedi_callsig_orig' , {}), lnum, 0 )
274
+ if orig_line is 0
275
+ return lnum
276
+ endif
277
+ if ! empty (orig_line)
278
+ return lnum
279
+ endif
280
+ let lnum -= 1
281
+ endwhile
282
+ endfunction
283
+
266
284
function ! s: indent_like_previous_line (lnum)
267
- let lnum = prevnonblank (a: lnum - 1 )
285
+ let lnum = s: prevnonblank (a: lnum - 1 )
268
286
269
287
" No previous line, keep current indent.
270
288
if lnum < 1
271
289
return -1
272
290
endif
273
291
274
- let text = getline (lnum)
292
+ let text = s: getline (lnum)
275
293
let start = s: find_start_of_multiline_statement (lnum)
276
294
let base = indent (start )
277
295
let current = indent (a: lnum )
@@ -297,25 +315,25 @@ function! s:indent_like_previous_line(lnum)
297
315
" If this line is the continuation of a control statement
298
316
" indent further to distinguish the continuation line
299
317
" from the next logical line.
300
- if getline (start ) = ~# b: control_statement
318
+ if s: getline (start ) = ~# b: control_statement
301
319
return base + s: sw () * 2
302
320
endif
303
321
304
322
" Nest (other) explicit continuations only one level deeper.
305
323
return base + s: sw ()
306
324
endif
307
325
308
- let empty = getline (a: lnum ) = ~# ' ^\s*$'
326
+ let empty = s: getline (a: lnum ) = ~# ' ^\s*$'
309
327
310
328
" Current and prev line are empty, next is not -> indent like next.
311
329
if empty && a: lnum > 1 &&
312
- \ (getline (a: lnum - 1 ) = ~# ' ^\s*$' ) &&
313
- \ ! (getline (a: lnum + 1 ) = ~# ' ^\s*$' )
330
+ \ (s: getline (a: lnum - 1 ) = ~# ' ^\s*$' ) &&
331
+ \ ! (s: getline (a: lnum + 1 ) = ~# ' ^\s*$' )
314
332
return indent (a: lnum + 1 )
315
333
endif
316
334
317
335
" If the previous statement was a stop-execution statement or a pass
318
- if getline (start ) = ~# s: stop_statement
336
+ if s: getline (start ) = ~# s: stop_statement
319
337
" Remove one level of indentation if the user hasn't already dedented
320
338
if empty || current > base - s: sw ()
321
339
return base - s: sw ()
@@ -341,7 +359,7 @@ endfunction
341
359
342
360
" Is the syntax at lnum (and optionally cnum) a python string?
343
361
function ! s: is_python_string (lnum, ... )
344
- let line = getline (a: lnum )
362
+ let line = s: getline (a: lnum )
345
363
let linelen = len (line )
346
364
if linelen < 1
347
365
let linelen = 1
@@ -362,8 +380,8 @@ function! GetPythonPEPIndent(lnum)
362
380
return 0
363
381
endif
364
382
365
- let line = getline (a: lnum )
366
- let prevline = getline (a: lnum- 1 )
383
+ let line = s: getline (a: lnum )
384
+ let prevline = s: getline (a: lnum- 1 )
367
385
368
386
" Multilinestrings: continous, docstring or starting.
369
387
if s: is_python_string (a: lnum- 1 , len (prevline))
0 commit comments