summaryrefslogtreecommitdiffstats
path: root/indent
diff options
context:
space:
mode:
Diffstat (limited to 'indent')
-rw-r--r--indent/elixir.vim26
-rw-r--r--indent/html.vim42
-rw-r--r--indent/rust.vim19
3 files changed, 63 insertions, 24 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',
diff --git a/indent/html.vim b/indent/html.vim
index d5b7c837..466c6bd8 100644
--- a/indent/html.vim
+++ b/indent/html.vim
@@ -343,27 +343,27 @@ fun! HtmlIndentGet(lnum)
let lind = indent(lnum)
- for tags in s:omittable
- let tags_exp = '<\(' . join(tags, '\|') . '\)>'
- let close_tags_exp = '</\(' . join(tags, '\|') . '\)>'
- if getline(a:lnum) =~ tags_exp
- let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW')
- let prev_tag = search(tags_exp, 'bW', block_start)
- let prev_closetag = search(close_tags_exp, 'W', a:lnum)
- if prev_tag && !prev_closetag
- let ind = ind - 1
- endif
- endif
-
- if getline(a:lnum) =~ '</\w\+>'
- let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW')
- let prev_tag = search(tags_exp, 'bW', block_start)
- let prev_closetag = search(close_tags_exp, 'W', a:lnum)
- if prev_tag && !prev_closetag
- let ind = ind - 1
- endif
- endif
- endfor
+ " for tags in s:omittable
+ " let tags_exp = '<\(' . join(tags, '\|') . '\)>'
+ " let close_tags_exp = '</\(' . join(tags, '\|') . '\)>'
+ " if getline(a:lnum) =~ tags_exp
+ " let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW')
+ " let prev_tag = search(tags_exp, 'bW', block_start)
+ " let prev_closetag = search(close_tags_exp, 'W', a:lnum)
+ " if prev_tag && !prev_closetag
+ " let ind = ind - 1
+ " endif
+ " endif
+
+ " if getline(a:lnum) =~ '</\w\+>'
+ " let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW')
+ " let prev_tag = search(tags_exp, 'bW', block_start)
+ " let prev_closetag = search(close_tags_exp, 'W', a:lnum)
+ " if prev_tag && !prev_closetag
+ " let ind = ind - 1
+ " endif
+ " endif
+ " endfor
if restore_ic == 0
setlocal noic
diff --git a/indent/rust.vim b/indent/rust.vim
index ae3ca403..1f08c519 100644
--- a/indent/rust.vim
+++ b/indent/rust.vim
@@ -1,7 +1,7 @@
" Vim indent file
" Language: Rust
" Author: Chris Morgan <me@chrismorgan.info>
-" Last Change: 2013 Jul 10
+" Last Change: 2013 Oct 29
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
@@ -104,8 +104,23 @@ function GetRustIndent(lnum)
let prevline = s:get_line_trimmed(prevnonblank(a:lnum - 1))
if prevline[len(prevline) - 1] == ","
\ && s:get_line_trimmed(a:lnum) !~ "^\\s*[\\[\\]{}]"
+ \ && prevline !~ "^\\s*fn\\s"
" Oh ho! The previous line ended in a comma! I bet cindent will try to
- " take this too far... For now, let's use the previous line's indent
+ " take this too far... For now, let's normally use the previous line's
+ " indent.
+
+ " One case where this doesn't work out is where *this* line contains
+ " square or curly brackets; then we normally *do* want to be indenting
+ " further.
+ "
+ " Another case where we don't want to is one like a function
+ " definition with arguments spread over multiple lines:
+ "
+ " fn foo(baz: Baz,
+ " baz: Baz) // <-- cindent gets this right by itself
+ "
+ " There are probably other cases where we don't want to do this as
+ " well. Add them as needed.
return GetRustIndent(a:lnum - 1)
endif