From accc8959140fcb896bb76249bdd87a20052f6411 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 4 Feb 2016 13:33:10 -0500 Subject: [PATCH] Adds a do not prefill :GoRename setting 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. --- autoload/go/rename.vim | 21 ++++++++++++++++----- doc/vim-go.txt | 7 +++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/autoload/go/rename.vim b/autoload/go/rename.vim index 3212f0760e..4c8e063061 100644 --- a/autoload/go/rename.vim +++ b/autoload/go/rename.vim @@ -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("") 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') diff --git a/doc/vim-go.txt b/doc/vim-go.txt index c63ff34f00..aa629a2c26 100644 --- a/doc/vim-go.txt +++ b/doc/vim-go.txt @@ -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 +< ===============================================================================