From ad80283eec33af208d6bf24834809e351f54f90f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 4 Nov 2017 00:32:58 +1300 Subject: Add check and lint mappings for shell script The commands to use in this case are dependent on the particular shell being used. --- vim/ftplugin/sh.vim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'vim/ftplugin/sh.vim') diff --git a/vim/ftplugin/sh.vim b/vim/ftplugin/sh.vim index a6dd62eb..c09e4fe8 100644 --- a/vim/ftplugin/sh.vim +++ b/vim/ftplugin/sh.vim @@ -24,3 +24,25 @@ endif if exists('b:is_bash') && executable('han') setlocal keywordprg=han endif + +" Map checker based on shell family +if exists('b:is_bash') && b:is_bash + let b:check = 'bash -n' +elseif exists('b:is_ksh') && b:is_ksh + let b:check = 'ksh -n' +else + let b:check = 'sh -n' +endif +nnoremap c + \ :execute ':write !' . b:check + +" Map linter based on shell family +if exists('b:is_bash') && b:is_bash + let b:lint = 'shellcheck -s bash -' +elseif exists('b:is_ksh') && b:is_ksh + let b:lint = 'shellcheck -s ksh -' +else + let b:lint = 'shellcheck -s sh -' +endif +nnoremap l + \ :execute ':write !' . b:lint -- cgit v1.2.3