folke / noice.nvim

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

bug: Notifications seems block `ui.select` #938

Open ragu-manjegowda opened 2 months ago

ragu-manjegowda commented 2 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10.1

Operating system/version

Arch Linux

Describe the bug

When there is notification, ui.select seems to be blocked from being shown. Hitting escape/q makes it visible and disappear without taking any input.

Issue appears with both nvim-notify and mini Issue appears with notify.replace = true

Steps To Reproduce

  1. Open nvim with provided repro.lua
  2. Use keymap to trigger notification followed by ui.select

Expected Behavior

Destroy the notification or move it down and let ui.select come to foreground and accept user input.

Repro

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

require("lazy.minit").repro({
    spec = {
        {
            "folke/noice.nvim",
            config = true,
            event = "VeryLazy",
            dependencies = {
                "MunifTanjim/nui.nvim",
                -- "rcarriga/nvim-notify",
            }
        }
    }
})

local function get_selection(choices, selection_opts)
    local co = coroutine.running()
    local selection_made = false
    local selected_choice = nil

    vim.schedule(function()
        vim.ui.select(choices, selection_opts, function(choice)
            selection_made = true
            selected_choice = choice
            if co then
                coroutine.resume(co)
            end
        end)
    end)

    if co and not selection_made then
        coroutine.yield()
    end
    return selected_choice
end

local function test_input()
    vim.notify("Send notification")
    local os_choices = {
        "Linux",
        "macOS",
        "Windows",
    }

    get_selection(os_choices, {
        prompt = ("Choose remote OS (found OS '%s'): "):format(os),
        format_item = function(item)
            return ("Remote host is running %s"):format(item)
        end,
    })
end

vim.g.mapleader = " "

vim.api.nvim_set_keymap('n', '<leader>t', '', {
    noremap = true,
    callback = test_input
})
Vladmel1234 commented 2 months ago

I have the same issue, The workaround of downgrading to 4.4.7 also worked for this issue.

gbelouze commented 2 months ago

Downgrading did not solve this for me. However hacking into vim.ui.select, for instance by installing telescope-ui-select.nvim, did it.

zayihu commented 2 months ago

+1, installed dressing.nvim to fix this behavior, disabled input, only need vim.ui.select, otherwise I see my code actions in notifications?!

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

nicholascross commented 1 month ago

This is still an issue. Confirming work around of using dressing.nvim (defaulting to telescope) for selection worked well for me.

dapetcu21 commented 2 weeks ago

This is an issue, yes. It seems to be because ui.select() seems to want synchroneous user input, so nvim-notify only gets the chance to render the first frame of the notification animation. As a workaround, I modified the default animation to skip the fade-in animation, which I actually seem to prefer.

As a more permanent fix, I think we need a better UI for selections instead of relying on nvim-notify?

https://github.com/dapetcu21/nvim-notify/tree/slide-out

  {
    "dapetcu21/nvim-notify",
    branch = "slide-out",

    config = function ()
      local notify = require("notify")

      notify.setup({
        render = "wrapped-compact",
        stages = "slide_out", -- <==== This is the workaround
      })
      vim.notify = notify
    end,
  },
Jay-Madden commented 2 weeks ago

I am also facing this issue. Installing telescope-ui-select allowed me to get around this.

miguno commented 19 hours ago

+1, still an issue. Code actions are shown in notifications and therefore cannot be selected.

My workaround was to install https://github.com/nvim-telescope/telescope-ui-select.nvim, as suggested in https://github.com/folke/noice.nvim/issues/938#issuecomment-2313075221 and https://github.com/folke/noice.nvim/issues/938#issuecomment-2414908707.