From 4753e32c302abd2bf909269a13b7d9ef5e742303 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 10 Oct 2019 16:57:08 +0200 Subject: [PATCH] [ADD][VIM] Shellcheck options for ALE I want shellcheck to detect which shell is most appropriate on the `sh` filetype, but explicitly use the `bash` dialect on `bash` and `zsh` filetypes. I also really don't like nullary conditions in shell, so I'll screen for those too. I might turn on the 'quote-safe-variables' check too, because I think quoting variables is a good habit to take. --- vim/.vim/ftplugin/bash.vim | 6 ++++++ vim/.vim/ftplugin/sh.vim | 6 ++++++ vim/.vim/ftplugin/zsh.vim | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/vim/.vim/ftplugin/bash.vim b/vim/.vim/ftplugin/bash.vim index 1fb8b26..c69fa31 100644 --- a/vim/.vim/ftplugin/bash.vim +++ b/vim/.vim/ftplugin/bash.vim @@ -1,2 +1,8 @@ " Use shfmt as ALE fixer for bash let b:ale_fixers=[ 'shfmt' ] + +" Indent with 4 spaces, simplify script, indent switch cases, use Bash variant +let b:ale_sh_shfmt_options='-i 4 -s -ci -ln bash' + +" Use bash dialect explicitly, require explicit empty string test +let b:ale_sh_shellcheck_options='-s bash -o avoid-nullary-conditions' diff --git a/vim/.vim/ftplugin/sh.vim b/vim/.vim/ftplugin/sh.vim index 8ea4807..f4e1bf1 100644 --- a/vim/.vim/ftplugin/sh.vim +++ b/vim/.vim/ftplugin/sh.vim @@ -1,2 +1,8 @@ " Use shfmt as ALE fixer for sh let b:ale_fixers=[ 'shfmt' ] + +" Indent with 4 spaces, simplify the code, indent switch cases, use POSIX +let b:ale_sh_shfmt_options='-i 4 -s -ci -ln posix' + +" Require explicit empty string test +let b:ale_sh_shellcheck_options='-o avoid-nullary-conditions' diff --git a/vim/.vim/ftplugin/zsh.vim b/vim/.vim/ftplugin/zsh.vim index 1685f86..20233e4 100644 --- a/vim/.vim/ftplugin/zsh.vim +++ b/vim/.vim/ftplugin/zsh.vim @@ -1,2 +1,8 @@ " Use shfmt as ALE fixer for zsh let b:ale_fixers=[ 'shfmt' ] + +" Indent with 4 spaces, simplify script, indent switch cases, use Bash variant +let b:ale_sh_shfmt_options='-i 4 -s -ci -ln bash' + +" Use bash dialect explicitly, require explicit empty string test +let b:ale_sh_shellcheck_options='-s bash -o avoid-nullary-conditions'