vim-sh-indent icon indicating copy to clipboard operation
vim-sh-indent copied to clipboard

flag to disable unindenting end-block keywords

Open cheater opened this issue 1 year ago • 2 comments

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?

cheater avatar Sep 19 '24 17:09 cheater

(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)

cheater avatar Sep 19 '24 17:09 cheater

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

chrisbra avatar Sep 20 '24 21:09 chrisbra