From b00cef78afe53a421d6e7115dd8139ccddf01db4 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 10 Jun 2024 09:59:29 +0100 Subject: [PATCH] Enable formatting on save I've usually been against auto-formatting on save and instead preferred to trigger it manually using its own keybinding. I'm enabling it for now to see how I feel about it and I'll either keep or revert it. --- plugin/conform.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugin/conform.lua b/plugin/conform.lua index a154f7c..e27fc69 100644 --- a/plugin/conform.lua +++ b/plugin/conform.lua @@ -13,6 +13,12 @@ conform.setup { }, } -vim.keymap.set("n", "f", function() - conform.format { lsp_fallback = true, async = false, timeout_ms = 500 } -end) +vim.api.nvim_create_autocmd("BufWritePre", { + callback = function(args) + conform.format { + bufnr = args.buf, + lsp_fallback = true, + quiet = true, + } + end, +})