rcarriga / nvim-notify

A fancy, configurable, notification manager for NeoVim
MIT License
3k stars 80 forks source link

Option to ignore certain messages #114

Closed Gavus closed 2 years ago

Gavus commented 2 years ago

I want to be able to avoid certain messages so that they don't popup. Is that possible?

rcarriga commented 2 years ago

nvim-notify will not do this but you can wrap nvim-notify with your own filtering.

local banned_messages = { "This is spam" }

vim.notify = function (msg, ...)

  for _, banned in ipairs(banned_messages) do
    if msg == banned then
      return
    end
  end
  require("notify")(msg, ...)
end

Though you're probably better off stopping the notification source from sending the message in the first place if possible

Gavus commented 2 years ago

Thank you! I'm trying go around getting this error here: https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/sourcery.lua#L29

Because I don't want to sign up to get a token.

gtnbssn commented 1 year ago

Been suffering from this as well, this looks like this could be a fix: https://github.com/neovim/neovim/issues/20457#issuecomment-1266782345

aemonge commented 3 months ago

That isn't working for me, I've done like this:

local banned_messages = {
    "[coc.nvim]: UnhandledRejection: TypeError: Cannot destructure property 'start' of 'range' as it is undefined.",
    "UnhandledRejection: TypeError: Cannot destructure property 'start' of 'range' as it is undefined.",
    "[telescope.builtin.buffers]: No buffers found with the provided options",
    "No buffers found with the provided options",
}

local function on_open()
    if vim.g.last_notification_id then
        require("notify").dismiss(vim.g.last_notification_id)
    end
end

local M = {
    "rcarriga/nvim-notify",
    priority = 99999,
    config = function()
        require("notify").setup({
            max_width = 90,
            background_colour = '#ffffff',
            timeout = 3500,
            top_down = false,
            -- level = vim.log.levels.WARN,
            stages = "fade_in_slide_out",
            -- render = "wrapped-compact",
            on_open = on_open
        })

        vim.notify = function(msg, ...)
            for _, banned_msg in ipairs(banned_messages) do
                if string.find(msg, banned_msg) then
                    return
                end
            end
            require("notify")(msg, ...)
        end
    end
}

return M

Any thing I've done badly ?

HarshalRathore commented 1 week ago

hello can someone help me i keep getting the buffer write messages like "/autocmd.lua" 115L, 3158B written but i don't want to see this message whenever i write so how do i solve this is my config

return {
    "folke/noice.nvim",
    event = "VeryLazy",
    opts = {
        -- add any options here
    },
    dependencies = {
        -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries
        "MunifTanjim/nui.nvim",
        -- OPTIONAL:
        --   `nvim-notify` is only needed, if you want to use the notification view.
        --   If not available, we use `mini` as the fallback
        "rcarriga/nvim-notify",
    },
    config = function()
        require("noice").setup({
            lsp = {
                -- override markdown rendering so that **cmp** and other plugins use **Treesitter**
                override = {
                    ["vim.lsp.util.convert_input_to_markdown_lines"] = true,
                    ["vim.lsp.util.stylize_markdown"] = true,
                    ["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp
                },
            },
            -- you can enable a preset for easier configuration
            presets = {
                bottom_search = true, -- use a classic bottom cmdline for search
                command_palette = true, -- position the cmdline and popupmenu together
                long_message_to_split = true, -- long messages will be sent to a split
                inc_rename = false, -- enables an input dialog for inc-rename.nvim
                lsp_doc_border = false, -- add a border to hover docs and signature help
            },
        })
    end,
}