summaryrefslogtreecommitdiff
path: root/ale_linters/sh
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-04-07 14:58:06 +0100
committerw0rp <devw0rp@gmail.com>2019-04-07 14:58:06 +0100
commit3bebcb5d48a7150f5a318952ee309acb67fb376d (patch)
tree97edd84badca566894fd4c4f10c2a786df2fe079 /ale_linters/sh
parentcdf89f8269aec31d0dfddf3a2769027d72d38155 (diff)
downloadale-3bebcb5d48a7150f5a318952ee309acb67fb376d.zip
#2132 - Replace command_chain and chain_with with ale#command#Run
Diffstat (limited to 'ale_linters/sh')
-rw-r--r--ale_linters/sh/shellcheck.vim34
1 files changed, 10 insertions, 24 deletions
diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim
index bb7048cd..3920cab8 100644
--- a/ale_linters/sh/shellcheck.vim
+++ b/ale_linters/sh/shellcheck.vim
@@ -11,10 +11,6 @@ call ale#Set('sh_shellcheck_executable', 'shellcheck')
call ale#Set('sh_shellcheck_dialect', 'auto')
call ale#Set('sh_shellcheck_options', '')
-function! ale_linters#sh#shellcheck#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'sh_shellcheck_executable')
-endfunction
-
function! ale_linters#sh#shellcheck#GetDialectArgument(buffer) abort
let l:shell_type = ale#handlers#sh#GetShellType(a:buffer)
@@ -39,30 +35,18 @@ function! ale_linters#sh#shellcheck#GetDialectArgument(buffer) abort
return ''
endfunction
-function! ale_linters#sh#shellcheck#VersionCheck(buffer) abort
- let l:executable = ale_linters#sh#shellcheck#GetExecutable(a:buffer)
-
- " Don't check the version again if we've already cached it.
- return !ale#semver#HasVersion(l:executable)
- \ ? ale#Escape(l:executable) . ' --version'
- \ : ''
-endfunction
-
-function! ale_linters#sh#shellcheck#GetCommand(buffer, version_output) abort
- let l:executable = ale_linters#sh#shellcheck#GetExecutable(a:buffer)
- let l:version = ale#semver#GetVersion(l:executable, a:version_output)
-
+function! ale_linters#sh#shellcheck#GetCommand(buffer, version) abort
let l:options = ale#Var(a:buffer, 'sh_shellcheck_options')
let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions')
let l:dialect = ale#Var(a:buffer, 'sh_shellcheck_dialect')
- let l:external_option = ale#semver#GTE(l:version, [0, 4, 0]) ? ' -x' : ''
+ let l:external_option = ale#semver#GTE(a:version, [0, 4, 0]) ? ' -x' : ''
if l:dialect is# 'auto'
let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer)
endif
return ale#path#BufferCdString(a:buffer)
- \ . ale#Escape(l:executable)
+ \ . '%e'
\ . (!empty(l:dialect) ? ' -s ' . l:dialect : '')
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '')
@@ -108,10 +92,12 @@ endfunction
call ale#linter#Define('sh', {
\ 'name': 'shellcheck',
-\ 'executable': function('ale_linters#sh#shellcheck#GetExecutable'),
-\ 'command_chain': [
-\ {'callback': 'ale_linters#sh#shellcheck#VersionCheck'},
-\ {'callback': 'ale_linters#sh#shellcheck#GetCommand'},
-\ ],
+\ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')},
+\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
+\ buffer,
+\ ale#Var(buffer, 'sh_shellcheck_executable'),
+\ '%e --version',
+\ function('ale_linters#sh#shellcheck#GetCommand'),
+\ )},
\ 'callback': 'ale_linters#sh#shellcheck#Handle',
\})