From 57f94f5780b309f716c0b8531af6d616ba2f3ba9 Mon Sep 17 00:00:00 2001 From: tsukkee Date: Thu, 21 Mar 2024 11:59:55 +0900 Subject: [PATCH] add `options` to `lsp#ui#vim#rename()` to specify `server` --- autoload/lsp/ui/vim.vim | 16 ++++++++++++++-- plugin/lsp.vim | 5 +++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/autoload/lsp/ui/vim.vim b/autoload/lsp/ui/vim.vim index 53309e51e..17afc4077 100644 --- a/autoload/lsp/ui/vim.vim +++ b/autoload/lsp/ui/vim.vim @@ -99,7 +99,10 @@ function! s:rename(server, new_name, pos) abort echo ' ... Renaming ...' endfunction -function! lsp#ui#vim#rename() abort +" options - { +" server - 'server_name' " optional +" } +function! lsp#ui#vim#rename(options) abort let l:servers = filter(lsp#get_allowed_servers(), 'lsp#capabilities#has_rename_prepare_provider(v:val)') let l:prepare_support = 1 if len(l:servers) == 0 @@ -115,7 +118,16 @@ function! lsp#ui#vim#rename() abort endif " TODO: ask the user which server it should use to rename if there are multiple - let l:server = l:servers[0] + if has_key(a:options, 'server') + if index(l:servers, a:options['server']) >= 0 + let l:server = a:options['server'] + else + call s:not_supported('Renaming by ' .. a:options['server']) + return + endif + else + let l:server = l:servers[0] + endif if l:prepare_support call lsp#send_request(l:server, { diff --git a/plugin/lsp.vim b/plugin/lsp.vim index 11a2b4428..e6429a06f 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -130,7 +130,8 @@ command! -nargs=* LspNextDiagnostic call lsp#internal#diagnostics#movement#_next command! -nargs=* LspPreviousDiagnostic call lsp#internal#diagnostics#movement#_previous_diagnostics() command! LspReferences call lsp#ui#vim#references({}) command! LspAddTreeReferences call lsp#ui#vim#add_tree_references() -command! LspRename call lsp#ui#vim#rename() +command! LspRename call lsp#ui#vim#rename( + \ extend({}, lsp#utils#args#_parse(, {}, v:null))) command! LspTypeDefinition call lsp#ui#vim#type_definition(0, ) command! LspTypeHierarchy call lsp#internal#type_hierarchy#show() command! LspPeekTypeDefinition call lsp#ui#vim#type_definition(1) @@ -191,7 +192,7 @@ nnoremap (lsp-next-diagnostic-nowrap) :call lsp#internal#dia nnoremap (lsp-previous-diagnostic) :call lsp#internal#diagnostics#movement#_previous_diagnostics() nnoremap (lsp-previous-diagnostic-nowrap) :call lsp#internal#diagnostics#movement#_previous_diagnostics("-wrap=0") nnoremap (lsp-references) :call lsp#ui#vim#references({}) -nnoremap (lsp-rename) :call lsp#ui#vim#rename() +nnoremap (lsp-rename) :call lsp#ui#vim#rename({}) nnoremap (lsp-type-definition) :call lsp#ui#vim#type_definition(0) nnoremap (lsp-type-hierarchy) :call lsp#internal#type_hierarchy#show() nnoremap (lsp-peek-type-definition) :call lsp#ui#vim#type_definition(1)