Skip to content
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

bug: snacks_notification gets written to a new buffer #275

Closed
4 tasks done
ThorstenRhau opened this issue Dec 13, 2024 · 13 comments
Closed
4 tasks done

bug: snacks_notification gets written to a new buffer #275

ThorstenRhau opened this issue Dec 13, 2024 · 13 comments
Labels
bug Something isn't working

Comments

@ThorstenRhau
Copy link

Did you check docs and existing issues?

  • I have read all the snacks.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of snacks.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.2 Build type: Release LuaJIT 2.1.1732813678

Operating system/version

macOS 15.2 Sequoia

Describe the bug

Thank you for creating snacks, it is awesome :-)

When committing to git with neogit (https://github.com/NeogitOrg/neogit) the commit message progress notification is written to a new buffer in nvim. I believe that this is done by snacks_notify. For me this buffer is undesirable since it prevents me from exiting nvim with :q, I do not want to quit with :qa! because of the risk of loosing unsaved work.
Screenshot 2024-12-13 at 09 23 55

Steps To Reproduce

  1. Commit a change with neogit
  2. new buffer is created with commit message status

Expected Behavior

No messages should be written to a new buffer.

Repro

Full config https://github.com/ThorstenRhau/neovim
Plugin config https://github.com/ThorstenRhau/neovim/blob/main/lua/plugins/snacks.lua

return {
    "folke/snacks.nvim",
    priority = 1000,
    lazy = false,
    opts = {
        bigfile = {
            size = 1 * 1024 * 1024, -- 1 MB
            notify = true,
        },
        dashboard = {
            row = nil, -- dashboard position. nil for center
            col = nil, -- dashboard position. nil for center
            preset = {
                header = [[neovim :: by Thorsten]],
            },
            formats = {
                header = { "%s", align = "center" },
                text = { "%s", align = "center" },
            },
            sections = {
                {
                    section = "header",
                },
            },
        },
        git = { enabled = true },
        gitbrowse = { enabled = true },
        indent = { enabled = true },
        notifier = {
            timeout = 3000,
            style = "compact",
        },
        notify = { enabled = true },
        quickfile = { enabled = true },
        scope = { enabled = true },
        scroll = { enabled = true },
        statuscolumn = { enabled = true },
        terminal = { enabled = true },
        toggle = { enabled = true },
        words = { enabled = true },
    },

    keys = {
        {
            "<leader>z",
            function()
                Snacks.zen()
            end,
            desc = "Toggle Zen Mode",
        },
        {
            "<leader>Z",
            function()
                Snacks.zen.zoom()
            end,
            desc = "Toggle Zoom",
        },
        {
            "<leader>.",
            function()
                Snacks.scratch()
            end,
            desc = "Toggle Scratch Buffer",
        },
        {
            "<leader>S",
            function()
                Snacks.scratch.select()
            end,
            desc = "Select Scratch Buffer",
        },
        {
            "<leader>n",
            function()
                Snacks.notifier.show_history()
            end,
            desc = "Notification History",
        },
        {
            "<leader>bd",
            function()
                Snacks.bufdelete()
            end,
            desc = "Delete Buffer",
        },
        {
            "<leader>cR",
            function()
                Snacks.rename.rename_file()
            end,
            desc = "Rename File",
        },
        {
            "<leader>gB",
            function()
                Snacks.gitbrowse()
            end,
            desc = "Git Browse",
        },
        {
            "<leader>gb",
            function()
                Snacks.git.blame_line()
            end,
            desc = "Git Blame Line",
        },
        {
            "<leader>gf",
            function()
                Snacks.lazygit.log_file()
            end,
            desc = "Lazygit Current File History",
        },
        {
            "<leader>gg",
            function()
                Snacks.lazygit()
            end,
            desc = "Lazygit",
        },
        {
            "<leader>gl",
            function()
                Snacks.lazygit.log()
            end,
            desc = "Lazygit Log (cwd)",
        },
        {
            "<leader>un",
            function()
                Snacks.notifier.hide()
            end,
            desc = "Dismiss All Notifications",
        },
        {
            "<leader>t",
            function()
                Snacks.terminal()
            end,
            desc = "Toggle Terminal",
        },
        {
            "]]",
            function()
                Snacks.words.jump(vim.v.count1)
            end,
            desc = "Next Reference",
            mode = { "n", "t" },
        },
        {
            "[[",
            function()
                Snacks.words.jump(-vim.v.count1)
            end,
            desc = "Prev Reference",
            mode = { "n", "t" },
        },
    },
    init = function()
        vim.api.nvim_create_autocmd("User", {
            pattern = "VeryLazy",
            callback = function()
                -- Setup some globals for debugging (lazy-loaded)
                _G.dd = function(...)
                    Snacks.debug.inspect(...)
                end
                _G.bt = function()
                    Snacks.debug.backtrace()
                end
                vim.print = _G.dd -- Override print to use snacks for `:=` command

                -- Create some toggle mappings
                Snacks.toggle.option("spell", { name = "Spelling" }):map("<leader>us")
                Snacks.toggle.option("wrap", { name = "Wrap" }):map("<leader>uw")
                Snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("<leader>uL")
                Snacks.toggle.diagnostics():map("<leader>ud")
                Snacks.toggle.line_number():map("<leader>ul")
                Snacks.toggle
                    .option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 })
                    :map("<leader>uc")
                Snacks.toggle.treesitter():map("<leader>uT")
                Snacks.toggle
                    .option("background", { off = "light", on = "dark", name = "Dark Background" })
                    :map("<leader>ub")
                Snacks.toggle.inlay_hints():map("<leader>uh")
                Snacks.toggle.indent():map("<leader>ug")
                Snacks.toggle.dim():map("<leader>uD")
            end,
        })
    end,
}
@ThorstenRhau ThorstenRhau added the bug Something isn't working label Dec 13, 2024
@folke
Copy link
Owner

