Skip to content

Commit

Permalink
Merge pull request #577 from fatih/show-gorename-errors
Browse files Browse the repository at this point in the history
gorename: create and populate errors in quickfix window
  • Loading branch information
fatih committed Oct 18, 2015
2 parents eab9c63 + 3422721 commit b510a66
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
12 changes: 10 additions & 2 deletions autoload/go/rename.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if !exists("g:go_gorename_bin")
let g:go_gorename_bin = "gorename"
endif

function! go#rename#Rename(...)
function! go#rename#Rename(bang, ...)
let to = ""
if a:0 == 0
let from = expand("<cword>")
Expand Down Expand Up @@ -31,8 +31,16 @@ function! go#rename#Rename(...)
let clean = split(out, '\n')

if v:shell_error
redraw | echon "vim-go: " | echohl Statement | echon clean[0] | echohl None
call go#tool#ShowErrors(out)
cwindow
let errors = getqflist()
if !empty(errors) && !a:bang
cc 1 "jump to first error if there is any
endif
return
else
call setqflist([])
cwindow
redraw | echon "vim-go: " | echohl Function | echon clean[0] | echohl None
endif

Expand Down
4 changes: 3 additions & 1 deletion doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,13 @@ COMMANDS *go-commands*
for the type that implements an interface under the cursor (or selected
package) is shown quickfix list.
*:GoRename*
:GoRename [to]
:GoRename[!] [to]

Rename the identifier under the cursor to the desired new name. If no
argument is given a prompt will ask for the desired identifier.

If [!] is not given the first error is jumped to.


*:GoOracleScope*
:GoOracleScope [path1] [path2] ...
Expand Down
2 changes: 1 addition & 1 deletion ftplugin/go/commands.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
" gorename
command! -nargs=? GoRename call go#rename#Rename(<f-args>)
command! -nargs=? GoRename call go#rename#Rename(<bang>0,<f-args>)

" oracle
command! -nargs=* -complete=customlist,go#package#Complete GoOracleScope call go#oracle#Scope(<f-args>)
Expand Down
2 changes: 1 addition & 1 deletion ftplugin/go/mappings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ nnoremap <silent> <Plug>(go-freevars) :<C-u>call go#oracle#Freevars(-1)<CR>
nnoremap <silent> <Plug>(go-channelpeers) :<C-u>call go#oracle#ChannelPeers(-1)<CR>
nnoremap <silent> <Plug>(go-referrers) :<C-u>call go#oracle#Referrers(-1)<CR>
nnoremap <silent> <Plug>(go-rename) :<C-u>call go#rename#Rename()<CR>
nnoremap <silent> <Plug>(go-rename) :<C-u>call go#rename#Rename(!g:go_jump_to_error)<CR>
nnoremap <silent> <Plug>(go-def) :<C-u>call go#def#Jump()<CR>
nnoremap <silent> <Plug>(go-def-vertical) :<C-u>call go#def#JumpMode("vsplit")<CR>
Expand Down

0 comments on commit b510a66

Please sign in to comment.