summaryrefslogtreecommitdiffstats
path: root/lua/conform
diff options
context:
space:
mode:
Diffstat (limited to 'lua/conform')
-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