This commit is contained in:
Adam Stankiewicz
2021-09-09 12:05:33 +02:00
parent ce31cd1d2f
commit 7f98e949d4
37 changed files with 491 additions and 249 deletions

View File

@@ -416,19 +416,19 @@ function! GetScalaIndent()
if prevline =~ '^\s*\.'
return ind
else
return ind + &shiftwidth
return ind + shiftwidth()
endif
endif
" Indent html literals
if prevline !~ '/>\s*$' && prevline =~ '^\s*<[a-zA-Z][^>]*>\s*$'
call scala#ConditionalConfirm("3")
return ind + &shiftwidth
return ind + shiftwidth()
endif
" assumes curly braces around try-block
if curline =~ '^\s*}\s*\<catch\>'
return ind - &shiftwidth
return ind - shiftwidth()
elseif curline =~ '^\s*\<catch\>'
return ind
endif
@@ -442,7 +442,7 @@ function! GetScalaIndent()
\ || prevline =~ '^\s*\%(}\s*\)\?\<else\>\s*$'
\ || prevline =~ '=\s*$'
call scala#ConditionalConfirm("4")
let ind = ind + &shiftwidth
let ind = ind + shiftwidth()
elseif prevline =~ '^\s*\<\%(}\?\s*else\s\+\)\?if\>' && curline =~ '^\s*}\?\s*\<else\>'
return ind
endif
@@ -451,7 +451,7 @@ function! GetScalaIndent()
let bracketCount = scala#CountBrackets(prevline, '{', '}')
if bracketCount > 0 || prevline =~ '.*{\s*$'
call scala#ConditionalConfirm("5b")
let ind = ind + &shiftwidth
let ind = ind + shiftwidth()
elseif bracketCount < 0
call scala#ConditionalConfirm("6b")
" if the closing brace actually completes the braces entirely, then we
@@ -479,7 +479,7 @@ function! GetScalaIndent()
let bracketCount = scala#CountBrackets(prevline, '(', ')')
if bracketCount > 0 || prevline =~ '.*(\s*$'
call scala#ConditionalConfirm("5a")
let ind = ind + &shiftwidth
let ind = ind + shiftwidth()
elseif bracketCount < 0
call scala#ConditionalConfirm("6a")
" if the closing brace actually completes the braces entirely, then we
@@ -501,7 +501,7 @@ function! GetScalaIndent()
else
" This is the only part that's different from from the '{', '}' one below
" Yup... some refactoring is necessary at some point.
let ind = ind + (bracketCount * &shiftwidth)
let ind = ind + (bracketCount * shiftwidth())
let lineCompletedBrackets = 1
endif
endif
@@ -510,7 +510,7 @@ function! GetScalaIndent()
if curline =~ '^\s*}\?\s*\<else\>\%(\s\+\<if\>\s*(.*)\)\?\s*{\?\s*$' &&
\ ! scala#LineIsCompleteIf(prevline) &&
\ prevline !~ '^.*}\s*$'
let ind = ind - &shiftwidth
let ind = ind - shiftwidth()
endif
" Subtract a 'shiftwidth' on '}' or html
@@ -521,7 +521,7 @@ function! GetScalaIndent()
return indent(matchline)
elseif curline =~ '^\s*</[a-zA-Z][^>]*>'
call scala#ConditionalConfirm("14c")
return ind - &shiftwidth
return ind - shiftwidth()
endif
let prevParenCount = scala#CountParens(prevline)
@@ -533,7 +533,7 @@ function! GetScalaIndent()
let prevCurlyCount = scala#CountCurlies(prevline)
if prevCurlyCount == 0 && prevline =~ '^.*\%(=>\|⇒\)\s*$' && prevline !~ '^\s*this\s*:.*\%(=>\|⇒\)\s*$' && curline !~ '^\s*\<case\>'
call scala#ConditionalConfirm("16")
let ind = ind + &shiftwidth
let ind = ind + shiftwidth()
endif
if ind == originalIndentValue && curline =~ '^\s*\<case\>'
@@ -559,7 +559,7 @@ function! GetScalaIndent()
if scala#LineIsAClosingXML(prevline)
if scala#LineCompletesXML(prevlnum, prevline)
call scala#ConditionalConfirm("20a")
return ind - &shiftwidth
return ind - shiftwidth()
else
call scala#ConditionalConfirm("20b")
return ind
@@ -570,7 +570,7 @@ function! GetScalaIndent()
"let indentMultiplier = scala#LineCompletesDefValr(prevlnum, prevline)
"if indentMultiplier != 0
" call scala#ConditionalConfirm("19a")
" let ind = ind - (indentMultiplier * &shiftwidth)
" let ind = ind - (indentMultiplier * shiftwidth())
let defValrLine = scala#Test(prevlnum, prevline, '{', '}')
if defValrLine != -1
call scala#ConditionalConfirm("21a")
@@ -579,10 +579,10 @@ function! GetScalaIndent()
call scala#ConditionalConfirm("21b")
if scala#GetLine(prevnonblank(prevlnum - 1)) =~ '^.*\<else\>\s*\%(//.*\)\?$'
call scala#ConditionalConfirm("21c")
let ind = ind - &shiftwidth
let ind = ind - shiftwidth()
elseif scala#LineCompletesIfElse(prevlnum, prevline)
call scala#ConditionalConfirm("21d")
let ind = ind - &shiftwidth
let ind = ind - shiftwidth()
elseif scala#CountParens(curline) < 0 && curline =~ '^\s*)' && scala#GetLine(scala#GetLineThatMatchesBracket('(', ')')) =~ '.*(\s*$'
" Handles situations that look like this:
"
@@ -596,7 +596,7 @@ function! GetScalaIndent()
" 10
" ).somethingHere()
call scala#ConditionalConfirm("21e")
let ind = ind - &shiftwidth
let ind = ind - shiftwidth()
endif
endif
endif