comparison runtime/indent/r.vim @ 11347:4aae8146c21f

Update runtime files. commit https://github.com/vim/vim/commit/cd5c8f82507822467232ab71e1ebbaae19595916 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 9 20:11:58 2017 +0200 Update runtime files.
author Christian Brabandt <cb@256bit.org>
date Sun, 09 Apr 2017 20:15:03 +0200
parents da01d5da2cfa
children 0ecb909e3249
comparison
equal deleted inserted replaced
11346:75f4dd526eb8 11347:4aae8146c21f
272 let nline = line 272 let nline = line
273 while s:Get_paren_balance(nline, '(', ')') < 0 273 while s:Get_paren_balance(nline, '(', ')') < 0
274 let nlnum = s:Get_prev_line(nlnum) 274 let nlnum = s:Get_prev_line(nlnum)
275 let nline = SanitizeRLine(getline(nlnum)) . nline 275 let nline = SanitizeRLine(getline(nlnum)) . nline
276 endwhile 276 endwhile
277 if nline =~ '^\s*function\s*(' && indent(nlnum) == &sw 277 if nline =~ '^\s*function\s*(' && indent(nlnum) == shiftwidth()
278 return 0 278 return 0
279 endif 279 endif
280 endif 280 endif
281 if s:Get_paren_balance(line, "(", ")") == 0 281 if s:Get_paren_balance(line, "(", ")") == 0
282 return indent(lnum) 282 return indent(lnum)
283 endif 283 endif
284 endif 284 endif
285 285
286 " line is an incomplete command: 286 " line is an incomplete command:
287 if line =~ '\<\(if\|while\|for\|function\)\s*()$' || line =~ '\<else$' || line =~ '<-$' || line =~ '->$' 287 if line =~ '\<\(if\|while\|for\|function\)\s*()$' || line =~ '\<else$' || line =~ '<-$' || line =~ '->$'
288 return indent(lnum) + &sw 288 return indent(lnum) + shiftwidth()
289 endif 289 endif
290 290
291 " Deal with () and [] 291 " Deal with () and []
292 292
293 let pb = s:Get_paren_balance(line, '(', ')') 293 let pb = s:Get_paren_balance(line, '(', ')')
294 294
295 if line =~ '^\s*{$' || line =~ '(\s*{' || (pb == 0 && (line =~ '{$' || line =~ '(\s*{$')) 295 if line =~ '^\s*{$' || line =~ '(\s*{' || (pb == 0 && (line =~ '{$' || line =~ '(\s*{$'))
296 return indent(lnum) + &sw 296 return indent(lnum) + shiftwidth()
297 endif 297 endif
298 298
299 let s:curtabstop = repeat(' ', &tabstop) 299 let s:curtabstop = repeat(' ', &tabstop)
300 300
301 if g:r_indent_align_args == 1 301 if g:r_indent_align_args == 1
302 if pb > 0 && line =~ '{$' 302 if pb > 0 && line =~ '{$'
303 return s:Get_last_paren_idx(line, '(', ')', pb) + &sw 303 return s:Get_last_paren_idx(line, '(', ')', pb) + shiftwidth()
304 endif 304 endif
305 305
306 let bb = s:Get_paren_balance(line, '[', ']') 306 let bb = s:Get_paren_balance(line, '[', ']')
307 307
308 if pb > 0 308 if pb > 0
362 if olnum > 0 362 if olnum > 0
363 if line =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 363 if line =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
364 if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 364 if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
365 return indent(lnum) 365 return indent(lnum)
366 else 366 else
367 return indent(lnum) + &sw 367 return indent(lnum) + shiftwidth()
368 endif 368 endif
369 else 369 else
370 if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 370 if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
371 return indent(lnum) - &sw 371 return indent(lnum) - shiftwidth()
372 endif 372 endif
373 endif 373 endif
374 endif 374 endif
375 375
376 let post_fun = 0 376 let post_fun = 0
381 let linepiece = SanitizeRLine(getline(lnum)) 381 let linepiece = SanitizeRLine(getline(lnum))
382 let pb += s:Get_paren_balance(linepiece, "(", ")") 382 let pb += s:Get_paren_balance(linepiece, "(", ")")
383 let line = linepiece . line 383 let line = linepiece . line
384 endwhile 384 endwhile
385 if line =~ '{$' && post_block == 0 385 if line =~ '{$' && post_block == 0
386 return indent(lnum) + &sw 386 return indent(lnum) + shiftwidth()
387 endif 387 endif
388 388
389 " Now we can do some tests again 389 " Now we can do some tests again
390 if cline =~ '^\s*{' 390 if cline =~ '^\s*{'
391 return indent(lnum) 391 return indent(lnum)
392 endif 392 endif
393 if post_block == 0 393 if post_block == 0
394 let newl = SanitizeRLine(line) 394 let newl = SanitizeRLine(line)
395 if newl =~ '\<\(if\|while\|for\|function\)\s*()$' || newl =~ '\<else$' || newl =~ '<-$' 395 if newl =~ '\<\(if\|while\|for\|function\)\s*()$' || newl =~ '\<else$' || newl =~ '<-$'
396 return indent(lnum) + &sw 396 return indent(lnum) + shiftwidth()
397 endif 397 endif
398 endif 398 endif
399 endif 399 endif
400 400
401 if cline =~ '^\s*else' 401 if cline =~ '^\s*else'
402 if line =~ '<-\s*if\s*()' 402 if line =~ '<-\s*if\s*()'
403 return indent(lnum) + &sw 403 return indent(lnum) + shiftwidth()
404 else 404 else
405 if line =~ '\<if\s*()' 405 if line =~ '\<if\s*()'
406 return indent(lnum) 406 return indent(lnum)
407 else 407 else
408 return indent(lnum) - &sw 408 return indent(lnum) - shiftwidth()
409 endif 409 endif
410 endif 410 endif
411 endif 411 endif
412 412
413 let bb = s:Get_paren_balance(line, '[', ']') 413 let bb = s:Get_paren_balance(line, '[', ']')
472 endif 472 endif
473 473
474 let ind = indent(lnum) 474 let ind = indent(lnum)
475 475
476 if g:r_indent_align_args == 0 && pb != 0 476 if g:r_indent_align_args == 0 && pb != 0
477 let ind += pb * &sw 477 let ind += pb * shiftwidth()
478 return ind 478 return ind
479 endif 479 endif
480 480
481 if g:r_indent_align_args == 0 && bb != 0 481 if g:r_indent_align_args == 0 && bb != 0
482 let ind += bb * &sw 482 let ind += bb * shiftwidth()
483 return ind 483 return ind
484 endif 484 endif
485 485
486 if plnum > 0 486 if plnum > 0
487 let pind = indent(plnum) 487 let pind = indent(plnum)
488 else 488 else
489 let pind = 0 489 let pind = 0
490 endif 490 endif
491 491
492 if ind == pind || (ind == (pind + &sw) && pline =~ '{$' && ppost_else == 0) 492 if ind == pind || (ind == (pind + shiftwidth()) && pline =~ '{$' && ppost_else == 0)
493 return ind 493 return ind
494 endif 494 endif
495 495
496 let pline = getline(plnum) 496 let pline = getline(plnum)
497 let pbb = s:Get_paren_balance(pline, '[', ']') 497 let pbb = s:Get_paren_balance(pline, '[', ']')
507 let pline = getline(plnum) 507 let pline = getline(plnum)
508 let ppb = s:Get_paren_balance(pline, '(', ')') 508 let ppb = s:Get_paren_balance(pline, '(', ')')
509 let pbb = s:Get_paren_balance(pline, '[', ']') 509 let pbb = s:Get_paren_balance(pline, '[', ']')
510 endwhile 510 endwhile
511 let pind = indent(plnum) 511 let pind = indent(plnum)
512 if ind == (pind + &sw) && pline =~ '{$' 512 if ind == (pind + shiftwidth()) && pline =~ '{$'
513 return ind 513 return ind
514 endif 514 endif
515 endwhile 515 endwhile
516 516
517 return ind 517 return ind