Skip to content

Commit

Permalink
Merge pull request #1146 from horgh/master
Browse files Browse the repository at this point in the history
#1142: go_metalinter_deadline applies in async mode now
  • Loading branch information
fatih authored Jan 7, 2017
2 parents 7635fc0 + 95be72d commit 41f5fd1
Showing 1 changed file with 19 additions and 6 deletions.
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

0 comments on commit 41f5fd1

Please sign in to comment.