-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lint: add g:go_metalinter_path setting
- Loading branch information
Showing
4 changed files
with
38 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ if !exists("g:go_metalinter_enabled") | |
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck'] | ||
endif | ||
|
||
if !exists("g:go_metalinter_path") | ||
let g:go_metalinter_path = "./..." | ||
endif | ||
|
||
if !exists("g:go_golint_bin") | ||
let g:go_golint_bin = "golint" | ||
endif | ||
|
@@ -14,36 +18,42 @@ if !exists("g:go_errcheck_bin") | |
let g:go_errcheck_bin = "errcheck" | ||
endif | ||
|
||
function! go#lint#Gometa(...) abort | ||
" change GOPATH too, so the underlying tools in gometalinter can pick up | ||
" the correct GOPATH | ||
let old_gopath = $GOPATH | ||
let $GOPATH = go#path#Detect() | ||
|
||
function! go#lint#Gometa(path_to_lint) abort | ||
let meta_command = "gometalinter --disable-all" | ||
if empty(g:go_metalinter_command) | ||
let bin_path = go#path#CheckBinPath("gometalinter") | ||
if empty(bin_path) | ||
return | ||
endif | ||
|
||
if empty(g:go_metalinter_enabled) | ||
echohl Error | echomsg "vim-go: please enable linters with the setting g:go_metalinter_enabled" | echohl None | ||
return | ||
endif | ||
|
||
for linter in g:go_metalinter_enabled | ||
let meta_command .= " --enable=".linter | ||
endfor | ||
|
||
" TODO(arslan): maybe this should be passed via argument? | ||
" for now we search for all underlying files | ||
let meta_command .= " ./..." | ||
|
||
" by default we search for all underlying files | ||
let path = g:go_metalinter_path | ||
if !empty(a:path_to_lint) | ||
let path = a:path_to_lint | ||
endif | ||
|
||
let meta_command .= path | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fatih
Author
Owner
|
||
else | ||
" the user wants something else, let us use it. | ||
let meta_command = g:go_metalinter_command | ||
endif | ||
|
||
" debug | ||
" comment out the following two lines for debugging | ||
" echo meta_command | ||
" return | ||
|
||
let out = system(meta_command) | ||
let out = go#tool#ExecuteInDir(meta_command) | ||
|
||
if v:shell_error == 0 | ||
redraw | echo | ||
call setqflist([]) | ||
|
@@ -63,9 +73,6 @@ function! go#lint#Gometa(...) abort | |
|
||
let &errorformat = old_errorformat | ||
endif | ||
|
||
" restore GOPATH again | ||
let $GOPATH = old_gopath | ||
endfunction | ||
|
||
" Golint calls 'golint' on the current directory. Any warnings are populated in | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@fatih should this be
let meta_command .= " " . path
else it would be --enable=errcheck./...