r/neovim•
braxtons12

show vim.lsp.buf.hover on CursorHold?

How can I get the vim.lsp.buf.hover to show on CursorHold, without triggering its second call and jumping into the hover float?

Currently I've found the below, but this only works once and then never hovers again.

vim.api.nvim_create_autocmd(
    "CursorHold",
    {
        pattern = {"*"},
        callback = function()
            if not require("cmp").visible() then
                local hover_fixed = function()
                    vim.api.nvim_command("set eventignore=CursorHold")
                    vim.api.nvim_command("autocmd CursorMoved ++once set eventignore=\" \" ")
                    vim.lsp.buf.hover()
                end
                hover_fixed()
            end
        end
    }, 
)

Posted Jun 9, 2022, 7:42 AM UTC

22
Loading comments…