|
@@ -72,12 +72,9 @@ vim.api.nvim_create_autocmd('BufWritePre', {
|
|
|
|
|
|
if not vim.g.no_lsp_format then
|
|
|
-- check if can LSP format
|
|
|
- local clients = vim.lsp.get_active_clients({ bufnr = opts.buf })
|
|
|
- for _, client in ipairs(clients) do
|
|
|
- if client.supports_method('textDocument/formatting', { bufnr = opts.buf }) then
|
|
|
- vim.lsp.buf.format({ bufnr = opts.buf })
|
|
|
- return
|
|
|
- end
|
|
|
+ local clients = vim.lsp.get_clients({ bufnr = opts.buf, method = 'textDocument/formatting' })
|
|
|
+ if #clients > 0 then
|
|
|
+ vim.lsp.buf.format({ bufnr = opts.buf })
|
|
|
end
|
|
|
end
|
|
|
|