From bc0cf8961e78cc1edad0b9ea871a36df73d88416 Mon Sep 17 00:00:00 2001 From: gered Date: Fri, 6 Sep 2024 18:36:15 -0400 Subject: [PATCH] default to not format on save, except for explicitly listed filetypes --- lua/plugins/conform.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua index c3fe578..6357da0 100644 --- a/lua/plugins/conform.lua +++ b/lua/plugins/conform.lua @@ -16,15 +16,17 @@ return { opts = { notify_on_error = false, format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true } + -- Filetypes to apply formatting to on save. Remove from this list + -- to disable formatting on save for that filetype. + local filetypes = { + 'lua', + 'rust', + } local lsp_format_opt - if disable_filetypes[vim.bo[bufnr].filetype] then - lsp_format_opt = 'never' - else + if filetypes[vim.bo[bufnr].filetype] then lsp_format_opt = 'fallback' + else + lsp_format_opt = 'never' end return { timeout_ms = 500,