Skip to content

Commit

Permalink
Merge pull request #730 from nhooyr/gorun-neovim-args
Browse files Browse the repository at this point in the history
Allow GoRun to accept file arguments in neovim
  • Loading branch information
fatih committed Feb 24, 2016
2 parents 199fa8f + f432580 commit 411ec39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions autoload/go/cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ endfunction


" Run runs the current file (and their dependencies if any) in a new terminal.
function! go#cmd#RunTerm(bang, mode)
let cmd = "go run ". go#util#Shelljoin(go#tool#Files())
function! go#cmd#RunTerm(bang, mode, files)
if empty(a:files)
let cmd = "go run ". go#util#Shelljoin(go#tool#Files())
else
let cmd = "go run ". go#util#Shelljoin(map(copy(a:files), "expand(v:val)"), 1)
endif
call go#term#newmode(a:bang, cmd, a:mode)
endfunction

Expand All @@ -85,7 +89,7 @@ endfunction
" calling long running apps will block the whole UI.
function! go#cmd#Run(bang, ...)
if has('nvim')
call go#cmd#RunTerm(a:bang, '')
call go#cmd#RunTerm(a:bang, '', a:000)
return
endif

Expand Down
6 changes: 3 additions & 3 deletions ftplugin/go/mappings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ endif
nnoremap <silent> <Plug>(go-run) :<C-u>call go#cmd#Run(!g:go_jump_to_error)<CR>
if has("nvim")
nnoremap <silent> <Plug>(go-run-vertical) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'vsplit')<CR>
nnoremap <silent> <Plug>(go-run-split) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'split')<CR>
nnoremap <silent> <Plug>(go-run-tab) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'tabe')<CR>
nnoremap <silent> <Plug>(go-run-vertical) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'vsplit', [])<CR>
nnoremap <silent> <Plug>(go-run-split) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'split', [])<CR>
nnoremap <silent> <Plug>(go-run-tab) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'tabe', [])<CR>
endif

nnoremap <silent> <Plug>(go-build) :<C-u>call go#cmd#Build(!g:go_jump_to_error)<CR>
Expand Down

0 comments on commit 411ec39

Please sign in to comment.