From 9a2b4f5cd8bcb03f1344fa9f81b59efb84a91889 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 24 Jan 2014 18:06:22 +0100 Subject: Update --- indent/elixir.vim | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'indent') diff --git a/indent/elixir.vim b/indent/elixir.vim index 01303c21..c89f5887 100644 --- a/indent/elixir.vim +++ b/indent/elixir.vim @@ -10,7 +10,7 @@ let b:did_indent = 1 setlocal nosmartindent -setlocal indentexpr=GetElixirIndent(v:lnum) +setlocal indentexpr=GetElixirIndent() setlocal indentkeys+==end,=else:,=match:,=elsif:,=catch:,=after:,=rescue: if exists("*GetElixirIndent") @@ -31,7 +31,7 @@ let s:pipeline = '^\s*|>.*$' let s:indent_keywords = '\<\%(' . s:block_start . '\|' . s:block_middle . '\)$' . '\|' . s:arrow let s:deindent_keywords = '^\s*\<\%(' . s:block_end . '\|' . s:block_middle . '\)\>' . '\|' . s:arrow -function! GetElixirIndent(...) +function! GetElixirIndent() let lnum = prevnonblank(v:lnum - 1) let ind = indent(lnum) @@ -40,6 +40,14 @@ function! GetElixirIndent(...) return 0 endif + " TODO: Remove these 2 lines + " I don't know why, but for the test on spec/indent/lists_spec.rb:24. + " Vim is making some mess on parsing the syntax of 'end', it is being + " recognized as 'elixirString' when should be recognized as 'elixirBlock'. + " This forces vim to sync the syntax. + call synID(v:lnum, 1, 1) + syntax sync fromstart + if synIDattr(synID(v:lnum, 1, 1), "name") !~ s:skip_syntax let current_line = getline(v:lnum) let last_line = getline(lnum) @@ -61,7 +69,7 @@ function! GetElixirIndent(...) if current_line =~ s:pipeline && \ last_line =~ '^[^=]\+=.\+$' let b:old_ind = ind - let ind += round(match(last_line, '=') / &sw) * &sw + let ind = float2nr(matchend(last_line, '=\s*[^ ]') / &sw) * &sw endif " if last line starts with pipeline @@ -78,6 +86,7 @@ function! GetElixirIndent(...) \ '\<:\@\zs', \ 'nbW', \ s:block_skip ) + let ind = indent(bslnum) endif -- cgit v1.2.3