Fix #2054 - Make golint configurable

This commit is contained in:
w0rp 2018-11-11 09:42:57 +00:00
parent b96105bebb
commit d1d5292178
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
4 changed files with 51 additions and 2 deletions

View File

@ -1,10 +1,21 @@
" Author: neersighted <bjorn@neersighted.com>
" 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',
\})

View File

@ -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*

View File

@ -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|

View File

@ -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'