diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2014-01-24 18:06:22 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2014-01-24 18:06:22 +0100 |
commit | 9a2b4f5cd8bcb03f1344fa9f81b59efb84a91889 (patch) | |
tree | 31d8265fcf38ee6f12f3f763acf409fdde03817d /indent/elixir.vim | |
parent | f211f02d1e53dbb4eada17e999eba81bccaf1fb2 (diff) | |
download | vim-polyglot-1.5.1.tar.gz vim-polyglot-1.5.1.zip |
Updatev1.5.1
Diffstat (limited to 'indent/elixir.vim')
-rw-r--r-- | indent/elixir.vim | 15 |
1 files changed, 12 insertions, 3 deletions
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(...) \ '\<:\@<!' . s:block_end . '\>\zs', \ 'nbW', \ s:block_skip ) + let ind = indent(bslnum) endif |