comparison runtime/indent/scala.vim @ 11160:d0a20101ecb2

Update runtime files. commit https://github.com/vim/vim/commit/036986f1507d223549d110af300144468bd3a1f7 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 16 17:41:02 2017 +0100 Update runtime files.
author Christian Brabandt <cb@256bit.org>
date Thu, 16 Mar 2017 17:45:05 +0100
parents 03fa8a51e9dc
children d4faa2c5211b
comparison
equal deleted inserted replaced
11159:c13ab9398ce9 11160:d0a20101ecb2
410 " '.' continuations 410 " '.' continuations
411 if curline =~ '^\s*\.' 411 if curline =~ '^\s*\.'
412 if prevline =~ '^\s*\.' 412 if prevline =~ '^\s*\.'
413 return ind 413 return ind
414 else 414 else
415 return ind + &shiftwidth 415 return ind + shiftwidth()
416 endif 416 endif
417 endif 417 endif
418 418
419 " Indent html literals 419 " Indent html literals
420 if prevline !~ '/>\s*$' && prevline =~ '^\s*<[a-zA-Z][^>]*>\s*$' 420 if prevline !~ '/>\s*$' && prevline =~ '^\s*<[a-zA-Z][^>]*>\s*$'
421 call scala#ConditionalConfirm("3") 421 call scala#ConditionalConfirm("3")
422 return ind + &shiftwidth 422 return ind + shiftwidth()
423 endif 423 endif
424 424
425 " assumes curly braces around try-block 425 " assumes curly braces around try-block
426 if curline =~ '^\s*}\s*\<catch\>' 426 if curline =~ '^\s*}\s*\<catch\>'
427 return ind - &shiftwidth 427 return ind - shiftwidth()
428 elseif curline =~ '^\s*\<catch\>' 428 elseif curline =~ '^\s*\<catch\>'
429 return ind 429 return ind
430 endif 430 endif
431 431
432 " Add a 'shiftwidth' after lines that start a block 432 " Add a shiftwidth()' after lines that start a block
433 " If 'if', 'for' or 'while' end with ), this is a one-line block 433 " If 'if', 'for' or 'while' end with ), this is a one-line block
434 " If 'val', 'var', 'def' end with =, this is a one-line block 434 " If 'val', 'var', 'def' end with =, this is a one-line block
435 if (prevline =~ '^\s*\<\%(\%(}\?\s*else\s\+\)\?if\|for\|while\)\>.*[)=]\s*$' && scala#NumberOfBraceGroups(prevline) <= 1) 435 if (prevline =~ '^\s*\<\%(\%(}\?\s*else\s\+\)\?if\|for\|while\)\>.*[)=]\s*$' && scala#NumberOfBraceGroups(prevline) <= 1)
436 \ || prevline =~ '^\s*' . s:defMatcher . '.*=\s*$' 436 \ || prevline =~ '^\s*' . s:defMatcher . '.*=\s*$'
437 \ || prevline =~ '^\s*\<va[lr]\>.*[=]\s*$' 437 \ || prevline =~ '^\s*\<va[lr]\>.*[=]\s*$'
438 \ || prevline =~ '^\s*\%(}\s*\)\?\<else\>\s*$' 438 \ || prevline =~ '^\s*\%(}\s*\)\?\<else\>\s*$'
439 \ || prevline =~ '=\s*$' 439 \ || prevline =~ '=\s*$'
440 call scala#ConditionalConfirm("4") 440 call scala#ConditionalConfirm("4")
441 let ind = ind + &shiftwidth 441 let ind = ind + shiftwidth()
442 elseif prevline =~ '^\s*\<\%(}\?\s*else\s\+\)\?if\>' && curline =~ '^\s*}\?\s*\<else\>' 442 elseif prevline =~ '^\s*\<\%(}\?\s*else\s\+\)\?if\>' && curline =~ '^\s*}\?\s*\<else\>'
443 return ind 443 return ind
444 endif 444 endif
445 445
446 let lineCompletedBrackets = 0 446 let lineCompletedBrackets = 0
447 let bracketCount = scala#CountBrackets(prevline, '{', '}') 447 let bracketCount = scala#CountBrackets(prevline, '{', '}')
448 if bracketCount > 0 || prevline =~ '.*{\s*$' 448 if bracketCount > 0 || prevline =~ '.*{\s*$'
449 call scala#ConditionalConfirm("5b") 449 call scala#ConditionalConfirm("5b")
450 let ind = ind + &shiftwidth 450 let ind = ind + shiftwidth()
451 elseif bracketCount < 0 451 elseif bracketCount < 0
452 call scala#ConditionalConfirm("6b") 452 call scala#ConditionalConfirm("6b")
453 " if the closing brace actually completes the braces entirely, then we 453 " if the closing brace actually completes the braces entirely, then we
454 " have to indent to line that started the whole thing 454 " have to indent to line that started the whole thing
455 let completeLine = scala#LineCompletesBrackets('{', '}') 455 let completeLine = scala#LineCompletesBrackets('{', '}')
473 473
474 if ind == originalIndentValue 474 if ind == originalIndentValue
475 let bracketCount = scala#CountBrackets(prevline, '(', ')') 475 let bracketCount = scala#CountBrackets(prevline, '(', ')')
476 if bracketCount > 0 || prevline =~ '.*(\s*$' 476 if bracketCount > 0 || prevline =~ '.*(\s*$'
477 call scala#ConditionalConfirm("5a") 477 call scala#ConditionalConfirm("5a")
478 let ind = ind + &shiftwidth 478 let ind = ind + shiftwidth()
479 elseif bracketCount < 0 479 elseif bracketCount < 0
480 call scala#ConditionalConfirm("6a") 480 call scala#ConditionalConfirm("6a")
481 " if the closing brace actually completes the braces entirely, then we 481 " if the closing brace actually completes the braces entirely, then we
482 " have to indent to line that started the whole thing 482 " have to indent to line that started the whole thing
483 let completeLine = scala#LineCompletesBrackets('(', ')') 483 let completeLine = scala#LineCompletesBrackets('(', ')')
495 let ind = indent(completeLine) 495 let ind = indent(completeLine)
496 endif 496 endif
497 else 497 else
498 " This is the only part that's different from from the '{', '}' one below 498 " This is the only part that's different from from the '{', '}' one below
499 " Yup... some refactoring is necessary at some point. 499 " Yup... some refactoring is necessary at some point.
500 let ind = ind + (bracketCount * &shiftwidth) 500 let ind = ind + (bracketCount * shiftwidth())
501 let lineCompletedBrackets = 1 501 let lineCompletedBrackets = 1
502 endif 502 endif
503 endif 503 endif
504 endif 504 endif
505 505
506 if curline =~ '^\s*}\?\s*\<else\>\%(\s\+\<if\>\s*(.*)\)\?\s*{\?\s*$' && 506 if curline =~ '^\s*}\?\s*\<else\>\%(\s\+\<if\>\s*(.*)\)\?\s*{\?\s*$' &&
507 \ ! scala#LineIsCompleteIf(prevline) && 507 \ ! scala#LineIsCompleteIf(prevline) &&
508 \ prevline !~ '^.*}\s*$' 508 \ prevline !~ '^.*}\s*$'
509 let ind = ind - &shiftwidth 509 let ind = ind - shiftwidth()
510 endif 510 endif
511 511
512 " Subtract a 'shiftwidth' on '}' or html 512 " Subtract a shiftwidth()' on '}' or html
513 let curCurlyCount = scala#CountCurlies(curline) 513 let curCurlyCount = scala#CountCurlies(curline)
514 if curCurlyCount < 0 514 if curCurlyCount < 0
515 call scala#ConditionalConfirm("14a") 515 call scala#ConditionalConfirm("14a")
516 let matchline = scala#CurlyMatcher() 516 let matchline = scala#CurlyMatcher()
517 return indent(matchline) 517 return indent(matchline)
518 elseif curline =~ '^\s*</[a-zA-Z][^>]*>' 518 elseif curline =~ '^\s*</[a-zA-Z][^>]*>'
519 call scala#ConditionalConfirm("14c") 519 call scala#ConditionalConfirm("14c")
520 return ind - &shiftwidth 520 return ind - shiftwidth()
521 endif 521 endif
522 522
523 let prevParenCount = scala#CountParens(prevline) 523 let prevParenCount = scala#CountParens(prevline)
524 if prevline =~ '^\s*\<for\>.*$' && prevParenCount > 0 524 if prevline =~ '^\s*\<for\>.*$' && prevParenCount > 0
525 call scala#ConditionalConfirm("15") 525 call scala#ConditionalConfirm("15")
527 endif 527 endif
528 528
529 let prevCurlyCount = scala#CountCurlies(prevline) 529 let prevCurlyCount = scala#CountCurlies(prevline)
530 if prevCurlyCount == 0 && prevline =~ '^.*\%(=>\|⇒\)\s*$' && prevline !~ '^\s*this\s*:.*\%(=>\|⇒\)\s*$' && curline !~ '^\s*\<case\>' 530 if prevCurlyCount == 0 && prevline =~ '^.*\%(=>\|⇒\)\s*$' && prevline !~ '^\s*this\s*:.*\%(=>\|⇒\)\s*$' && curline !~ '^\s*\<case\>'
531 call scala#ConditionalConfirm("16") 531 call scala#ConditionalConfirm("16")
532 let ind = ind + &shiftwidth 532 let ind = ind + shiftwidth()
533 endif 533 endif
534 534
535 if ind == originalIndentValue && curline =~ '^\s*\<case\>' 535 if ind == originalIndentValue && curline =~ '^\s*\<case\>'
536 call scala#ConditionalConfirm("17") 536 call scala#ConditionalConfirm("17")
537 let parentCase = scala#IsParentCase() 537 let parentCase = scala#IsParentCase()
553 endif 553 endif
554 554
555 if scala#LineIsAClosingXML(prevline) 555 if scala#LineIsAClosingXML(prevline)
556 if scala#LineCompletesXML(prevlnum, prevline) 556 if scala#LineCompletesXML(prevlnum, prevline)
557 call scala#ConditionalConfirm("20a") 557 call scala#ConditionalConfirm("20a")
558 return ind - &shiftwidth 558 return ind - shiftwidth()
559 else 559 else
560 call scala#ConditionalConfirm("20b") 560 call scala#ConditionalConfirm("20b")
561 return ind 561 return ind
562 endif 562 endif
563 endif 563 endif
564 564
565 if ind == originalIndentValue 565 if ind == originalIndentValue
566 "let indentMultiplier = scala#LineCompletesDefValr(prevlnum, prevline) 566 "let indentMultiplier = scala#LineCompletesDefValr(prevlnum, prevline)
567 "if indentMultiplier != 0 567 "if indentMultiplier != 0
568 " call scala#ConditionalConfirm("19a") 568 " call scala#ConditionalConfirm("19a")
569 " let ind = ind - (indentMultiplier * &shiftwidth) 569 " let ind = ind - (indentMultiplier * shiftwidth())
570 let defValrLine = scala#Test(prevlnum, prevline, '{', '}') 570 let defValrLine = scala#Test(prevlnum, prevline, '{', '}')
571 if defValrLine != -1 571 if defValrLine != -1
572 call scala#ConditionalConfirm("21a") 572 call scala#ConditionalConfirm("21a")
573 let ind = indent(defValrLine) 573 let ind = indent(defValrLine)
574 elseif lineCompletedBrackets == 0 574 elseif lineCompletedBrackets == 0
575 call scala#ConditionalConfirm("21b") 575 call scala#ConditionalConfirm("21b")
576 if scala#GetLine(prevnonblank(prevlnum - 1)) =~ '^.*\<else\>\s*\%(//.*\)\?$' 576 if scala#GetLine(prevnonblank(prevlnum - 1)) =~ '^.*\<else\>\s*\%(//.*\)\?$'
577 call scala#ConditionalConfirm("21c") 577 call scala#ConditionalConfirm("21c")
578 let ind = ind - &shiftwidth 578 let ind = ind - shiftwidth()
579 elseif scala#LineCompletesIfElse(prevlnum, prevline) 579 elseif scala#LineCompletesIfElse(prevlnum, prevline)
580 call scala#ConditionalConfirm("21d") 580 call scala#ConditionalConfirm("21d")
581 let ind = ind - &shiftwidth 581 let ind = ind - shiftwidth()
582 elseif scala#CountParens(curline) < 0 && curline =~ '^\s*)' && scala#GetLine(scala#GetLineThatMatchesBracket('(', ')')) =~ '.*(\s*$' 582 elseif scala#CountParens(curline) < 0 && curline =~ '^\s*)' && scala#GetLine(scala#GetLineThatMatchesBracket('(', ')')) =~ '.*(\s*$'
583 " Handles situations that look like this: 583 " Handles situations that look like this:
584 " 584 "
585 " val a = func( 585 " val a = func(
586 " 10 586 " 10
590 " 590 "
591 " val a = func( 591 " val a = func(
592 " 10 592 " 10
593 " ).somethingHere() 593 " ).somethingHere()
594 call scala#ConditionalConfirm("21e") 594 call scala#ConditionalConfirm("21e")
595 let ind = ind - &shiftwidth 595 let ind = ind - shiftwidth()
596 endif 596 endif
597 endif 597 endif
598 endif 598 endif
599 599
600 call scala#ConditionalConfirm("returning " . ind) 600 call scala#ConditionalConfirm("returning " . ind)