hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
7.71k stars 383 forks source link

When attempting to navigate suggestion list getting E5108 Error executing lua: .../custom_entries_view.lua:328: attempt to perform arithmetic on local 'cursor' (a nil value) #1994

Closed a3ng7n closed 1 month ago

a3ng7n commented 1 month ago

FAQ

Announcement

Minimal reproducible full config

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
    vim.api.nvim_echo({
      { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
      { out, "WarningMsg" },
      { "\nPress any key to exit..." },
    }, true, {})
    vim.fn.getchar()
    os.exit(1)
  end
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
  spec = {
    -- add LazyVim and import its plugins
    { "LazyVim/LazyVim", import = "lazyvim.plugins" },
    { import = "lazyvim.plugins.extras.dap.core" },
    { import = "lazyvim.plugins.extras.lang.python" },
    -- import/override with your plugins
    { import = "plugins" },
  },
  defaults = {
    -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
    -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
    lazy = false,
    -- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
    -- have outdated releases, which may break your Neovim install.
    version = false, -- always use the latest git commit
    -- version = "*", -- try installing the latest stable version for plugins that support semver
  },
  install = { colorscheme = { "tokyonight", "habamax" } },
  checker = { enabled = true }, -- automatically check for plugin updates
  performance = {
    rtp = {
      -- disable some rtp plugins
      disabled_plugins = {
        "gzip",
        -- "matchit",
        -- "matchparen",
        -- "netrwPlugin",
        "tarPlugin",
        "tohtml",
        "tutor",
        "zipPlugin",
      },
    },
  },
})

Description

When attempting to navigate any suggestion entries I get this error:

E5108: Error executing lua: .../nvim/lazy/nvim-cmp/lua/cmp/view/custom_entries_view.lua:328: attempt to perform arithmetic on local 'cursor' (a nil value)
stack traceback:
    .../nvim/lazy/nvim-cmp/lua/cmp/view/custom_entries_view.lua:328: in function 'select_next_item'
    ...e/aaron/.local/share/nvim/lazy/nvim-cmp/lua/cmp/view.lua:224: in function 'select_next_item'
    ...e/aaron/.local/share/nvim/lazy/nvim-cmp/lua/cmp/init.lua:146: in function 'select_next_item'
    ...ocal/share/nvim/lazy/nvim-cmp/lua/cmp/config/mapping.lua:202: in function 'on_keymap'
    ...e/aaron/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:145: in function 'callback'
    ....local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/keymap.lua:133: in function <....local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/keymap.lua:127>

My config (attached) is pretty much a bone stock LazyVim configuration.

Steps to reproduce

  1. open any file
  2. insert mode
  3. start typing anything to get suggestions
  4. attempt to navigate the list of suggestions

Expected behavior

I would expect it to not show the error

Actual behavior

It shows the error, and the navigation seems to get stuck/halted until entering normal mode, then re-entering insert again.

Additional context

No response

bew commented 1 month ago

Please search open issues with the error msg for example. Existing issue about this: https://github.com/hrsh7th/nvim-cmp/issues/1988

You can close your issue and subscribe on that other one to be notified on progress.

Shougo commented 1 month ago

Please test this.

https://github.com/hrsh7th/nvim-cmp/pull/1993

a3ng7n commented 1 month ago

Please search open issues with the error msg for example. Existing issue about this: #1988

You can close your issue and subscribe on that other one to be notified on progress.

Oh, so sorry - I did a couple dozen google searches but that never showed up!

Please test this.

1993

Will do.