summaryrefslogtreecommitdiffstats
path: root/indent/elixir.vim
diff options
context:
space:
mode:
Diffstat (limited to 'indent/elixir.vim')
-rw-r--r--indent/elixir.vim26
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',