Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1142: go_metalinter_deadline applies in async mode now #1146

Merged
merged 1 commit into from
Jan 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions autoload/go/lint.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ if !exists("g:go_metalinter_enabled")
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
endif

if !exists("g:go_metalinter_deadline")
let g:go_metalinter_deadline = "5s"
endif

if !exists("g:go_golint_bin")
let g:go_golint_bin = "golint"
endif
Expand Down Expand Up @@ -51,13 +47,30 @@ function! go#lint#Gometa(autosave, ...) abort
let cmd += [split(g:go_metalinter_command, " ")]
endif

" gometalinter has a default deadline of 5 seconds.
"
" For async mode (s:lint_job), we want to override the default deadline only
" if we have a deadline configured.
"
" For sync mode (go#tool#ExecuteInDir), always explicitly pass the 5 seconds
" deadline if there is no other deadline configured. If a deadline is
" configured, then use it.

" Call gometalinter asynchronously.
if go#util#has_job() && has('lambda')
let deadline = get(g:, 'go_metalinter_deadline', 0)
if deadline != 0
let cmd += ["--deadline=" . deadline]
endif

call s:lint_job({'cmd': cmd})
return
endif

" we add deadline only for sync mode
let cmd += ["--deadline=" . g:go_metalinter_deadline]
" We're calling gometalinter synchronously.

let cmd += ["--deadline=" . get(g:, 'go_metalinter_deadline', "5s")]

if a:autosave
" include only messages for the active buffer
let cmd += ["--include='^" . expand('%:p') . ".*$'"]
Expand Down