-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: status notification during format operation #250
Comments
The first formatter failure will notify, but successive failures do not notify to avoid a noisy UI. Once the formatter successfully runs, it will reset the status and the next failure will display an error again. I haven't yet found a situation where I want to be notified of the same failure multiple times, which seems to be what you're asking for. Could you explain more about your use case and what the value is from more notifications? |
I have a key binding for the format and disabled auto format. The formatter may fail for different reasons while I'm coding:
For UI notification like Currently, without formatting indicator, it'd be hard to tell that: |
I don't think this is something that should be built-in to conform, which is trying to be more of the low-level formatting API. It's something that could be built on top fairly easily, because the local bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { "Formatting..." })
local winid = vim.api.nvim_open_win(bufnr, false, {
relative = "editor",
anchor = "SE",
row = vim.o.lines - 2,
col = vim.o.columns,
width = 20,
height = 1,
style = "minimal",
border = "rounded",
focusable = false,
noautocmd = true,
})
vim.bo[bufnr].bufhidden = "wipe"
require("conform").format({ async = true, quiet = true, lsp_fallback = true }, function(err)
vim.api.nvim_win_close(winid, true)
if err then
vim.notify(err, vim.log.levels.WARN)
end
end) |
I'm trying to add a related wrapper over the |
I'm having a wrapper of format() like this
and have a route configured for
But I find no way to hide the message once format is done, the message disappears only on timeout. |
With fidget, finally I get what I want!
Effects: |
Would this be possible to achieve with format_on_save = function(_)
local conform = require("conform")
local formatters = conform.list_formatters()
local fmt_names = {}
if not vim.tbl_isempty(formatters) then
fmt_names = vim.tbl_map(function(f)
return f.name
end, formatters)
elseif conform.will_fallback_lsp(format_opts) then
fmt_names = { "lsp" }
else
return
end
local fmt_info = "fmt: " .. table.concat(fmt_names, "/")
local msg_handle = init_msg_progress(fmt_info)
return format_options,
function(err)
msg_handle:finish()
end
end, This is what I have right now, using the same |
Now it's done with the following wrapper and the the PR for noice
|
What do you mean by "come at the same time", two different messages or any screenshot? The format operation generally finished very fast, and the begin message will be updated with the end message (it's progress message), if there is only one format operation, you should get just one message, either begin or end. Now the progress message is done with noice (the PR is not merged at the time), just like null-ls before, for which all the status info appears in a single line. This is two independent format operations, one is done, another is in process: |
What I meant was that when using your wrapper around manual formatting it works as expected. First a fidget notification is shown that formatting started and then once its completed it shows the check mark. But when using the code I sent (I want to see the fidget notification when using format_on_save), the start message is shown when the formatting is completed, and then the check mark comes instantly after. This is usually not noticable but when formatting takes a bit of time it is |
For anyone reading this and prepare to use the wrapper above, there is a critical bug in the old wrapper which cause #260 , I have just updated (the 3rd line: |
Not sure for the case, not sure if I'm reading it correctly, if possible you may provide a screen recording :) |
If you define local function open_progress_win()
local bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { "Formatting..." })
local winid = vim.api.nvim_open_win(bufnr, false, {
relative = "editor",
anchor = "SE",
row = vim.o.lines - 2,
col = vim.o.columns,
width = 20,
height = 1,
style = "minimal",
border = "rounded",
focusable = false,
noautocmd = true,
})
vim.bo[bufnr].bufhidden = "wipe"
return winid
end
local function format()
require("conform").format({ async = true, quiet = true, lsp_fallback = true }, function(err)
local winid = open_progress_win()
vim.api.nvim_win_close(winid, true)
if err then
vim.notify(err, vim.log.levels.WARN)
end
end)
end
require("conform").setup({
format_on_save = function()
local winid = open_progress_win()
return {
lsp_fallback = true,
}, function(err)
vim.api.nvim_win_close(winid, true)
if err then
vim.notify(err, vim.log.levels.WARN)
end
end
end,
}) |
Did you check existing requests?
Describe the feature
It's better to have a notification on the UI during the format operation, just like
null-ls
:Find that the format operation may fail silently with only the first failed format get informed.
Provide background
No response
What is the significance of this feature?
nice to have
Additional details
No response
The text was updated successfully, but these errors were encountered: