From 2124e9c94c3bf12382ef18c811df5cecdb6bbcd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=90=B1?= <88maomao@gmail.com> Date: Mon, 5 Feb 2018 14:05:16 +0000 Subject: [PATCH] Respect comma first style Make following formatting style possible -export([ respect/1 , first/2 , comma/3]). --- indent/erlang.vim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/indent/erlang.vim b/indent/erlang.vim index 67cd1b4..c16c75a 100644 --- a/indent/erlang.vim +++ b/indent/erlang.vim @@ -653,6 +653,8 @@ function! s:BeginElementFound(stack, token, curr_vcol, stored_vcol, end_token, s else return [0, 0] endif + elseif a:stack == ['first_comma'] + return [1, a:curr_vcol] else return [1, s:UnexpectedToken(a:token, a:stack)] endif @@ -1024,7 +1026,7 @@ function! s:ErlangCalcIndent2(lnum, stack) let end_token = (token ==# '(' ? ')' : \token ==# '{' ? '}' : 'error') - if empty(stack) + if empty(stack) || stack == ['first_comma'] " We found the opening paren whose block contains the LTI. let mode = 'inside' elseif stack[0] ==# end_token @@ -1095,6 +1097,10 @@ function! s:ErlangCalcIndent2(lnum, stack) call s:Log(' "' . token . '" token (whose closing token ' . \'starts LTI) found -> return') return curr_vcol + elseif stored_vcol ==# -1 && stack == ['first_comma'] + call s:Log(' "' . token . '" token (which directly ' . + \'precedes LTI with first_comma) found -> return') + return curr_vcol elseif stored_vcol ==# -1 " Examples: {{{ " @@ -1438,6 +1444,9 @@ function! ErlangIndent() let new_col = s:ErlangCalcIndent(v:lnum - 1, \[ml[2], 'align_to_begin_element']) endif + elseif currline =~# '^\s*,' + call s:Log(" Line type = 'first comma'") + let new_col = s:ErlangCalcIndent(v:lnum - 1, ['first_comma']) else call s:Log(" Line type = 'normal'")