summaryrefslogtreecommitdiffstats
path: root/indent/eruby.vim
diff options
context:
space:
mode:
Diffstat (limited to 'indent/eruby.vim')
-rw-r--r--indent/eruby.vim21
1 files changed, 14 insertions, 7 deletions
diff --git a/indent/eruby.vim b/indent/eruby.vim
index 5f323857..5028fe06 100644
--- a/indent/eruby.vim
+++ b/indent/eruby.vim
@@ -42,6 +42,13 @@ if exists("*GetErubyIndent")
endif
function! GetErubyIndent(...)
+ " The value of a single shift-width
+ if exists('*shiftwidth')
+ let sw = shiftwidth()
+ else
+ let sw = &sw
+ endif
+
if a:0 && a:1 == '.'
let v:lnum = line('.')
elseif a:0 && a:1 =~ '^\d'
@@ -70,24 +77,24 @@ function! GetErubyIndent(...)
let line = getline(lnum)
let cline = getline(v:lnum)
if cline =~# '^\s*<%[-=]\=\s*\%(}\|end\|else\|\%(ensure\|rescue\|elsif\|when\).\{-\}\)\s*\%([-=]\=%>\|$\)'
- let ind = ind - &sw
+ let ind = ind - sw
endif
if line =~# '\S\s*<%[-=]\=\s*\%(}\|end\).\{-\}\s*\%([-=]\=%>\|$\)'
- let ind = ind - &sw
+ let ind = ind - sw
endif
if line =~# '\%({\|\<do\)\%(\s*|[^|]*|\)\=\s*[-=]\=%>'
- let ind = ind + &sw
+ let ind = ind + sw
elseif line =~# '<%[-=]\=\s*\%(module\|class\|def\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>'
- let ind = ind + &sw
+ let ind = ind + sw
endif
if line =~# '^\s*<%[=#-]\=\s*$' && cline !~# '^\s*end\>'
- let ind = ind + &sw
+ let ind = ind + sw
endif
if line !~# '^\s*<%' && line =~# '%>\s*$'
- let ind = ind - &sw
+ let ind = ind - sw
endif
if cline =~# '^\s*[-=]\=%>\s*$'
- let ind = ind - &sw
+ let ind = ind - sw
endif
return ind
endfunction