Skip to content

Commit 3b3e5fd

Browse files
committed
rename: add support for gopls rename
1 parent 7827332 commit 3b3e5fd

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

autoload/go/rename.vim

+8-5
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,26 @@ function! go#rename#Rename(bang, ...) abort
2323
let l:bin = go#config#RenameCommand()
2424

2525
" return with a warning if the bin doesn't exist
26-
let bin_path = go#path#CheckBinPath(l:bin)
26+
let bin_path = go#path#CheckBinPath(substitute(l:bin, 'gopls rename$', 'gopls', ''))
2727
if empty(bin_path)
2828
return
2929
endif
3030

31-
let fname = expand('%:p')
32-
let pos = go#util#OffsetCursor()
33-
let offset = printf('%s:#%d', fname, pos)
34-
3531
if l:bin == 'gopls'
3632
call go#lsp#Rename(to_identifier)
3733
return
3834
endif
3935

36+
let fname = expand('%:p')
37+
let pos = go#util#OffsetCursor()
38+
4039
let args = []
4140
if l:bin == 'gorename'
41+
let offset = printf('%s:#%d', fname, pos)
4242
let l:args = extend(l:args, ['-tags', go#config#BuildTags(), '-offset', offset, '-to', to_identifier])
43+
elseif l:bin == 'gopls rename'
44+
let offset = printf('%s:#%d', fname, pos)
45+
let l:args = extend(l:args, ['rename', '-write', offset, to_identifier])
4346
else
4447
call go#util#EchoWarning('unexpected rename command')
4548
endif

doc/vim-go.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ default it is set to edit.
16761676
*'g:go_rename_command'*
16771677

16781678
Use this option to define which tool is used to rename. By default `gopls`
1679-
is used. Valid options are `gorename` and `gopls`.
1679+
is used. Valid options are `gopls`, `gopls rename`, and `gorename`.
16801680
>
16811681
let g:go_rename_command = 'gopls'
16821682
<

0 commit comments

Comments
 (0)