mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-18 18:25:57 +08:00
Fix #2054 - Make golint configurable
This commit is contained in:
@@ -1,10 +1,21 @@
|
|||||||
" Author: neersighted <bjorn@neersighted.com>
|
" Author: neersighted <bjorn@neersighted.com>
|
||||||
" Description: golint for Go files
|
" 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', {
|
call ale#linter#Define('go', {
|
||||||
\ 'name': 'golint',
|
\ 'name': 'golint',
|
||||||
\ 'output_stream': 'both',
|
\ 'output_stream': 'both',
|
||||||
\ 'executable': 'golint',
|
\ 'executable_callback': ale#VarFunc('go_golint_executable'),
|
||||||
\ 'command': 'golint %t',
|
\ 'command_callback': 'ale_linters#go#golint#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ '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.
|
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*
|
govet *ale-go-govet*
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ CONTENTS *ale-contents*
|
|||||||
go....................................|ale-go-options|
|
go....................................|ale-go-options|
|
||||||
gobuild.............................|ale-go-gobuild|
|
gobuild.............................|ale-go-gobuild|
|
||||||
gofmt...............................|ale-go-gofmt|
|
gofmt...............................|ale-go-gofmt|
|
||||||
|
golint..............................|ale-go-golint|
|
||||||
govet...............................|ale-go-govet|
|
govet...............................|ale-go-govet|
|
||||||
gometalinter........................|ale-go-gometalinter|
|
gometalinter........................|ale-go-gometalinter|
|
||||||
staticcheck.........................|ale-go-staticcheck|
|
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'
|
||||||
Reference in New Issue
Block a user