Skip to content

Commit

Permalink
Adds a do not prefill :GoRename setting
Browse files Browse the repository at this point in the history
Added a setting to prevent :GoRename from prefilling. Also if the to
identifer is empty, just return. This way if you run :GoRename but
decide to not rename, simply press escape.
  • Loading branch information
nhooyr committed Feb 4, 2016
1 parent 198a400 commit accc895
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
21 changes: 16 additions & 5 deletions autoload/go/rename.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@ if !exists("g:go_gorename_bin")
let g:go_gorename_bin = "gorename"
endif

if !exists("g:go_gorename_prefill")
let g:go_gorename_prefill = 1
endif

function! go#rename#Rename(bang, ...)
let to = ""
if a:0 == 0
let from = expand("<cword>")
let ask = printf("vim-go: rename '%s' to: ", from)
let to = input(ask, from)
redraw
if g:go_gorename_prefill
let to = input(ask, from)
else
let to = input(ask)
endif
redraw!
if empty(to)
return
endif
else
let to = a:1
endif

"return with a warning if the bin doesn't exist
let bin_path = go#path#CheckBinPath(g:go_gorename_bin)
if empty(bin_path)
return
let bin_path = go#path#CheckBinPath(g:go_gorename_bin)
if empty(bin_path)
return
endif

let fname = expand('%:p')
Expand Down
7 changes: 7 additions & 0 deletions doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,13 @@ It is by default set to edit.
>
let g:go_alternate_mode = "edit"
<
*g:go_gorename_prefill*

Specifies whether |:GoRename| prefills the new identifer name with the
word under the cursor. By default is is on.
>
let g:go_gorename_prefill = 1
<


===============================================================================
Expand Down

0 comments on commit accc895

Please sign in to comment.