mirror of
https://github.com/dense-analysis/ale
synced 2024-12-22 14:13:12 +00:00
Fix #2054 - Make golint configurable
This commit is contained in:
parent
b96105bebb
commit
d1d5292178
@ -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',
|
||||
\})
|
||||
|
@ -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*
|
||||
|
||||
|
@ -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|
|
||||
|
18
test/command_callback/test_golint_command_callbacks.vader
Normal file
18
test/command_callback/test_golint_command_callbacks.vader
Normal 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'
|
Loading…
Reference in New Issue
Block a user