diff --git a/ale_linters/go/golint.vim b/ale_linters/go/golint.vim index d580fda2..4bf14fcc 100644 --- a/ale_linters/go/golint.vim +++ b/ale_linters/go/golint.vim @@ -1,10 +1,21 @@ " Author: neersighted " Description: golint for Go files +call ale#Set('go_golint_executable', 'golint') +call ale#Set('go_golint_options', '') + +function! ale_linters#go#golint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'go_golint_options') + + return '%e' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + call ale#linter#Define('go', { \ 'name': 'golint', \ 'output_stream': 'both', -\ 'executable': 'golint', -\ 'command': 'golint %t', +\ 'executable_callback': ale#VarFunc('go_golint_executable'), +\ 'command_callback': 'ale_linters#go#golint#GetCommand', \ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/doc/ale-go.txt b/doc/ale-go.txt index 17d9cb10..43289bd5 100644 --- a/doc/ale-go.txt +++ b/doc/ale-go.txt @@ -53,6 +53,25 @@ g:ale_go_gofmt_options *g:ale_go_gofmt_options* This variable can be set to pass additional options to the gofmt fixer. +=============================================================================== +golint *ale-go-golint* + +g:ale_go_golint_executable *g:ale_go_golint_executable* + *b:ale_go_golint_executable* + Type: |String| + Default: `'golint'` + + This variable can be set to change the golint executable path. + + +g:ale_go_golint_options *g:ale_go_golint_options* + *b:ale_go_golint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the golint linter. + + =============================================================================== govet *ale-go-govet* diff --git a/doc/ale.txt b/doc/ale.txt index 5da95930..39d9f580 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -108,6 +108,7 @@ CONTENTS *ale-contents* go....................................|ale-go-options| gobuild.............................|ale-go-gobuild| gofmt...............................|ale-go-gofmt| + golint..............................|ale-go-golint| govet...............................|ale-go-govet| gometalinter........................|ale-go-gometalinter| staticcheck.........................|ale-go-staticcheck| diff --git a/test/command_callback/test_golint_command_callbacks.vader b/test/command_callback/test_golint_command_callbacks.vader new file mode 100644 index 00000000..7c300309 --- /dev/null +++ b/test/command_callback/test_golint_command_callbacks.vader @@ -0,0 +1,18 @@ +Before: + call ale#assert#SetUpLinterTest('go', 'golint') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default golint command should be correct): + AssertLinter 'golint', ale#Escape('golint') . ' %t' + +Execute(The golint executable should be configurable): + let b:ale_go_golint_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') . ' %t' + +Execute(The golint options should be configurable): + let b:ale_go_golint_options = '--foo' + + AssertLinter 'golint', ale#Escape('golint') . ' --foo %t'