aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Arcangeli <stevearc@stevearc.com>2024-01-08 22:24:34 -0800
committerSteven Arcangeli <stevearc@stevearc.com>2024-01-08 22:24:34 -0800
commit75e7c5c7eb5fbd53f8b12dc420b31ec70770b231 (patch)
treef558b4d38a526e4c1a627c844b9ede156a3f045c
parent229e9ab5d6e90bc5e6d24141dce3cc28ba95293a (diff)
fix: LSP deprecated method warning on nvim nightly
-rw-r--r--lua/conform/lsp_format.lua28
1 files changed, 20 insertions, 8 deletions
diff --git a/lua/conform/lsp_format.lua b/lua/conform/lsp_format.lua
index 283b3ae..cd6e429 100644
--- a/lua/conform/lsp_format.lua
+++ b/lua/conform/lsp_format.lua
@@ -30,17 +30,29 @@ end
function M.get_format_clients(options)
local method = options.range and "textDocument/rangeFormatting" or "textDocument/formatting"
- local clients = vim.lsp.get_active_clients({
- id = options.id,
- bufnr = options.bufnr,
- name = options.name,
- })
+ local clients
+ if vim.lsp.get_clients then
+ clients = vim.lsp.get_clients({
+ id = options.id,
+ bufnr = options.bufnr,
+ name = options.name,
+ method = method,
+ })
+ else
+ clients = vim.lsp.get_active_clients({
+ id = options.id,
+ bufnr = options.bufnr,
+ name = options.name,
+ })
+
+ clients = vim.tbl_filter(function(client)
+ return client.supports_method(method, { bufnr = options.bufnr })
+ end, clients)
+ end
if options.filter then
clients = vim.tbl_filter(options.filter, clients)
end
- return vim.tbl_filter(function(client)
- return client.supports_method(method, { bufnr = options.bufnr })
- end, clients)
+ return clients
end
---@param options table