summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-05-04 00:47:14 -0700
committerOri Bernstein <ori@eigenstate.org>2015-05-04 00:47:14 -0700
commit3b9796f80b335ea4c2f152988715e6069effdc88 (patch)
tree1a5089791613c3ebdf3b4b3eae0c3b2b68cd044e /support
parent238bffb3afa386dea2980944271d28ec6d4d866c (diff)
downloadmc-3b9796f80b335ea4c2f152988715e6069effdc88.tar.gz
Add support for escaped line endings in vim indent script.
Diffstat (limited to 'support')
-rw-r--r--support/vim/indent/myr.vim27
1 files changed, 19 insertions, 8 deletions
diff --git a/support/vim/indent/myr.vim b/support/vim/indent/myr.vim
index 51bf4a6..d53111c 100644
--- a/support/vim/indent/myr.vim
+++ b/support/vim/indent/myr.vim
@@ -65,19 +65,30 @@ function! GetMyrIndent(ln)
let inpat = ['\<if\>', '\<elif\>', '\<else\>',
\ '\<while\>','\<for\>', '\<match\>',
\ '\<struct\>', '\<union\>',
- \ '{', '\[', '^\s*|', '=\s*$']
- let outpat = ['}', ']', ';;']
- let outalone = ['\<else\>', '\<elif\>.*', '}.*', '^\s*].*', ';;', '|.*']
+ \ '{', '\[', '(', '^\s*|', '=\s*$']
+ let outpat = ['}', ']', '(', ';;']
+ let outalone = ['\<else\>', '\<elif\>.*',
+ \ '}.*', '].*', ').*', ';;', '|.*']
let width = &tabstop
let n_in = s:CountMatches(prevln, ln - i, inpat)
let n_out = s:CountMatches(prevln, ln - i, outpat)
- if s:LineMatch(curln, outalone) != 0
- let ind = ind + (n_in - n_out - 1) * &tabstop
- " avoid double-counting outdents from outalones.
- elseif s:LineMatch(prevln, outpat) == 0
- let ind = ind + (n_in - n_out) * &tabstop
+
+ " indent escaped line endings
+ if prevln =~ '\\\s*$' && getline(ln - i - 1) !~ '\\\s*$'
+ let n_in = n_in + 1
+ endif
+ " if we break the set of indented line endings, outdent
+ if getline(ln - i - 1) =~ '\\\s*$' && getline(ln - i) !~ '\\\s*$'
+ let n_out = n_out + 1
+ endif
+
+ " avoid double counting outdents that are also outalone
+ if n_out > 0 && s:LineMatch(prevln, outalone) != 0
+ let n_out = n_out - 1
endif
+ let n_out = n_out + s:LineMatch(curln, outalone)
+ let ind = ind + (n_in - n_out) * &tabstop
endif
return ind
endfunction