folke commented Dec 13, 2024

What do you mean with the progress message commit notification?
snacks does no such thing.
And any buffers created for notifications are hidden, so won't interfer with :q

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2024
@ThorstenRhau
Copy link
Author

My gut feeling was that this behavior was caused by snacks since if I disable it the behavior stops. When I re-enable snacks the behavior comes back. The unwritten buffer is of type snacks_notification (attached screenshot).

@folke folke reopened this Dec 13, 2024
@ThorstenRhau
Copy link
Author

It seems to be some kind of a conflict with other plugins in my configuration.

I added:
vim.notify = function(msg, opts)
Snacks.notify(msg, opts)
end

I also disabled the telescope notify extension, noice, and nvim-notify

Now the behavior is gone. I am not quite sure if it was necessary to remove noice.

Seems like the error was partly in my setup and how snacks handles conflicting configuration of vim.notify, I might be wrong though.

Thank you for your effort Folke, it is appreciated.

@folke
Copy link
Owner

folke commented Dec 13, 2024

This is not correct:

vim.notify = function(msg, opts)
Snacks.notify(msg, opts)
end

Just set opts.snacks.notifier.enabled = true in your config.
No need to manually override vim.notify.
Noice also works with snacks automatically when enabled.
When not enabled, noice will use nvim-notify instead if that's available.

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2024
@saitharun14
Copy link

Hello,

First of all thanks for the great plugin. Keep up the good work !!!

I'm also observing the behavior where the neogit progress msg are being written to a new buffer. I have setup the notifier
according to the suggest config using opts.snacks.notifier.enabled = true

image

And when I quit try quitting nvim following is showing up

image

I also have the noice plugin installed.

Any help is greatly appreciated.

@ThorstenRhau
Copy link
Author

@saitharun14 I have been trying to figure out why this happens. At first I thought that my configuration has a flaw that I am not able to figure out. But now that you also are seeing this behavior, with a different configuration (I suppose), I am even more curious as to what could be causing this.

@folke
Copy link
Owner

folke commented Dec 19, 2024

Since you're both seeing this happening with neogit, that seems to be the culprit.

@ThorstenRhau
Copy link
Author

Neogit behaves as expected when I disable snacks in my configuration, preventing messages from being written to new buffers.

This is a catch-22 since both Neogit and Snacks work fine when loaded alone, without the other plugin present. Reporting this as a bug to either plugin is challenging since this behavior only exists when both are loaded simultaneously.

@ThorstenRhau
Copy link
Author

I will have another look at this during Christmas and see if I can figure out why this happens.

Hope you both get a relaxing Christmas break.

@saitharun14
Copy link

@saitharun14 I have been trying to figure out why this happens. At first I thought that my configuration has a flaw that I am not able to figure out. But now that you also are seeing this behavior, with a different configuration (I suppose), I am even more curious as to what could be causing this.

Yes, my configuration is different from the configuration you attached in the details. Similar to your observation, when I use them individually I don't observe the issue.

@ThorstenRhau
Copy link
Author

I think that I might have figured it out. There is an option in neogit that is not part of the plugin documentation 'process_spinner = false,'. After setting that in my plugin configuration I have had no problems with buffers etc.

As usual folke was spot on ;-)

Here is the complete configuration for reference in case anyone else finds this thread, looking for a solution to a problem that is not related to snacks: https://github.com/ThorstenRhau/neovim/blob/main/lua/plugins/neogit.lua

@saitharun14
Copy link

Hi @ThorstenRhau, setting process_spinner to false works but this will complete remove the processing indicator. This wan't an issue with noice, so I believe there can be a better solution. I may be wrong as I'm new to nvim.

@ThorstenRhau
Copy link
Author

NeogitOrg/neogit@a1fc4e5

This resolves the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants