From 477ad3fdd2df80a9dc479f974caeca1aa6ae640b Mon Sep 17 00:00:00 2001 From: Guangqing Chen Date: Thu, 8 Sep 2022 16:04:17 +0800 Subject: Allow to pass options to the buf linter and fix callback. (#4300) * Allow to pass options to the buf linter * Fix the callback of buf linter --- ale_linters/proto/buf_lint.vim | 5 ++++- test/linter/test_buf_lint.vader | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ale_linters/proto/buf_lint.vim b/ale_linters/proto/buf_lint.vim index e68494a7..a22f8e53 100644 --- a/ale_linters/proto/buf_lint.vim +++ b/ale_linters/proto/buf_lint.vim @@ -3,12 +3,15 @@ call ale#Set('proto_buf_lint_executable', 'buf') call ale#Set('proto_buf_lint_config', '') +call ale#Set('proto_buf_lint_options', '') function! ale_linters#proto#buf_lint#GetCommand(buffer) abort let l:config = ale#Var(a:buffer, 'proto_buf_lint_config') + let l:options = ale#Var(a:buffer, 'proto_buf_lint_options') return '%e lint' \ . (!empty(l:config) ? ' --config=' . ale#Escape(l:config) : '') + \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' %s#include_package_files=true' endfunction @@ -19,5 +22,5 @@ call ale#linter#Define('proto', { \ 'output_stream': 'stdout', \ 'executable': {b -> ale#Var(b, 'proto_buf_lint_executable')}, \ 'command': function('ale_linters#proto#buf_lint#GetCommand'), -\ 'callback': 'ale#handlers#unix#HandleAsError', +\ 'callback': 'ale#handlers#go#Handler', \}) diff --git a/test/linter/test_buf_lint.vader b/test/linter/test_buf_lint.vader index 7b8bb52c..2f065adc 100644 --- a/test/linter/test_buf_lint.vader +++ b/test/linter/test_buf_lint.vader @@ -11,7 +11,7 @@ Execute(The default command should be correct): \ . ' lint' \ . ' %s#include_package_files=true' -Execute(The callback should include any additional options): +Execute(The callback should include any additional config): let b:ale_proto_buf_lint_executable = '/tmp/buf' let b:ale_proto_buf_lint_config = '/tmp/buf.yaml' @@ -20,3 +20,13 @@ Execute(The callback should include any additional options): \ . ' lint' \ . ' --config=' . ale#Escape('/tmp/buf.yaml') \ . ' %s#include_package_files=true' + +Execute(The callback should include additional options): + let b:ale_proto_buf_lint_executable = '/tmp/buf' + let b:ale_proto_buf_lint_options = '--disable-symlinks' + + AssertLinter '/tmp/buf', + \ ale#Escape('/tmp/buf') + \ . ' lint' + \ . ' --disable-symlinks' + \ . ' %s#include_package_files=true' -- cgit v1.2.3