summaryrefslogtreecommitdiff
path: root/ale_linters/go
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/go')
-rw-r--r--ale_linters/go/gobuild.vim4
-rw-r--r--ale_linters/go/golangci_lint.vim7
-rw-r--r--ale_linters/go/gometalinter.vim7
-rw-r--r--ale_linters/go/gosimple.vim8
-rw-r--r--ale_linters/go/gotype.vim12
-rw-r--r--ale_linters/go/govet.vim4
-rw-r--r--ale_linters/go/staticcheck.vim12
7 files changed, 24 insertions, 30 deletions
diff --git a/ale_linters/go/gobuild.vim b/ale_linters/go/gobuild.vim
index 1dfb6daa..5210c5a8 100644
--- a/ale_linters/go/gobuild.vim
+++ b/ale_linters/go/gobuild.vim
@@ -10,8 +10,7 @@ function! ale_linters#go#gobuild#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'go_gobuild_options')
" Run go test in local directory with relative path
- return ale#path#BufferCdString(a:buffer)
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . ale#Var(a:buffer, 'go_go_executable') . ' test'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' -c -o /dev/null ./'
@@ -50,6 +49,7 @@ call ale#linter#Define('go', {
\ 'name': 'gobuild',
\ 'aliases': ['go build'],
\ 'executable': {b -> ale#Var(b, 'go_go_executable')},
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#gobuild#GetCommand'),
\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#go#gobuild#Handler',
diff --git a/ale_linters/go/golangci_lint.vim b/ale_linters/go/golangci_lint.vim
index dd0e975a..2c4b1a4f 100644
--- a/ale_linters/go/golangci_lint.vim
+++ b/ale_linters/go/golangci_lint.vim
@@ -12,14 +12,12 @@ function! ale_linters#go#golangci_lint#GetCommand(buffer) abort
if l:lint_package
- return ale#path#BufferCdString(a:buffer)
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . '%e run '
\ . l:options
endif
- return ale#path#BufferCdString(a:buffer)
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . '%e run '
\ . ale#Escape(l:filename)
\ . ' ' . l:options
@@ -53,6 +51,7 @@ endfunction
call ale#linter#Define('go', {
\ 'name': 'golangci-lint',
\ 'executable': {b -> ale#Var(b, 'go_golangci_lint_executable')},
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#golangci_lint#GetCommand'),
\ 'callback': 'ale_linters#go#golangci_lint#Handler',
\ 'lint_file': 1,
diff --git a/ale_linters/go/gometalinter.vim b/ale_linters/go/gometalinter.vim
index eed9550a..ac33a9f3 100644
--- a/ale_linters/go/gometalinter.vim
+++ b/ale_linters/go/gometalinter.vim
@@ -13,14 +13,12 @@ function! ale_linters#go#gometalinter#GetCommand(buffer) abort
" BufferCdString is used so that we can be sure the paths output from gometalinter can
" be calculated to absolute paths in the Handler
if l:lint_package
- return ale#path#BufferCdString(a:buffer)
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . '%e'
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endif
- return ale#path#BufferCdString(a:buffer)
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . '%e'
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename))
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
@@ -53,6 +51,7 @@ endfunction
call ale#linter#Define('go', {
\ 'name': 'gometalinter',
\ 'executable': {b -> ale#Var(b, 'go_gometalinter_executable')},
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#gometalinter#GetCommand'),
\ 'callback': 'ale_linters#go#gometalinter#Handler',
\ 'lint_file': 1,
diff --git a/ale_linters/go/gosimple.vim b/ale_linters/go/gosimple.vim
index ad52c621..490d15a9 100644
--- a/ale_linters/go/gosimple.vim
+++ b/ale_linters/go/gosimple.vim
@@ -1,15 +1,11 @@
" Author: Ben Reedy <https://github.com/breed808>
" Description: gosimple for Go files
-function! ale_linters#go#gosimple#GetCommand(buffer) abort
- return ale#path#BufferCdString(a:buffer) . ' '
- \ . ale#go#EnvString(a:buffer) . 'gosimple .'
-endfunction
-
call ale#linter#Define('go', {
\ 'name': 'gosimple',
\ 'executable': 'gosimple',
-\ 'command': function('ale_linters#go#gosimple#GetCommand'),
+\ 'cwd': '%s:h',
+\ 'command': {b -> ale#go#EnvString(b) . 'gosimple .'},
\ 'callback': 'ale#handlers#go#Handler',
\ 'output_stream': 'both',
\ 'lint_file': 1,
diff --git a/ale_linters/go/gotype.vim b/ale_linters/go/gotype.vim
index 6a5149ca..8fd6df27 100644
--- a/ale_linters/go/gotype.vim
+++ b/ale_linters/go/gotype.vim
@@ -1,19 +1,23 @@
" Author: Jelte Fennema <github-public@jeltef.nl>
" Description: gotype for Go files
-function! ale_linters#go#gotype#GetCommand(buffer) abort
+function! ale_linters#go#gotype#GetExecutable(buffer) abort
if expand('#' . a:buffer . ':p') =~# '_test\.go$'
return ''
endif
- return ale#path#BufferCdString(a:buffer) . ' '
- \ . ale#go#EnvString(a:buffer) . 'gotype -e .'
+ return 'gotype'
+endfunction
+
+function! ale_linters#go#gotype#GetCommand(buffer) abort
+ return ale#go#EnvString(a:buffer) . 'gotype -e .'
endfunction
call ale#linter#Define('go', {
\ 'name': 'gotype',
\ 'output_stream': 'stderr',
-\ 'executable': 'gotype',
+\ 'executable': function('ale_linters#go#gotype#GetExecutable'),
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#gotype#GetCommand'),
\ 'callback': 'ale#handlers#go#Handler',
\ 'lint_file': 1,
diff --git a/ale_linters/go/govet.vim b/ale_linters/go/govet.vim
index dddafe17..5da8261c 100644
--- a/ale_linters/go/govet.vim
+++ b/ale_linters/go/govet.vim
@@ -10,8 +10,7 @@ call ale#Set('go_govet_options', '')
function! ale_linters#go#govet#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'go_govet_options')
- return ale#path#BufferCdString(a:buffer) . ' '
- \ . ale#go#EnvString(a:buffer)
+ return ale#go#EnvString(a:buffer)
\ . ale#Var(a:buffer, 'go_go_executable') . ' vet '
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' .'
@@ -22,6 +21,7 @@ call ale#linter#Define('go', {
\ 'aliases': ['go vet'],
\ 'output_stream': 'stderr',
\ 'executable': {b -> ale#Var(b, 'go_go_executable')},
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#govet#GetCommand'),
\ 'callback': 'ale#handlers#go#Handler',
\ 'lint_file': 1,
diff --git a/ale_linters/go/staticcheck.vim b/ale_linters/go/staticcheck.vim
index ed40c6c2..84e70d58 100644
--- a/ale_linters/go/staticcheck.vim
+++ b/ale_linters/go/staticcheck.vim
@@ -5,28 +5,24 @@ call ale#Set('go_staticcheck_options', '')
call ale#Set('go_staticcheck_lint_package', 0)
function! ale_linters#go#staticcheck#GetCommand(buffer) abort
- let l:filename = expand('#' . a:buffer . ':t')
let l:options = ale#Var(a:buffer, 'go_staticcheck_options')
let l:lint_package = ale#Var(a:buffer, 'go_staticcheck_lint_package')
let l:env = ale#go#EnvString(a:buffer)
- " BufferCdString is used so that we can be sure the paths output from
- " staticcheck can be calculated to absolute paths in the Handler
if l:lint_package
- return ale#path#BufferCdString(a:buffer)
- \ . l:env . 'staticcheck'
+ return l:env . 'staticcheck'
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endif
- return ale#path#BufferCdString(a:buffer)
- \ . l:env . 'staticcheck'
+ return l:env . 'staticcheck'
\ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' ' . ale#Escape(l:filename)
+ \ . ' %s:t'
endfunction
call ale#linter#Define('go', {
\ 'name': 'staticcheck',
\ 'executable': 'staticcheck',
+\ 'cwd': '%s:h',
\ 'command': function('ale_linters#go#staticcheck#GetCommand'),
\ 'callback': 'ale#handlers#go#Handler',
\ 'output_stream': 'both',