aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Arcangeli <stevearc@stevearc.com>2023-08-25 11:55:01 -0700
committerSteven Arcangeli <stevearc@stevearc.com>2023-08-25 11:55:01 -0700
commita75722517d17d749a5ee86c8a3bbb098a61265fc (patch)
tree9b701b2cf64789ac063efb5365e87e6148cce219
parenteb5987e9dd40ce1e27c9c07e41d09571f1bd876e (diff)
fix: notification when no formatters available
-rw-r--r--lua/conform/init.lua28
1 files changed, 15 insertions, 13 deletions
diff --git a/lua/conform/init.lua b/lua/conform/init.lua
index f721587..15c4317 100644
--- a/lua/conform/init.lua
+++ b/lua/conform/init.lua
@@ -115,22 +115,24 @@ M.format = function(opts)
end
end
- if not any_formatters and opts.lsp_fallback then
- local supports_lsp_formatting = false
- for _, client in ipairs(vim.lsp.get_active_clients({ bufnr = opts.bufnr })) do
- if client.server_capabilities.documentFormattingProvider then
- supports_lsp_formatting = true
- break
+ if not any_formatters then
+ if opts.lsp_fallback then
+ local supports_lsp_formatting = false
+ for _, client in ipairs(vim.lsp.get_active_clients({ bufnr = opts.bufnr })) do
+ if client.server_capabilities.documentFormattingProvider then
+ supports_lsp_formatting = true
+ break
+ end
end
- end
- if supports_lsp_formatting then
- local restore = require("conform.util").save_win_positions(opts.bufnr)
- vim.lsp.buf.format(opts)
- restore()
+ if supports_lsp_formatting then
+ local restore = require("conform.util").save_win_positions(opts.bufnr)
+ vim.lsp.buf.format(opts)
+ restore()
+ end
+ else
+ vim.notify("No formatters found for buffer. See :checkhealth conform", vim.log.levels.WARN)
end
- else
- vim.notify("No formatters found for buffer. See :checkhealth conform", vim.log.levels.WARN)
end
return any_formatters