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

Request: Add noice support #76

Open
ColinKennedy opened this issue Dec 29, 2024 · 7 comments
Open

Request: Add noice support #76

ColinKennedy opened this issue Dec 29, 2024 · 7 comments
Labels
enhancement New feature or enhancement

Comments

@ColinKennedy
Copy link

When one has smear-cursor.nvim + noice.nvim installed at the same time, the cursor animation should move to the pop-up UI window. But it still goes to the old lower-left command window. See the GIF for a visual representation.

2024-12-28.16-49-08.mp4

It'd be nice if smear-cursor.nvim could animate to wherever the command line start is, even that position is not at the (default) bottom of the screen.

I don't have a clear suggestion on how to implement it. But I did see this in the noice code:

https://github.com/folke/noice.nvim/blob/791eb70fd9257b76941c81a32e852fdfa1c4915b/lua/noice/ui/init.lua#L121-L130

There's also a (small amount of) help docs, :h vim.ui_attach(), that might help

        ns = vim.api.nvim_create_namespace('my_fancy_pum')

        vim.ui_attach(ns, {ext_popupmenu=true}, function(event, ...)
          if event == "popupmenu_show" then
            local items, selected, row, col, grid = ...
            print("display pum ", #items)

        -- ...
@ColinKennedy ColinKennedy added the enhancement New feature or enhancement label Dec 29, 2024
@sphamba
Copy link
Owner

sphamba commented Dec 30, 2024

I just added a smear_to_cmd configuration parameter #77. In the meantime, does setting it to false solve the issue?

@PumpkinKnightStudio
Copy link

Hi, I just tried it and The animation still wont play within the CMD (Noice) but it does stop moving to the left bottom which mean the config is working.

@ColinKennedy
Copy link
Author

I just added a smear_to_cmd configuration parameter #77. In the meantime, does setting it to false solve the issue?

I won't be at my main computer for a few days. I'll check back in before this weekend

@ColinKennedy
Copy link
Author

Hi, smear_to_cmd does remove animations though FWIW I'd rather not use it because if this is fixed in the future, I might miss that update. I'll keep everything enabled even if the animation normal -> cmd -> normal animation is a little wonky for the time being

@sphamba
Copy link
Owner

sphamba commented Jan 5, 2025

The issue potentially comes from noice setting a custom cursor position. I could override the vim.api.nvim_win_set_cursor function to trigger the smear animation, but that's a bit dirty. Let me know if you have another idea.

@ColinKennedy
Copy link
Author

ColinKennedy commented Jan 5, 2025

I guess it depends on who calls what first. Is the issue that smear-cursor.nvim is triggering before noice.nvim sets the cursor position? Or is it that smear-cursor.nvim does run in the correct order but vim.fn.screenrow() and vim.fn.screencol() report incorrect values which causes cursor to move to the wrong position?

Assuming Incorrect Values (And The Call Order Is Already Correct)

We know from #9 (comment) that command mode in Neovim can have some weird redraw / rendering issues. Maybe it's a situation where a redraw is needed and then screenrow / screencol report the right information.

If not that then maybe it's a bug that needs to go to Neovim core. If screenrow / screencol aren't reporting accurate information in command mode then there isn't much that can be done.

Assuming Incorrect Call Order (And It Is Not Incorrect Values)

Considering noice.nvim overrides other plugin's function calls with its own, smear-cursor.nvim may want to do the same to noice.nvim.

Something like

(somewhere in smear-cursor.nvim)

local success, cmdline = pcall("noice.ui.cmdline")

if success then
    local function _override(original)
        -- Your preamble code, as needed
        original()
        -- Your post code, as needed
    end

    cmdline.fix_cursor = _override(cmdline.fix_cursor)
end

@GNRSN
Copy link

GNRSN commented Jan 14, 2025

The issue potentially comes from noice setting a custom cursor position. I could override the vim.api.nvim_win_set_cursor function to trigger the smear animation, but that's a bit dirty. Let me know if you have another idea.

Noice itself and notification plugins such as snacks-notify or nvim-notify handles notifications by overriding vim.notify. Personally, I think this is ok when there is no better option. Epecially when it is something as general/global as a interfering with the cursor or notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants