Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lua/core/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions lua/modules/configs/completion/formatting.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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),
Expand Down