Skip to content

Commit 552f7b2

Browse files
authored
Merge pull request #1948 from bhcleek/homogenize-async-progress
Homogenize async progress
2 parents 96e36a2 + 6e6abbc commit 552f7b2

File tree

7 files changed

+36
-47
lines changed

7 files changed

+36
-47
lines changed

autoload/go/cmd.vim

-8
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ function! go#cmd#Build(bang, ...) abort
3232

3333
" Vim and Neovim async.
3434
if go#util#has_job() || has('nvim')
35-
if go#config#EchoCommandInfo()
36-
call go#util#EchoProgress("building dispatched ...")
37-
endif
38-
3935
call s:cmd_job({
4036
\ 'cmd': ['go'] + args,
4137
\ 'bang': a:bang,
@@ -196,10 +192,6 @@ function! go#cmd#Install(bang, ...) abort
196192
" expand all wildcards(i.e: '%' to the current file name)
197193
let goargs = map(copy(a:000), "expand(v:val)")
198194

199-
if go#config#EchoCommandInfo()
200-
call go#util#EchoProgress("installing dispatched ...")
201-
endif
202-
203195
call s:cmd_job({
204196
\ 'cmd': ['go', 'install', '-tags', go#config#BuildTags()] + goargs,
205197
\ 'bang': a:bang,

autoload/go/coverage.vim

+5-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ function! go#coverage#Buffer(bang, ...) abort
4444
let s:toggle = 1
4545
let l:tmpname = tempname()
4646

47-
if go#config#EchoCommandInfo()
48-
call go#util#EchoProgress("testing...")
49-
endif
50-
5147
if go#util#has_job() || has('nvim')
5248
call s:coverage_job({
5349
\ 'cmd': ['go', 'test', '-tags', go#config#BuildTags(), '-coverprofile', l:tmpname] + a:000,
@@ -59,6 +55,10 @@ function! go#coverage#Buffer(bang, ...) abort
5955
return
6056
endif
6157

58+
if go#config#EchoCommandInfo()
59+
call go#util#EchoProgress("testing...")
60+
endif
61+
6262
let args = [a:bang, 0, "-coverprofile", l:tmpname]
6363
if a:0
6464
call extend(args, a:000)
@@ -95,6 +95,7 @@ function! go#coverage#Browser(bang, ...) abort
9595
\ 'complete': function('s:coverage_browser_callback', [l:tmpname]),
9696
\ 'bang': a:bang,
9797
\ 'for': 'GoTest',
98+
\ 'statustype': 'coverage',
9899
\ })
99100
return
100101
endif

autoload/go/def.vim

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ function! go#def#Jump(mode) abort
4848
\ 'cmd': cmd,
4949
\ 'complete': function('s:jump_to_declaration_cb', [a:mode, bin_name], l:state),
5050
\ 'for': '_',
51+
\ 'statustype': 'searching declaration',
5152
\ }
5253

5354
if &modified
5455
let l:spawn_args.input = stdin_content
5556
endif
5657

57-
call go#util#EchoProgress("searching declaration ...")
58-
5958
call s:def_job(spawn_args, l:state)
6059
return
6160
endif

autoload/go/guru.vim

+11-15
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,6 @@ function! s:async_guru(args) abort
114114
return
115115
endif
116116

117-
if !has_key(a:args, 'disable_progress')
118-
if a:args.needs_scope
119-
call go#util#EchoProgress("analysing with scope " . result.scope .
120-
\ " (see ':help go-guru-scope' if this doesn't work)...")
121-
endif
122-
endif
123-
124117
let state = {
125118
\ 'mode': a:args.mode,
126119
\ 'parse' : get(a:args, 'custom_parse', funcref("s:parse_guru_output"))
@@ -141,6 +134,10 @@ function! s:async_guru(args) abort
141134
\ 'complete': state.complete,
142135
\ }
143136

137+
if has_key(a:args, 'disable_progress')
138+
let opts.statustype = ''
139+
endif
140+
144141
let opts = go#job#Options(l:opts)
145142

146143
if has_key(result, 'stdin_content')
@@ -151,6 +148,11 @@ function! s:async_guru(args) abort
151148
endif
152149

153150
call go#job#Start(result.cmd, opts)
151+
152+
if a:args.needs_scope && go#config#EchoCommandInfo() && !has_key(a:args, 'disable_progress')
153+
call go#util#EchoProgress("analysing with scope " . result.scope .
154+
\ " (see ':help go-guru-scope' if this doesn't work)...")
155+
endif
154156
endfunc
155157

156158
" run_guru runs the given guru argument
@@ -315,18 +317,13 @@ function! go#guru#DescribeInfo(showstatus) abort
315317

316318
let args = {
317319
\ 'mode': 'describe',
318-
\ 'statustype': '',
319320
\ 'format': 'json',
320321
\ 'selected': -1,
321322
\ 'needs_scope': 0,
322323
\ 'custom_parse': function('s:info'),
323324
\ 'disable_progress': 1,
324325
\ }
325326

326-
if a:showstatus
327-
let args.statustype = args.mode
328-
endif
329-
330327
call s:run_guru(args)
331328
endfunction
332329

@@ -426,14 +423,13 @@ function! go#guru#SameIds(showstatus) abort
426423

427424
let args = {
428425
\ 'mode': 'what',
429-
\ 'statustype': '',
430426
\ 'format': 'json',
431427
\ 'selected': -1,
432428
\ 'needs_scope': 0,
433429
\ 'custom_parse': function('s:same_ids_highlight'),
434430
\ }
435-
if a:showstatus
436-
let args.statustype = args.mode
431+
if !a:showstatus
432+
let args.disable_progress = 1
437433
endif
438434

439435
call s:run_guru(args)

autoload/go/job.vim

+11-9
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,19 @@ function! go#job#Options(args)
105105
endfunction
106106

107107
function state.show_status(job, exit_status) dict
108-
if go#config#EchoCommandInfo() && self.for != '_'
109-
let prefix = ""
110-
if self.statustype != ''
111-
let prefix = '[' . self.statustype . '] '
112-
endif
108+
if self.statustype == ''
109+
return
110+
endif
111+
112+
if go#config#EchoCommandInfo()
113+
let prefix = '[' . self.statustype . '] '
113114
if a:exit_status == 0
114115
call go#util#EchoSuccess(prefix . "SUCCESS")
115116
else
116117
call go#util#EchoError(prefix . "FAIL")
117118
endif
118119
endif
119120

120-
if self.statustype == ''
121-
return
122-
endif
123-
124121
let status = {
125122
\ 'desc': 'last status',
126123
\ 'type': self.statustype,
@@ -146,6 +143,11 @@ function! go#job#Options(args)
146143
endif
147144

148145
function! s:start(args) dict
146+
if go#config#EchoCommandInfo()
147+
let prefix = '[' . self.statustype . '] '
148+
call go#util#EchoSuccess(prefix . "dispatched")
149+
endif
150+
149151
if self.statustype != ''
150152
let status = {
151153
\ 'desc': 'current status',

autoload/go/rename.vim

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ function! go#rename#Rename(bang, ...) abort
2828
let cmd = [bin_path, "-offset", offset, "-to", to_identifier, '-tags', go#config#BuildTags()]
2929

3030
if go#util#has_job() || has('nvim')
31-
call go#util#EchoProgress(printf("renaming to '%s' ...", to_identifier))
3231
call s:rename_job({
3332
\ 'cmd': cmd,
3433
\ 'bang': a:bang,

autoload/go/test.vim

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ function! go#test#Test(bang, compile, ...) abort
2626
call add(args, printf("-timeout=%s", timeout))
2727
endif
2828

29-
if go#config#EchoCommandInfo()
30-
if a:compile
31-
call go#util#EchoProgress("compiling tests ...")
32-
else
33-
call go#util#EchoProgress("testing...")
34-
endif
35-
endif
36-
3729
if has('nvim') && go#config#TermEnabled()
3830
call go#term#new(a:bang, ["go"] + args)
3931
endif
@@ -55,6 +47,14 @@ function! go#test#Test(bang, compile, ...) abort
5547
return
5648
endif
5749

50+
if go#config#EchoCommandInfo()
51+
if a:compile
52+
call go#util#EchoProgress("compiling tests ...")
53+
else
54+
call go#util#EchoProgress("testing...")
55+
endif
56+
endif
57+
5858
call go#cmd#autowrite()
5959
redraw
6060

0 commit comments

Comments
 (0)