From 3b3e5fd6ea42646f3a9eda0dd1fc84fb36c2b8e4 Mon Sep 17 00:00:00 2001 From: Billie Cleek Date: Thu, 26 Dec 2024 10:40:47 -0800 Subject: [PATCH] rename: add support for gopls rename --- autoload/go/rename.vim | 13 ++++++++----- doc/vim-go.txt | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/autoload/go/rename.vim b/autoload/go/rename.vim index 12c6fe413e..28e7091af9 100644 --- a/autoload/go/rename.vim +++ b/autoload/go/rename.vim @@ -23,23 +23,26 @@ function! go#rename#Rename(bang, ...) abort let l:bin = go#config#RenameCommand() " return with a warning if the bin doesn't exist - let bin_path = go#path#CheckBinPath(l:bin) + let bin_path = go#path#CheckBinPath(substitute(l:bin, 'gopls rename$', 'gopls', '')) if empty(bin_path) return endif - let fname = expand('%:p') - let pos = go#util#OffsetCursor() - let offset = printf('%s:#%d', fname, pos) - if l:bin == 'gopls' call go#lsp#Rename(to_identifier) return endif + let fname = expand('%:p') + let pos = go#util#OffsetCursor() + let args = [] if l:bin == 'gorename' + let offset = printf('%s:#%d', fname, pos) let l:args = extend(l:args, ['-tags', go#config#BuildTags(), '-offset', offset, '-to', to_identifier]) + elseif l:bin == 'gopls rename' + let offset = printf('%s:#%d', fname, pos) + let l:args = extend(l:args, ['rename', '-write', offset, to_identifier]) else call go#util#EchoWarning('unexpected rename command') endif diff --git a/doc/vim-go.txt b/doc/vim-go.txt index a278bb1af0..a47d1f1cc1 100644 --- a/doc/vim-go.txt +++ b/doc/vim-go.txt @@ -1676,7 +1676,7 @@ default it is set to edit. *'g:go_rename_command'* Use this option to define which tool is used to rename. By default `gopls` -is used. Valid options are `gorename` and `gopls`. +is used. Valid options are `gopls`, `gopls rename`, and `gorename`. > let g:go_rename_command = 'gopls' <