diff --git a/lua/core/settings.lua b/lua/core/settings.lua index af736989b..3c42ad53d 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -9,6 +9,10 @@ settings["use_ssh"] = true ---@type boolean settings["format_on_save"] = true +-- Set it to false if the nofitication after formatting is annoying for you. +---@type boolean +settings["format_notify"] = true + -- Set it to false if diagnostics virtual text is annoying for you ---@type boolean settings["diagnostics_virtual_text"] = true diff --git a/lua/modules/configs/completion/formatting.lua b/lua/modules/configs/completion/formatting.lua index 4204e9ed5..d2af9c7e4 100644 --- a/lua/modules/configs/completion/formatting.lua +++ b/lua/modules/configs/completion/formatting.lua @@ -1,6 +1,7 @@ local M = {} local settings = require("core.settings") +local format_notify = settings.format_notify local disabled_workspaces = settings.format_disabled_dirs local format_on_save = settings.format_on_save local server_formatting_block_list = settings.server_formatting_block_list @@ -156,11 +157,13 @@ function M.format(opts) local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, bufnr) if result and result.result then vim.lsp.util.apply_text_edits(result.result, bufnr, client.offset_encoding) - vim.notify( - string.format("[LSP] Format successfully with %s!", client.name), - vim.log.levels.INFO, - { title = "LSP Format Success" } - ) + if format_notify then + vim.notify( + string.format("[LSP] Format successfully with %s!", client.name), + vim.log.levels.INFO, + { title = "LSP Format Success" } + ) + end elseif err then vim.notify( string.format("[LSP][%s] %s", client.name, err),