diff --git a/ale_linters/yaml/actionlint.vim b/ale_linters/yaml/actionlint.vim index e51cf5f0..1e2fda49 100644 --- a/ale_linters/yaml/actionlint.vim +++ b/ale_linters/yaml/actionlint.vim @@ -1,6 +1,7 @@ " Author: bretello call ale#Set('yaml_actionlint_executable', 'actionlint') +call ale#Set('yaml_actionlint_options', '') call ale#linter#Define('yaml', { \ 'name': 'actionlint', diff --git a/autoload/ale/handlers/actionlint.vim b/autoload/ale/handlers/actionlint.vim index 9a6f1909..73843c08 100644 --- a/autoload/ale/handlers/actionlint.vim +++ b/autoload/ale/handlers/actionlint.vim @@ -1,5 +1,17 @@ function! ale#handlers#actionlint#GetCommand(buffer) abort - return '%e --no-color --oneline %t' + let l:options = ale#Var(a:buffer, 'yaml_actionlint_options') + + " automatically add --no-color option if not defined + if l:options !~# '--no-color' + let l:options .= ' --no-color' + endif + + " automatically add --oneline option if not defined + if l:options !~# '--oneline' + let l:options .= ' --oneline' + endif + + return '%e ' . l:options . ' %t' endfunction function! ale#handlers#actionlint#Handle(buffer, lines) abort diff --git a/doc/ale-yaml.txt b/doc/ale-yaml.txt index 8d44973d..9733990e 100644 --- a/doc/ale-yaml.txt +++ b/doc/ale-yaml.txt @@ -32,6 +32,20 @@ g:ale_yaml_actionlint_executable *g:ale_yaml_actionlint_executable* This variable can be set to change the path to actionlint. +g:ale_yaml_actionlint_options *g:ale_yaml_actionlint_options* + *b:ale_yaml_actionlint_options* + + Type: |String| + Default: `''` + + This variable can be set to add extra options to actionlint executable. + + For example, to disable running `shellcheck` and `pyflakes` external commands, + you may want to set: +> + let g:ale_yaml_actionlint_options = '-shellcheck= -pyflakes=' +< + Please note that passing `-format` as option is not supported at the moment. =============================================================================== circleci *ale-yaml-circleci* diff --git a/test/handler/test_actionlint_handler.vader b/test/handler/test_actionlint_handler.vader index 557cff02..3e762129 100644 --- a/test/handler/test_actionlint_handler.vader +++ b/test/handler/test_actionlint_handler.vader @@ -2,6 +2,7 @@ Before: runtime! ale/handlers/actionlint.vim After: + unlet! g:ale_yaml_actionlint_options call ale#linter#Reset() Execute(Problems should be parsed correctly for actionlint): @@ -26,3 +27,17 @@ Execute(Problems should be parsed correctly for actionlint): \ '.codecov.yaml:2:1: "jobs" section is missing in workflow [syntax-check]', \ 'workflow_call_event.yaml:56:23: property "unknown_input" is not defined in object type {input7: bool; input0: any; input1: any; input2: string; input3: any; input4: any; input5: number; input6: number} [expression]', \ ]) + +Execute(Command should always have --no-color and --oneline options): + let g:ale_yaml_actionlint_options = '' + + AssertEqual + \ '%e --no-color --oneline %t', + \ ale#handlers#actionlint#GetCommand(bufnr('')) + +Execute(Options should be added to command): + let g:ale_yaml_actionlint_options = '-shellcheck= -pyflakes=' + + AssertEqual + \ '%e -shellcheck= -pyflakes= --no-color --oneline %t', + \ ale#handlers#actionlint#GetCommand(bufnr(''))