aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/buf.lua
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2022-05-06 18:57:08 +0200
committerGitHub <noreply@github.com>2022-05-06 18:57:08 +0200
commit44a4af0ed02db7f4f1cce8c64935238b4efbee12 (patch)
tree3a162764f0fd7493be87fd4abf8fd2262b2cdac5 /runtime/lua/vim/lsp/buf.lua
parentd9ec57e16a13f66a4b17edd872786e2c67348752 (diff)
downloadrneovim-44a4af0ed02db7f4f1cce8c64935238b4efbee12.tar.gz
rneovim-44a4af0ed02db7f4f1cce8c64935238b4efbee12.tar.bz2
rneovim-44a4af0ed02db7f4f1cce8c64935238b4efbee12.zip
fix(lsp): skip clients without rename capability (#18449)
Follow up to https://github.com/neovim/neovim/pull/18441 This way rename should "just work" in most cases without having to manually filter the client
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r--runtime/lua/vim/lsp/buf.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index 8db215829f..6666b3c044 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -383,8 +383,14 @@ function M.rename(new_name, options)
)
end
+ -- Clients must at least support rename, prepareRename is optional
+ clients = vim.tbl_filter(
+ function(client) return client.supports_method("textDocument/rename") end,
+ clients
+ )
+
if #clients == 0 then
- vim.notify("[LSP] Rename request failed, no matching language servers.")
+ vim.notify("[LSP] Rename, no matching language servers with rename capability.")
end
local win = vim.api.nvim_get_current_win()
@@ -459,7 +465,8 @@ function M.rename(new_name, options)
rename(input)
end)
end, bufnr)
- elseif client.supports_method("textDocument/rename") then
+ else
+ assert(client.supports_method("textDocument/rename"), 'Client must support textDocument/rename')
if new_name then
rename(new_name)
return
@@ -475,8 +482,6 @@ function M.rename(new_name, options)
end
rename(input)
end)
- else
- vim.notify('Client ' .. client.id .. '/' .. client.name .. ' has no rename capability')
end
end