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

Input delay when using ray-x/lsp_signature.nvim #1613

Open
2 tasks done
mgnsk opened this issue Jun 9, 2023 · 1 comment
Open
2 tasks done

Input delay when using ray-x/lsp_signature.nvim #1613

mgnsk opened this issue Jun 9, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@mgnsk
Copy link

mgnsk commented Jun 9, 2023

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    {
        "ray-x/lsp_signature.nvim",
    },
    {
        "neovim/nvim-lspconfig",
        config = function()
            local lsp = require("lspconfig")
            local capabilities = vim.lsp.protocol.make_client_capabilities()

            local function on_attach(client, bufnr)
                require("lsp_signature").on_attach({}, bufnr)
            end

            lsp.gopls.setup({ capabilities = capabilities, on_attach = on_attach })

            vim.lsp.handlers["textDocument/publishDiagnostics"] =
                vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
                    update_in_insert = false,
                })
        end,
    },
    {
        "hrsh7th/nvim-cmp",
        commit = "09ff53f",
        dependencies = {
            "hrsh7th/cmp-nvim-lsp",
        },
        config = function()
            local cmp = require("cmp")
            cmp.setup({
                snippet = {
                    expand = function(args) end,
                },
                sources = {
                    { name = "nvim_lsp" },
                },
                mapping = {
                    ["<Tab>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "s" }),
                    ["<CR>"] = cmp.mapping(cmp.mapping.confirm({
                        behavior = cmp.ConfirmBehavior.Insert,
                        select = true,
                    })),
                },
            })
        end,
    },
})

Description

The input delay was supposedly fixed (#1606, #1608) but the issue is still there. Also linking a related issue: ray-x/lsp_signature.nvim#273.

Steps to reproduce

Repro (requires docker):

git clone https://github.com/mgnsk/nvim-cmp-stutter-repro.git
cd nvim-cmp-stutter-repro
bash build.sh
bash run.sh

Now move inside a go function, type append(, wait for the signature and completion to pop up and try to type the letter c 4 times as fast as possible. It seems to occur in about 4 out of 5 attempts.

Expected behavior

Expected no stutter.

Actual behavior

Recording of the stutter with ray signature in use: https://asciinema.org/a/EMs6LU8QXUYntcm9Gkf3oy58l

Without ray signature, no stutter: https://asciinema.org/a/KMSlHcFPWyPKw1yJNhinwCH56

Additional context

As a hack, the stutter goes away when this function:

---Return view is visible or not.
cmp.visible = cmp.sync(function()
return cmp.core.view:visible() or vim.fn.pumvisible() == 1
end)

is changed to

---Return view is visible or not.
cmp.visible = function()
  return cmp.core.view:visible() or vim.fn.pumvisible() == 1
end

indicating that the delay comes from cmp.sync().

@mgnsk mgnsk added the bug Something isn't working label Jun 9, 2023
deathmaz added a commit to deathmaz/dotfiles that referenced this issue Jun 10, 2023
the issue was due to `ray-x/lsp_signature.nvim`
hrsh7th/nvim-cmp#1613
@mgnsk
Copy link
Author

mgnsk commented Jun 16, 2023

It seems to be introduced in #1583. The commit before that didn't stutter.

The cmp.visible() function was made synchronous in 0d23640

It seems like these functions should be synchronous with regards to the global filter and not with regards to the UI.

Also in ray signature, I tried completely removing the call to cmp.visible() and it still worked, without the stutter now. So maybe something can be done there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant