folke / noice.nvim

💥 Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu.
Apache License 2.0
4.36k stars 101 forks source link

bug(vim-visual-multi): Notification window doesn't expand or have black color #913

Closed ilias777 closed 2 months ago

ilias777 commented 2 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.11.0-dev-219+gc37695a5d-Homebrew

Operating system/version

MacOS 14.5

Describe the bug

The notifications that comes from vim-visual-multi are not expand if stages = 'slide' in the notify options and it's not possible to see the content.

slide_1 slide_2

If slides is set to fade the color is black or sometime the same color as the background.

black_1 black_2

If you look here closely the notification color is same as the background. After the l in the second line you can see the icon from the notification:

same_as_bg

Steps To Reproduce

  1. Run: nvim -u repro.lua.
  2. After lazy installing the plugins open the file with the command :e repro.lua.
  3. Press following keys: <C-n> to start vim-visual-multi and then the keys: \\C to open the notification window to switch the case in this example.
  4. You will see that the notification window is not expanding.
  5. Try to change the stages to fade or fade_in_slide_out.
  6. Press the same keys like in step 3.
  7. The notification window now is black or the same color as the background.

Expected Behavior

The notification window opens full as expected or they have the expected color.

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

vim.g.mapleader = ','
vim.g.maplocalleader = ','

vim.opt.autoindent = true
vim.opt.smartindent = true
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
vim.opt.expandtab = true

require("lazy.minit").repro({
    spec = {
        {
            'nvim-treesitter/nvim-treesitter',
            build = ':TSUpdate',
            config = function()
                require('nvim-treesitter.configs').setup({
                    ensure_installed = {
                        'lua'
                    },
                })
            end
        },
        {
        "mg979/vim-visual-multi",
            branch = "master",
            event = 'VeryLazy',
            keys = {
                      { 'cp', 'vip<Plug>(VM-Visual-Cursors)', desc = 'Create multicursors inner paragraph' },
                      { '<M-s>', ':VMSearch ', mode = 'x', desc = 'Search & create multicursors in visual mode' },
                      { '<M-s>', ':%VMSearch ', desc = 'Search & create multicursors' },
                      { '<M-c>', '<Plug>(VM-Visual-Cursors)', mode = 'x', desc = 'Create multicursors in visual mode' },
            },
            init = function()
                vim.g.VM_maps = {
                    ['Motion ,'] = '',
                    ['Select l'] = '<C-Right>',
                    ['Select h'] = '<C-Left>',
                    ['Goto Next'] = '',
                    ['Goto Prev'] = '',
                    -- ['I BS'] = '',
                }
            end
        },
        {
            "folke/which-key.nvim",
            opts = {
                preset = 'helix',
            },
        },
            {
            "folke/noice.nvim",
            dependencies = {
                "MunifTanjim/nui.nvim",
                {
                    "rcarriga/nvim-notify",
                    opts = {
                        render = 'wrapped-compact',
                        stages = 'slide,
                        max_height = function()
                            return math.floor(vim.o.lines * 0.75)
                        end,
                        max_width = function()
                            return math.floor(vim.o.columns * 0.75)
                        end,
                    },
                },
            },
            opts = {}
        },
    },
})
folke commented 2 months ago

That's not noice? You even specify it's an option to nvim-notify?

ilias777 commented 2 months ago

I thought that was an noice issue, because noice uses nvim-notify. Ok I try to set this issue in nvim-notify.

Sorry for the "noice" 😅

folke commented 2 months ago

After further looking into this, this is indeed something that worked before. Reason it used to work, is that in Noice I hacked into vim.cmd.redraw and any of the getchar and input functions. When I detected that we were right before or inside such a function, I replaced stage to static.

I did it like that, because I thought that when Neovim was waiting for input, the main loop was blocked.

Recently I discovered this is simply not the case.

tbh, this hack was something I probably never should have done.

The correct fix is to add vim.cmd.redraw() calls when needed inside nvim-notify.

ilias777 commented 2 months ago

Do you know maybe if it's possible to send these notifications to dressing.nvim and skip nvim-notify notification for that specific case? I read the dressing docs, but I didn't find something that I can use for vim-visual-multi.

The only solution that I found and it's working, is to complete disable Noice if vim-visual-multi is running with this autocommand:

local visual_multi_group = vim.api.nvim_create_augroup('VisualMulti', { clear = true })
vim.api.nvim_create_autocmd('User', {
    pattern = 'visual_multi_start',
    callback = function()
        vim.cmd('NoiceDisable')
        vim.lsp.inlay_hint.enable(false)
    end,
    group = visual_multi_group,
})
vim.api.nvim_create_autocmd('User', {
    pattern = 'visual_multi_exit',
    callback = function()
        vim.cmd('NoiceEnable')
        vim.lsp.inlay_hint.enable(true)
    end,
    group = visual_multi_group,
})

Can I do something with vim.cmd.redraw(), maybe with this autocommand, or has this to be fix on nvim-notify side?

folke commented 2 months ago

In LAzyVim I just always use opts.stages = 'static' for nvim-notify

ilias777 commented 2 months ago

I tested with static and it works for me as well now, but no with the other ones. Thank you.