diff options
author | Steven Arcangeli <stevearc@stevearc.com> | 2024-01-08 22:24:34 -0800 |
---|---|---|
committer | Steven Arcangeli <stevearc@stevearc.com> | 2024-01-08 22:24:34 -0800 |
commit | 75e7c5c7eb5fbd53f8b12dc420b31ec70770b231 (patch) | |
tree | f558b4d38a526e4c1a627c844b9ede156a3f045c /lua/conform/lsp_format.lua | |
parent | 229e9ab5d6e90bc5e6d24141dce3cc28ba95293a (diff) |
fix: LSP deprecated method warning on nvim nightly
Diffstat (limited to 'lua/conform/lsp_format.lua')
-rw-r--r-- | lua/conform/lsp_format.lua | 28 |
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 |