aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/buf.lua
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2022-05-26 12:28:50 +0200
committerGitHub <noreply@github.com>2022-05-26 12:28:50 +0200
commite8ada41b63ebd916a44240de661faa64a1d0c941 (patch)
treec836f9ab678d9cb48dab69e70492c8dc1c96a482 /runtime/lua/vim/lsp/buf.lua
parent7b952793d5c46e862a9cdec3d6ac4762370296ed (diff)
downloadrneovim-e8ada41b63ebd916a44240de661faa64a1d0c941.tar.gz
rneovim-e8ada41b63ebd916a44240de661faa64a1d0c941.tar.bz2
rneovim-e8ada41b63ebd916a44240de661faa64a1d0c941.zip
feat(lsp): turn rename filter into a predicate (#18745)
Same as https://github.com/neovim/neovim/pull/18458 but for rename
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r--runtime/lua/vim/lsp/buf.lua17
1 files changed, 7 insertions, 10 deletions
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