From 67959207414919777f11832d2eee913531d418cd Mon Sep 17 00:00:00 2001 From: naps62 Date: Mon, 17 Aug 2026 09:07:19 +0000 Subject: [PATCH] refactor(conform): format on demand, not on save MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agents run stylua/biome/rustfmt themselves, and a save-time reformat races their in-flight writes to the same buffer. Timeout and LSP fallback move to default_format_opts so fm (NvChad's binding) keeps the same behaviour; conform now lazy-loads on first use. Drops the /contrib/ skip — explicit invocation is already the opt-in. Co-Authored-By: Claude Opus 5 --- lua/configs/conform.lua | 17 ++++++----------- lua/plugins/init.lua | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/lua/configs/conform.lua b/lua/configs/conform.lua index 13ac260..be89d77 100644 --- a/lua/configs/conform.lua +++ b/lua/configs/conform.lua @@ -20,17 +20,12 @@ local options = { }, }, - format_after_save = function() - local buf_path = vim.api.nvim_buf_get_name(0) - if buf_path:find "/contrib/" then - return nil - end - - return { - timeout_ms = 1000, - lsp_format = "fallback", - } - end, + -- No format-on-save: agents run these formatters themselves, and a save-time + -- reformat races their in-flight writes. Format on demand with fm. + default_format_opts = { + timeout_ms = 1000, + lsp_format = "fallback", + }, } return options diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 81cf733..ab3ba20 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,7 +1,7 @@ return { { "stevearc/conform.nvim", - event = "BufWritePre", + cmd = "ConformInfo", opts = require "configs.conform", }, }