From a75722517d17d749a5ee86c8a3bbb098a61265fc Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Fri, 25 Aug 2023 11:55:01 -0700 Subject: fix: notification when no formatters available --- lua/conform/init.lua | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'lua') 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 -- cgit v1.2.3-70-g09d2