diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2013-11-02 23:27:57 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2013-11-02 23:27:57 +0100 |
commit | 30c1920e4fa4e612238e1f435907c40ecfa47f33 (patch) | |
tree | f88ffb408895a5baf93fe81fdd12acba17f32d44 /indent/elixir.vim | |
parent | 57cfac7ae384466c3ff2543a9200319dc1d459a0 (diff) | |
download | vim-polyglot-1.4.1.tar.gz vim-polyglot-1.4.1.zip |
Massive update :)v1.4.1
Diffstat (limited to 'indent/elixir.vim')
-rw-r--r-- | indent/elixir.vim | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/indent/elixir.vim b/indent/elixir.vim index e4798141..a71c466c 100644 --- a/indent/elixir.vim +++ b/indent/elixir.vim @@ -25,6 +25,7 @@ let s:block_skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" . s:s let s:block_start = 'do\|fn' let s:block_middle = 'else\|match\|elsif\|catch\|after\|rescue' let s:block_end = 'end' +let s:pipeline = '^\s*|>.*$' let s:indent_keywords = '\<\%(' . s:block_start . '\|' . s:block_middle . '\)$' let s:deindent_keywords = '^\s*\<\%(' . s:block_end . '\|' . s:block_middle . '\)\>' @@ -38,7 +39,7 @@ function! GetElixirIndent(...) return 0 endif - if synIDattr(synID(v:lnum, 1, 1), "name") !~ '\(Comment\|String\)$' + if synIDattr(synID(v:lnum, 1, 1), "name") !~ s:skip_syntax let splited_line = split(getline(lnum), '\zs') let opened_symbol = 0 let opened_symbol += count(splited_line, '[') - count(splited_line, ']') @@ -51,6 +52,29 @@ function! GetElixirIndent(...) let ind += &sw endif + " if line starts with pipeline + " and last line doesn't start with pipeline + if getline(v:lnum) =~ s:pipeline && + \ getline(lnum) !~ s:pipeline + let ind += &sw + endif + + " if last line starts with pipeline + " and currentline doesn't start with pipeline + if getline(lnum) =~ s:pipeline && + \ getline(v:lnum) !~ s:pipeline + let ind -= &sw + endif + + " if last line starts with pipeline + " and current line doesn't start with pipeline + " but last line started a block + if getline(lnum) =~ s:pipeline && + \ getline(v:lnum) !~ s:pipeline && + \ getline(lnum) =~ s:block_start + let ind += &sw + endif + if getline(v:lnum) =~ s:deindent_keywords let bslnum = searchpair( '\<\%(' . s:block_start . '\):\@!\>', \ '\<\%(' . s:block_middle . '\):\@!\>\zs', |