mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-16 15:33:49 -05:00
Update
This commit is contained in:
@@ -5,7 +5,7 @@ endif
|
||||
" Vim indent file
|
||||
" Language: Bazel (http://bazel.io)
|
||||
" Maintainer: David Barnett (https://github.com/google/vim-ft-bzl)
|
||||
" Last Change: 2017 Jun 13
|
||||
" Last Change: 2021 Jul 08
|
||||
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
@@ -45,30 +45,41 @@ function GetBzlIndent(lnum) abort
|
||||
if exists('g:pyindent_open_paren')
|
||||
let l:pyindent_open_paren = g:pyindent_open_paren
|
||||
endif
|
||||
let g:pyindent_nested_paren = 'shiftwidth() * 2'
|
||||
let g:pyindent_open_paren = 'shiftwidth() * 2'
|
||||
let g:pyindent_nested_paren = 'shiftwidth()'
|
||||
let g:pyindent_open_paren = 'shiftwidth()'
|
||||
endif
|
||||
|
||||
let l:indent = -1
|
||||
|
||||
" Indent inside parens.
|
||||
" Align with the open paren unless it is at the end of the line.
|
||||
" E.g.
|
||||
" open_paren_not_at_EOL(100,
|
||||
" (200,
|
||||
" 300),
|
||||
" 400)
|
||||
" open_paren_at_EOL(
|
||||
" 100, 200, 300, 400)
|
||||
call cursor(a:lnum, 1)
|
||||
let [l:par_line, l:par_col] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
|
||||
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" .
|
||||
\ " synIDattr(synID(line('.'), col('.'), 1), 'name')" .
|
||||
\ " =~ '\\(Comment\\|String\\)$'")
|
||||
if l:par_line > 0
|
||||
call cursor(l:par_line, 1)
|
||||
if l:par_col != col('$') - 1
|
||||
let l:indent = l:par_col
|
||||
" Indent inside parens.
|
||||
if searchpair('(\|{\|\[', '', ')\|}\|\]', 'W',
|
||||
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" .
|
||||
\ " synIDattr(synID(line('.'), col('.'), 1), 'name')" .
|
||||
\ " =~ '\\(Comment\\|String\\)$'") && line('.') == a:lnum
|
||||
" If cursor is at close parens, match indent with open parens.
|
||||
" E.g.
|
||||
" foo(
|
||||
" )
|
||||
let l:indent = indent(l:par_line)
|
||||
else
|
||||
" Align with the open paren unless it is at the end of the line.
|
||||
" E.g.
|
||||
" open_paren_not_at_EOL(100,
|
||||
" (200,
|
||||
" 300),
|
||||
" 400)
|
||||
" open_paren_at_EOL(
|
||||
" 100, 200, 300, 400)
|
||||
call cursor(l:par_line, 1)
|
||||
if l:par_col != col('$') - 1
|
||||
let l:indent = l:par_col
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ let b:did_indent = 1
|
||||
setlocal indentexpr=elixir#indent(v:lnum)
|
||||
|
||||
setlocal indentkeys+==after,=catch,=do,=else,=end,=rescue,
|
||||
setlocal indentkeys+=*<Return>,=->,=\|>,=<>,0},0],0)
|
||||
setlocal indentkeys+=*<Return>,=->,=\|>,=<>,0},0],0),>
|
||||
|
||||
" TODO: @jbodah 2017-02-27: all operators should cause reindent when typed
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ endfunction
|
||||
" ======================
|
||||
|
||||
" Indtokens are "indentation tokens". See their exact format in the
|
||||
" documentaiton of the s:GetTokensFromLine function.
|
||||
" documentation of the s:GetTokensFromLine function.
|
||||
|
||||
" Purpose:
|
||||
" Calculate the new virtual column after the given segment of a line.
|
||||
@@ -79,7 +79,7 @@ endfunction
|
||||
" s:CalcVCol("\t'\tx', b", 1, 4, 4) -> 10
|
||||
function! s:CalcVCol(line, first_index, last_index, vcol, tabstop)
|
||||
|
||||
" We copy the relevent segment of the line, otherwise if the line were
|
||||
" We copy the relevant segment of the line, otherwise if the line were
|
||||
" e.g. `"\t", term` then the else branch below would consume the `", term`
|
||||
" part at once.
|
||||
let line = a:line[a:first_index : a:last_index]
|
||||
@@ -608,7 +608,7 @@ endfunction
|
||||
function! s:BeginElementFoundIfEmpty(stack, token, curr_vcol, stored_vcol, sw)
|
||||
if empty(a:stack)
|
||||
if a:stored_vcol ==# -1
|
||||
call s:Log(' "' . a:token . '" directly preceeds LTI -> return')
|
||||
call s:Log(' "' . a:token . '" directly precedes LTI -> return')
|
||||
return [1, a:curr_vcol + a:sw]
|
||||
else
|
||||
call s:Log(' "' . a:token .
|
||||
@@ -829,7 +829,7 @@ function! s:ErlangCalcIndent2(lnum, stack)
|
||||
if ret | return res | endif
|
||||
|
||||
if stored_vcol ==# -1
|
||||
call s:Log(' End of clause directly preceeds LTI -> return')
|
||||
call s:Log(' End of clause directly precedes LTI -> return')
|
||||
return 0
|
||||
else
|
||||
call s:Log(' End of clause (but not end of line) -> return')
|
||||
|
||||
@@ -287,7 +287,7 @@ function! GetRubyIndent(...) abort
|
||||
\ ]
|
||||
|
||||
" Most Significant line based on the previous one -- in case it's a
|
||||
" contination of something above
|
||||
" continuation of something above
|
||||
let indent_info.plnum_msl = s:GetMSL(indent_info.plnum)
|
||||
|
||||
for callback_name in indent_callback_names
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user