summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-06-20 10:17:36 -0700
committerOri Bernstein <ori@eigenstate.org>2015-06-20 10:17:36 -0700
commit95034f67da8b6e6dca03868002ea2c56bad49b7c (patch)
tree0d80c5b7bd9e003caa14a2ae679e48e8b46b188a /support
parent7872641a685fc1498036dd0d6c2a4657e97a8e2e (diff)
downloadmc-95034f67da8b6e6dca03868002ea2c56bad49b7c.tar.gz
Fix up indent scripts.
Diffstat (limited to 'support')
-rw-r--r--support/vim/indent/myr.vim20
1 files changed, 14 insertions, 6 deletions
diff --git a/support/vim/indent/myr.vim b/support/vim/indent/myr.vim
index 2dbadfe..d20010a 100644
--- a/support/vim/indent/myr.vim
+++ b/support/vim/indent/myr.vim
@@ -65,8 +65,8 @@ function! GetMyrIndent(ln)
let inpat = ['\<if\>', '\<elif\>', '\<else\>',
\ '\<while\>','\<for\>', '\<match\>',
\ '\<struct\>', '\<union\>',
- \ '{', '\[', '(', '^\s*|', '=\s*$']
- let outpat = ['}', ']', '(', ';;']
+ \ '{', '\[', '(', '^\s*|.*:', '=\s*$']
+ let outpat = ['}', ']', ')', ';;']
let outalone = ['\<else\>', '\<elif\>.*', ';;', '|.*',
\ '].*', ').*', '}.*']
let width = &tabstop
@@ -78,17 +78,25 @@ function! GetMyrIndent(ln)
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 s:CountMatches(curln, ln, inpat) == 0 && s:LineMatch(prevln, outalone) != 0
- let n_out = n_out - 1
+ " we already outdented if we had an outalone
+ if s:LineMatch(prevln, outalone) != 0
+ let n_out = 0
endif
let n_out = n_out + s:LineMatch(curln, outalone)
- let ind = ind + (n_in - n_out) * &tabstop
+
+ let change = 0
+ if n_in - n_out > 0
+ let change = 1
+ elseif n_in - n_out < 0
+ let change = -1
+ endif
+ let ind = ind + change * &tabstop
endif
return ind
endfunction