diff options
Diffstat (limited to '')
-rw-r--r-- | indent/erlang.vim | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/indent/erlang.vim b/indent/erlang.vim index b1186ca8..64525bbd 100644 --- a/indent/erlang.vim +++ b/indent/erlang.vim @@ -6,9 +6,9 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'erlang') == -1 " Contributors: Edwin Fine <efine145_nospam01 at usa dot net> " Pawel 'kTT' Salata <rockplayer.pl@gmail.com> " Ricardo Catalinas Jiménez <jimenezrick@gmail.com> -" Last Update: 2013-Jul-21 +" Last Update: 2017-Feb-28 " License: Vim license -" URL: https://github.com/hcs42/vim-erlang +" URL: https://github.com/vim-erlang/vim-erlang-runtime " Note About Usage: " This indentation script works best with the Erlang syntax file created by @@ -528,7 +528,9 @@ endfunction " ok. % IsLineAtomContinuation = false function! s:IsLineAtomContinuation(lnum) if has('syntax_items') - return synIDattr(synID(a:lnum, 1, 0), 'name') =~# '^erlangQuotedAtom' + let syn_name = synIDattr(synID(a:lnum, 1, 0), 'name') + return syn_name =~# '^erlangQuotedAtom' || + \ syn_name =~# '^erlangQuotedRecord' else return 0 endif @@ -682,7 +684,7 @@ function! s:BeginningOfClauseFound(stack, token, stored_vcol, lnum, i) call s:Pop(a:stack) if empty(a:stack) call s:Log(' Stack is ["when"], so LTI is in a guard -> return') - return [1, a:stored_vcol + &sw + 2] + return [1, a:stored_vcol + shiftwidth() + 2] else return [1, s:UnexpectedToken(a:token, a:stack)] endif @@ -691,7 +693,7 @@ function! s:BeginningOfClauseFound(stack, token, stored_vcol, lnum, i) call s:Pop(a:stack) if empty(a:stack) call s:Log(' Stack is ["->"], so LTI is in function body -> return') - return [1, a:stored_vcol + &sw] + return [1, a:stored_vcol + shiftwidth()] elseif a:stack[0] ==# ';' call s:Pop(a:stack) @@ -843,7 +845,7 @@ function! s:ErlangCalcIndent2(lnum, stack) elseif token ==# 'begin' let [ret, res] = s:BeginElementFound(stack, token, curr_vcol, - \stored_vcol, 'end', &sw) + \stored_vcol, 'end', shiftwidth()) if ret | return res | endif " case EXPR of BRANCHES end @@ -894,11 +896,11 @@ function! s:ErlangCalcIndent2(lnum, stack) elseif stack == ['->'] call s:Log(' LTI is in a branch after ' . \'"of/receive/after/if/catch" -> return') - return stored_vcol + &sw + return stored_vcol + shiftwidth() elseif stack == ['when'] call s:Log(' LTI is in a guard after ' . \'"of/receive/after/if/catch" -> return') - return stored_vcol + &sw + return stored_vcol + shiftwidth() else return s:UnexpectedToken(token, stack) endif @@ -934,7 +936,7 @@ function! s:ErlangCalcIndent2(lnum, stack) if empty(stack) call s:Log(' LTI is in a condition; matching ' . \'"case/if/try/receive" found') - let stored_vcol = curr_vcol + &sw + let stored_vcol = curr_vcol + shiftwidth() elseif stack[0] ==# 'align_to_begin_element' call s:Pop(stack) let stored_vcol = curr_vcol @@ -943,23 +945,23 @@ function! s:ErlangCalcIndent2(lnum, stack) \'"case/if/try/receive" found') call s:Pop(stack) call s:Pop(stack) - let stored_vcol = curr_vcol + &sw + let stored_vcol = curr_vcol + shiftwidth() elseif stack[0] ==# '->' call s:Log(' LTI is in a branch; matching ' . \'"case/if/try/receive" found') call s:Pop(stack) - let stored_vcol = curr_vcol + 2 * &sw + let stored_vcol = curr_vcol + 2 * shiftwidth() elseif stack[0] ==# 'when' call s:Log(' LTI is in a guard; matching ' . \'"case/if/try/receive" found') call s:Pop(stack) - let stored_vcol = curr_vcol + 2 * &sw + 2 + let stored_vcol = curr_vcol + 2 * shiftwidth() + 2 endif endif let [ret, res] = s:BeginElementFound(stack, token, curr_vcol, - \stored_vcol, 'end', &sw) + \stored_vcol, 'end', shiftwidth()) if ret | return res | endif elseif token ==# 'fun' @@ -985,7 +987,7 @@ function! s:ErlangCalcIndent2(lnum, stack) " stack = ['when'] => LTI is in a guard if empty(stack) call s:Log(' LTI is in a condition; matching "fun" found') - let stored_vcol = curr_vcol + &sw + let stored_vcol = curr_vcol + shiftwidth() elseif len(stack) > 1 && stack[0] ==# '->' && stack[1] ==# ';' call s:Log(' LTI is in a condition; matching "fun" found') call s:Pop(stack) @@ -993,15 +995,15 @@ function! s:ErlangCalcIndent2(lnum, stack) elseif stack[0] ==# '->' call s:Log(' LTI is in a branch; matching "fun" found') call s:Pop(stack) - let stored_vcol = curr_vcol + 2 * &sw + let stored_vcol = curr_vcol + 2 * shiftwidth() elseif stack[0] ==# 'when' call s:Log(' LTI is in a guard; matching "fun" found') call s:Pop(stack) - let stored_vcol = curr_vcol + 2 * &sw + 2 + let stored_vcol = curr_vcol + 2 * shiftwidth() + 2 endif let [ret, res] = s:BeginElementFound(stack, token, curr_vcol, - \stored_vcol, 'end', &sw) + \stored_vcol, 'end', shiftwidth()) if ret | return res | endif else " Pass: we have a function reference (e.g. "fun f/0") @@ -1275,7 +1277,7 @@ function! s:ErlangCalcIndent2(lnum, stack) " when A, " LTI let [ret, res] = s:BeginElementFoundIfEmpty(stack, token, curr_vcol, - \stored_vcol, &sw) + \stored_vcol, shiftwidth()) if ret | return res | endif else " Example: @@ -1307,7 +1309,7 @@ function! s:ErlangCalcIndent2(lnum, stack) " If LTI is between an 'after' and the corresponding " 'end', then let's return let [ret, res] = s:BeginElementFoundIfEmpty(stack, token, curr_vcol, - \stored_vcol, &sw) + \stored_vcol, shiftwidth()) if ret | return res | endif endif |