summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-04-19 21:05:54 -0700
committerOri Bernstein <ori@eigenstate.org>2015-04-19 21:05:54 -0700
commitba22b4a713f78a66d8e6dd4abad3ce06db3c24c3 (patch)
tree032048652f9418388e6831d6409d4c43446e0451 /support
parent25fa643fa08fd1a2101fd961ce192d96db5ca017 (diff)
downloadmc-ba22b4a713f78a66d8e6dd4abad3ce06db3c24c3.tar.gz
Ignore indent/outdents inside strings.
Diffstat (limited to 'support')
-rw-r--r--support/vim/indent/myr.vim9
1 files changed, 5 insertions, 4 deletions
diff --git a/support/vim/indent/myr.vim b/support/vim/indent/myr.vim
index d0de51a..8c5d380 100644
--- a/support/vim/indent/myr.vim
+++ b/support/vim/indent/myr.vim
@@ -6,10 +6,11 @@ if exists("b:did_indent")
finish
endif
-function! InComment(lnum, col)
+function! Quoted(lnum, col)
let stk = synstack(a:lnum, a:col)
for id in stk
- if synIDattr(id, "name") == "myrComment"
+ let a = synIDattr(id, "name")
+ if a == "myrComment" || a == "myrString" || a == "myrChar"
return 1
endif
endfor
@@ -23,7 +24,7 @@ function! s:CountMatches(line, lnum, pats)
while idx >= 0
let idx = match(a:line, p, idx)
if idx >= 0
- let ic = InComment(a:lnum, idx)
+ let ic = Quoted(a:lnum, idx)
if !ic
let matches = matches + 1
echo "NOT IN COMMENT " ic " lnum " a:lnum " idx " idx
@@ -69,7 +70,7 @@ function! GetMyrIndent(ln)
\ '\<struct\>', '\<union\>',
\ '{', '^\s*|', '=\s*$']
let outpat = ['}', ';;']
- let outalone = ['\<else\>', '\<elif\>', '}', ';;', '|.*']
+ let outalone = ['\<else\>', '\<elif\>.*', '}', ';;', '|.*']
let width = &tabstop
let n_in = s:CountMatches(prevln, ln - i, inpat)