summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2017-04-11 09:26:58 +0100
committerGitHub <noreply@github.com>2017-04-11 09:26:58 +0100
commit8b890caa31411cd022156dca8e4c7f4c5fb65fc9 (patch)
tree8a58c4598c4c34891f2b8b35c8a121936c5ffdf6
parent5aa52fc4502f96e333e125bcab58f1dfd4228643 (diff)
parent8e33abaeab5a7e796f46a8a5107eba18f7c20987 (diff)
downloadale-8b890caa31411cd022156dca8e4c7f4c5fb65fc9.zip
Merge pull request #458 from Szero/master
Added shellcheck executable and options variable
-rw-r--r--ale_linters/sh/shellcheck.vim16
-rw-r--r--doc/ale-sh.txt23
2 files changed, 37 insertions, 2 deletions
diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim
index 735a0cd3..bb556460 100644
--- a/ale_linters/sh/shellcheck.vim
+++ b/ale_linters/sh/shellcheck.vim
@@ -10,6 +10,16 @@ if !exists('g:ale_linters_sh_shellcheck_exclusions')
let g:ale_linters_sh_shellcheck_exclusions = ''
endif
+let g:ale_sh_shellcheck_executable =
+\ get(g:, 'ale_sh_shellcheck_executable', 'shellcheck')
+
+let g:ale_sh_shellcheck_options =
+\ get(g:, 'ale_sh_shellcheck_options', '')
+
+function! ale_linters#sh#shellcheck#GetExecutable(buffer) abort
+ return g:ale_sh_shellcheck_executable
+endfunction
+
if g:ale_linters_sh_shellcheck_exclusions !=# ''
let s:exclude_option = '-e ' . g:ale_linters_sh_shellcheck_exclusions
else
@@ -29,12 +39,14 @@ function! s:GetDialectArgument() abort
endfunction
function! ale_linters#sh#shellcheck#GetCommand(buffer) abort
- return 'shellcheck ' . s:exclude_option . ' ' . s:GetDialectArgument() . ' -f gcc -'
+ return ale_linters#sh#shellcheck#GetExecutable(a:buffer)
+ \ . ' ' . g:ale_sh_shellcheck_options
+ \ . ' ' . s:exclude_option . ' ' . s:GetDialectArgument() . ' -f gcc -'
endfunction
call ale#linter#Define('sh', {
\ 'name': 'shellcheck',
-\ 'executable': 'shellcheck',
+\ 'executable_callback': 'ale_linters#sh#shellcheck#GetExecutable',
\ 'command_callback': 'ale_linters#sh#shellcheck#GetCommand',
\ 'callback': 'ale#handlers#HandleGCCFormat',
\})
diff --git a/doc/ale-sh.txt b/doc/ale-sh.txt
index aee13912..a7f7800e 100644
--- a/doc/ale-sh.txt
+++ b/doc/ale-sh.txt
@@ -19,12 +19,35 @@ g:ale_linters_sh_shell_default_shell *g:ale_linters_sh_shell_default_shell*
-------------------------------------------------------------------------------
shellcheck *ale-sh-shellcheck*
+g:ale_sh_shellcheck_executable *g:ale_sh_shellcheck_executable*
+
+ Type: |String|
+ Default: `'shellcheck'`
+
+ This variable sets executable used for shellcheck.
+
+
+g:ale_sh_shellcheck_options *g:ale_sh_shellcheck_options*
+
+ Type: |String|
+ Default: `''`
+
+ With this variable we are able to pass extra arguments for shellcheck
+ for shellcheck invocation.
+
+ For example, if we want shellcheck to follow external sources (`see SC1091`)
+ we can set the variable as such:
+
+ let g:ale_sh_shellcheck_options = '-x'
+
+
g:ale_linters_sh_shellcheck_exclusions *g:ale_linters_sh_shellcheck_exclusions*
Type: |String|
Default: `''`
Set this variable to exclude test(s) for shellcheck (-e/--exclude option).
+ To exclude more than one option, separate them with commas.
-------------------------------------------------------------------------------