diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-04 00:32:58 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-04 00:39:33 +1300 |
commit | ad80283eec33af208d6bf24834809e351f54f90f (patch) | |
tree | c14916215ac65b3fc84ebbd0e78c3bf31921551e /vim/ftplugin | |
parent | Add tidy mapping for HTML (diff) | |
download | dotfiles-ad80283eec33af208d6bf24834809e351f54f90f.tar.gz dotfiles-ad80283eec33af208d6bf24834809e351f54f90f.zip |
Add check and lint mappings for shell script
The commands to use in this case are dependent on the particular shell
being used.
Diffstat (limited to 'vim/ftplugin')
-rw-r--r-- | vim/ftplugin/sh.vim | 22 |
1 files changed, 22 insertions, 0 deletions
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 <buffer> <silent> <LocalLeader>c + \ :<C-U>execute ':write !' . b:check<CR> + +" 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 <buffer> <silent> <LocalLeader>l + \ :<C-U>execute ':write !' . b:lint<CR> |