Skip to content

Commit

Permalink
cmd, jobcontrol: add progress and complete message for nvim. cmd: fix…
Browse files Browse the repository at this point in the history
… to work GoTestFunc. refs fatih#686
  • Loading branch information
t-yuki committed Jan 24, 2016
1 parent b85b550 commit a912e5e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
18 changes: 9 additions & 9 deletions autoload/go/cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function! go#cmd#autowrite()
endfunction


" Build buils the source code without producting any output binary. We live in
" Build builds the source code without producting any output binary. We live in
" an editor so the best is to build it to catch errors and fix them. By
" default it tries to call simply 'go build', but it first tries to get all
" dependent files for the current folder and passes it to go build.
Expand All @@ -27,6 +27,7 @@ function! go#cmd#Build(bang, ...)

" if we have nvim, call it asynchronously and return early ;)
if has('nvim')
call go#util#EchoProgress("building dispatched ...")
call go#jobcontrol#Spawn(a:bang, "build", args)
return
endif
Expand Down Expand Up @@ -183,14 +184,19 @@ function! go#cmd#Test(bang, compile, ...)
" expand all wildcards(i.e: '%' to the current file name)
let goargs = map(copy(a:000), "expand(v:val)")

" escape all shell arguments before we pass it to test
call extend(args, go#util#Shelllist(goargs, 1))
call extend(args, goargs, 1)
else
" only add this if no custom flags are passed
let timeout = get(g:, 'go_test_timeout', '10s')
call add(args, printf("-timeout=%s", timeout))
endif

if a:compile
echon "vim-go: " | echohl Identifier | echon "compiling tests ..." | echohl None
else
echon "vim-go: " | echohl Identifier | echon "testing ..." | echohl None
endif

if has('nvim')
if get(g:, 'go_term_enabled', 0)
call go#term#new(a:bang, ["go"] + args)
Expand All @@ -200,12 +206,6 @@ function! go#cmd#Test(bang, compile, ...)
return
endif

if a:compile
echon "vim-go: " | echohl Identifier | echon "compiling tests ..." | echohl None
else
echon "vim-go: " | echohl Identifier | echon "testing ..." | echohl None
endif

call go#cmd#autowrite()
redraw

Expand Down
2 changes: 2 additions & 0 deletions autoload/go/jobcontrol.vim
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ function! s:on_exit(job_id, exit_status)
call go#list#Window()

let self.state = "SUCCESS"
call go#util#EchoSuccess("SUCCESS")
return
endif

let self.state = "FAILED"
call go#util#EchoError("FAILED")

let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
let dir = getcwd()
Expand Down
2 changes: 1 addition & 1 deletion autoload/go/term.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let s:jobs = {}
" new creates a new terminal with the given command. Mode is set based on the
" global variable g:go_term_mode, which is by default set to :vsplit
function! go#term#new(bang, cmd)
call go#term#newmode(a:bang, a:cmd, g:go_term_mode)
return go#term#newmode(a:bang, a:cmd, g:go_term_mode)
endfunction

" new creates a new terminal with the given command and window mode.
Expand Down
2 changes: 1 addition & 1 deletion autoload/go/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function! go#util#Shelljoin(arglist, ...)
endtry
endfunction

" Shelljoin returns a shell-safe representation of the items in the given
" Shelllist returns a shell-safe representation of the items in the given
" arglist. The {special} argument of shellescape() may optionally be passed.
function! go#util#Shelllist(arglist, ...)
try
Expand Down

0 comments on commit a912e5e

Please sign in to comment.