nvim-cmp icon indicating copy to clipboard operation
nvim-cmp copied to clipboard

performance.throttle not delaying appearence of completion menu

Open paride opened this issue 11 months ago • 2 comments

FAQ

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

Announcement

Minimal reproducible full config

Neovim init.lua:

local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
  local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
  if vim.v.shell_error ~= 0 then
    error('Error cloning lazy.nvim:\n' .. out)
  end
end
vim.opt.rtp:prepend(lazypath)

require('lazy').setup({
  {
    'hrsh7th/nvim-cmp',
    event = 'InsertEnter',
    dependencies = {
      'hrsh7th/cmp-buffer',
    },
    config = function()
      local cmp = require 'cmp'
      cmp.setup {
        mapping = cmp.mapping.preset.insert(),
        sources = {
          { name = 'buffer' },
        },
        performance = {
          throttle = 2000,
        },
      }
    end
  },
})

Description

The throttle = 2000 setting is not honored: the completion menu appears almost immediately while typing.

Steps to reproduce

  1. Configure neovim (latest 0.11 nightly) with the provided config
  2. echo foobar >> test.txt
  3. Open test.txt with nvim, add a new line and start typing foo
  4. Observe how the foobar completion appears almost immediately, and not after 2000ms.

Expected behavior

The completion menu only appears only after nothing is typed for 2000ms.

Actual behavior

The completion menu appears almost immediately while typing.

Additional context

This is not specific to cmp-buffer, but using cmp-buffer makes an easy reproducer because we don't need to configure any LSP or similar.

paride avatar Jan 13 '25 14:01 paride

I also tried with performance.debounce, but that doesn't seem to really help.

paride avatar Jan 13 '25 14:01 paride

setting debounce=1000 should work.

xzbdmw avatar Jan 20 '25 10:01 xzbdmw