From 88f187160aa2a9cacc269ceb0e0096d4afe83611 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 20 Jul 2024 16:50:00 +0200 Subject: [PATCH] nvim: FormatDisable disables globally with a bang Switch the functionality of `FormatDisable` command around: Disables for the local buffer by default and disables globally if called with a bang. --- nvim/.config/nvim/lua/plugins/ide.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/ide.lua b/nvim/.config/nvim/lua/plugins/ide.lua index 679c25d..0634d04 100644 --- a/nvim/.config/nvim/lua/plugins/ide.lua +++ b/nvim/.config/nvim/lua/plugins/ide.lua @@ -141,7 +141,9 @@ return { "stevearc/conform.nvim", config = function() require("conform").setup({ + lsp_format = "fallback", + format_after_save = function(bufnr) if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then return @@ -152,10 +154,10 @@ return { }) vim.api.nvim_create_user_command("FormatDisable", function(args) if args.bang then - -- FormatDisable! will disable formatting just for this buffer - vim.b.disable_autoformat = true - else vim.g.disable_autoformat = true + else + -- FormatDisable! will disable formatting globally + vim.b.disable_autoformat = true end end, { desc = "Disable formatting on save",