From 95be72ddd63287f5e004b8c234ae383729172a7b Mon Sep 17 00:00:00 2001 From: Will Storey Date: Sun, 18 Dec 2016 11:08:11 -0800 Subject: [PATCH] go_metalinter_deadline applies in async mode now This change is for issue #1142. Previous to this change, the option g:go_metalinter_deadline would only be respected when calling gometalinter if we called it synchronously. This change removes the default value of g:go_metalinter_deadline of 5 seconds. For async mode: We pass in a --deadline option now only if we've defined g:go_metalinter_deadline. For sync mode: We always pass in a --deadline value. If g:go_metalinter_deadline is not set, we pass in 5 seconds. Please note that gometalinter itself has a default deadline of 5 seconds if no deadline is passed to it, so in either case the default of 5 seconds will apply. --- autoload/go/lint.vim | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/autoload/go/lint.vim b/autoload/go/lint.vim index d81072a1e0..650ec130e1 100644 --- a/autoload/go/lint.vim +++ b/autoload/go/lint.vim @@ -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 @@ -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') . ".*$'"]