Skip to content

Commit

Permalink
fix: LSP deprecated method warning on nvim nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Jan 9, 2024
1 parent 229e9ab commit 75e7c5c
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions lua/conform/lsp_format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 75e7c5c

Please sign in to comment.