aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/lsp.txt8
-rw-r--r--runtime/lua/vim/lsp/buf.lua17
2 files changed, 11 insertions, 14 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 841ed36421..41f083687d 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -1271,10 +1271,10 @@ rename({new_name}, {options}) *vim.lsp.buf.rename()*
prompted for a new name using
|vim.ui.input()|.
{options} (table|nil) additional options
- • filter (function|nil): Predicate to filter
- clients used for rename. Receives the
- attached clients as argument and must return
- a list of clients.
+ • filter (function|nil): Predicate used to
+ filter clients. Receives a client as
+ argument and must return a boolean. Clients
+ matching the predicate are included.
• name (string|nil): Restrict clients used for
rename to ones where client.name matches
this field.
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index 0e86bff4f2..bcfaecdfcc 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -377,23 +377,20 @@ end
--- name using |vim.ui.input()|.
---@param options table|nil additional options
--- - filter (function|nil):
---- Predicate to filter clients used for rename.
---- Receives the attached clients as argument and must return a list of
---- clients.
+--- Predicate used to filter clients. Receives a client as argument and
+--- must return a boolean. Clients matching the predicate are included.
--- - name (string|nil):
--- Restrict clients used for rename to ones where client.name matches
--- this field.
function M.rename(new_name, options)
options = options or {}
local bufnr = options.bufnr or vim.api.nvim_get_current_buf()
- local clients = vim.lsp.buf_get_clients(bufnr)
-
+ local clients = vim.lsp.get_active_clients({
+ bufnr = bufnr,
+ name = options.name,
+ })
if options.filter then
- clients = options.filter(clients)
- elseif options.name then
- clients = vim.tbl_filter(function(client)
- return client.name == options.name
- end, clients)
+ clients = vim.tbl_filter(options.filter, clients)
end
-- Clients must at least support rename, prepareRename is optional