Skip to content

Commit

Permalink
add options to lsp#ui#vim#rename() to specify server
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukkee committed Mar 21, 2024
1 parent f7ccf00 commit 57f94f5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 14 additions & 2 deletions autoload/lsp/ui/vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'])

Check failure on line 125 in autoload/lsp/ui/vim.vim

View workflow job for this annotation

GitHub Actions / runner / vint

[vint] reported by reviewdog 🐶 unexpected token: . (see vim-jp/vim-vimlparser) Raw Output: autoload/lsp/ui/vim.vim:125:50: unexpected token: . (see vim-jp/vim-vimlparser)
return
endif
else
let l:server = l:servers[0]
endif

if l:prepare_support
call lsp#send_request(l:server, {
Expand Down
5 changes: 3 additions & 2 deletions plugin/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ command! -nargs=* LspNextDiagnostic call lsp#internal#diagnostics#movement#_next
command! -nargs=* LspPreviousDiagnostic call lsp#internal#diagnostics#movement#_previous_diagnostics(<f-args>)
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(<q-args>, {}, v:null)))
command! LspTypeDefinition call lsp#ui#vim#type_definition(0, <q-mods>)
command! LspTypeHierarchy call lsp#internal#type_hierarchy#show()
command! LspPeekTypeDefinition call lsp#ui#vim#type_definition(1)
Expand Down Expand Up @@ -191,7 +192,7 @@ nnoremap <silent> <plug>(lsp-next-diagnostic-nowrap) :<c-u>call lsp#internal#dia
nnoremap <silent> <plug>(lsp-previous-diagnostic) :<c-u>call lsp#internal#diagnostics#movement#_previous_diagnostics()<cr>
nnoremap <silent> <plug>(lsp-previous-diagnostic-nowrap) :<c-u>call lsp#internal#diagnostics#movement#_previous_diagnostics("-wrap=0")<cr>
nnoremap <silent> <plug>(lsp-references) :<c-u>call lsp#ui#vim#references({})<cr>
nnoremap <silent> <plug>(lsp-rename) :<c-u>call lsp#ui#vim#rename()<cr>
nnoremap <silent> <plug>(lsp-rename) :<c-u>call lsp#ui#vim#rename({})<cr>
nnoremap <silent> <plug>(lsp-type-definition) :<c-u>call lsp#ui#vim#type_definition(0)<cr>
nnoremap <silent> <plug>(lsp-type-hierarchy) :<c-u>call lsp#internal#type_hierarchy#show()<cr>
nnoremap <silent> <plug>(lsp-peek-type-definition) :<c-u>call lsp#ui#vim#type_definition(1)<cr>
Expand Down

0 comments on commit 57f94f5

Please sign in to comment.