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

Error "attempt to perform arithmetic on a nil value stack" #618

Closed
2 tasks done
will opened this issue Dec 17, 2024 · 3 comments
Closed
2 tasks done

Error "attempt to perform arithmetic on a nil value stack" #618

will opened this issue Dec 17, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@will
Copy link

will commented Dec 17, 2024

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

Hi, thanks for blink!

When any sort of noice thing pops up, like the floating command bar thing, or when doing a / search (even though I have it on the bottom) blink starts sending a lot of these errors:

Error executing vim.schedule lua callback: ...start/blink-cmp/lua/blink/cmp/config/completion/menu.lua:48: attempt to perform arithmetic on a nil value
stack traceback:
	...start/blink-cmp/lua/blink/cmp/config/completion/menu.lua:48: in function 'cmdline_position'
	...ck/mnw/start/blink-cmp/lua/blink/cmp/lib/window/init.lua:233: in function 'get_cursor_screen_position'
	...ck/mnw/start/blink-cmp/lua/blink/cmp/lib/window/init.lua:259: in function 'get_vertical_direction_and_height'
	...tart/blink-cmp/lua/blink/cmp/completion/windows/menu.lua:104: in function 'update_position'
	...tart/blink-cmp/lua/blink/cmp/completion/windows/menu.lua:59: in function 'open_with_items'
	...ck/mnw/start/blink-cmp/lua/blink/cmp/completion/init.lua:42: in function 'callback'
	.../mnw/start/blink-cmp/lua/blink/cmp/lib/event_emitter.lua:28: in function 'emit'
	...ck/mnw/start/blink-cmp/lua/blink/cmp/completion/list.lua:90: in function 'show'
	...ck/mnw/start/blink-cmp/lua/blink/cmp/completion/init.lua:34: in function <...ck/mnw/start/blink-cmp/lua/blink/cmp/completion/init.lua:29>

80a5198 seems to be the commit that introduced this error for me.

This started somewhat recently, happens on the current head b4c6fe6, and also happens in 12ffc10.

Doesn't seem to happen in fe568eb . Bisecting is a little cumbersome since I'm using blink via including it as a nix flake input and have to rebuild and check every time. I can do it'd help, but I'll hold off hoping that the stacktrace and these datapoints are enough.

Thanks for having a flake for this, it really made the dependencies a breeze :)

Relevant configuration

# blink config

```lua
  utils.packadd "friendly-snippets" -- https://github.com/rafamadriz/friendly-snippets
  utils.packadd "blink.cmp" -- https://github.com/Saghen/blink.cmp
  require("blink.cmp").setup {
    keymap = {
      ---@diagnostic disable-next-line: assign-type-mismatch
      preset = "default",
      ["<C-j>"] = { "select_next", "fallback" },
      ["<C-k>"] = { "select_prev", "fallback" },
      ["<C-l>"] = { "select_and_accept" },
    },
    completion = {
      documentation = { auto_show = true },
    },
  }

noice config

(lz.n)

  {
    "noice.nvim", -- https://github.com/folke/noice.nvim
    event = "DeferredUIEnter",
    before = function()
      utils.packadd "nui.nvim"
      utils.packadd "nvim-notify"
      require("notify").setup {
        background_colour = "#000000",
      }
      vim.keymap.set("n", "<esc>", "<esc><cmd>lua require('notify').dismiss()<cr>")
    end,
    after = function()
      require("noice").setup {
        lsp = {
          -- override markdown rendering so that **cmp** and other plugins use **Treesitter**
          override = {
            ["vim.lsp.util.convert_input_to_markdown_lines"] = true,
            ["vim.lsp.util.stylize_markdown"] = true,
          },
        },
        -- you can enable a preset for easier configuration
        presets = {
          bottom_search = true, -- use a classic bottom cmdline for search
          command_palette = true, -- position the cmdline and popupmenu together
          long_message_to_split = true, -- long messages will be sent to a split
          inc_rename = false, -- enables an input dialog for inc-rename.nvim
          lsp_doc_border = true, -- add a border to hover docs and signature help
        },
        routes = {
          {
            filter = {
              event = "msg_show",
              any = {
                { find = "%d+L, %d+B" },
                { find = "; after #%d+" },
                { find = "; before #%d+" },
              },
            },
            view = "mini",
          },
          {
            filter = {
              warning = true,
              event = "notify",
              cond = function(e)
                return vim.startswith(e:content(),  "position_encoding param is required")
              end,
            },
            opts = { skip = true },
          },
        },
      }

neovim version

NVIM v0.11.0-dev Build type: Release LuaJIT 2.1.1713773202 ( from nix-community/neovim-nightly-overlay 044f9a36ad620a119ebe154c26ec571a09f75039)

blink.cmp version: branch, tag, or commit

b4c6fe6

@will will added the bug Something isn't working label Dec 17, 2024
@will
Copy link
Author

will commented Dec 17, 2024

Actually by using the power of procrastination on other tasks, I was able to bisect to find the commit that started causing problems

[80a5198] feat: use number[] for ui_cmdline_pos

@will will changed the title Error "attempt to perform arithmetic on a nil value stack traceback" Error "attempt to perform arithmetic on a nil value stack" Dec 17, 2024
@Saghen
Copy link
Owner

Saghen commented Dec 17, 2024

Sounds like you need to update your noice.nvim. There was a moment while integrating that it returned { col = #, row = # } instead of number[]

@Saghen Saghen closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2024
@will
Copy link
Author

will commented Dec 17, 2024

Oh. I've been sticking to released versions when I can, and it looks like the fix in noice was added the exact commit after the last release, and there hasn't been any new commits nor a release in 5 days.
image

Thanks for pointing that out

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

2 participants