vim-sh-indent
vim-sh-indent copied to clipboard
flag to disable unindenting end-block keywords
I would appreciate a flag that disables automatic unindenting of end-block keywords (fi, esac, done, end) that I could set in my vimrc.
Workaround question: is it possible to somehow disable that functionality in the current versions of vim, eg using an "after" file?
(I've been reading through the syntax file for a while but it's just over my head how to do this correctly without introducing new bugs)
I haven't tested it, but does this work for you:
diff --git a/indent/sh.vim b/indent/sh.vim
index ae0a45f..846535e 100644
--- a/indent/sh.vim
+++ b/indent/sh.vim
@@ -302,7 +302,6 @@ function! s:end_block(line)
endfunction
function! s:start_block(line)
-# return a:line =~ '{\s*\(#.*\)\?$'
return a:line =~ '^[^#]*[{(]\s*\(#.*\)\?$'
endfunction
@@ -311,6 +310,9 @@ function! s:is_comment(line)
endfunction
function! s:is_end_expression(line)
+ if s:indent_value('end-expression') == 0
+ return 0
+ endif
return a:line =~ '\<\%(fi\|esac\|done\|end\)\>\s*\%(#.*\)\=$'
endfunction
You need to set :let b:sh_indent_options['end-expression']=0