kevinhwang91 / nvim-hlslens

Hlsearch Lens for Neovim
BSD 3-Clause "New" or "Revised" License
748 stars 10 forks source link

Throwing some errors (wrong number of arguments; nil value `sList`) #70

Closed daUnknownCoder closed 3 months ago

daUnknownCoder commented 3 months ago

Describe the bug I'm getting some weirdo errors: (Doesnt happen of plugin load, only happens when we use the plugin explicitly) First Error:

Error executing vim.schedule lua callback: .../share/NeutronVim/lazy/nvim-hlslens/lua/hlslens/wffi.lua:24: wrong number of arguments for function call
stack traceback:
    [C]: in function 'ml_get_buf'
    .../share/NeutronVim/lazy/nvim-hlslens/lua/hlslens/wffi.lua:24: in function 'mlGetBufLen'
    ...m/lazy/nvim-hlslens/lua/hlslens/position/range/regex.lua:33: in function 'buildList'
    ...utronVim/lazy/nvim-hlslens/lua/hlslens/position/init.lua:71: in function 'compute'
    ...NeutronVim/lazy/nvim-hlslens/lua/hlslens/render/init.lua:84: in function 'refreshCurrentBuf'
    ...NeutronVim/lazy/nvim-hlslens/lua/hlslens/render/init.lua:424: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>

Second error (every time i call the plugin 2 times for each use)

Error executing vim.schedule lua callback: ...NeutronVim/lazy/nvim-hlslens/lua/hlslens/render/init.lua:89: attempt to get length of field 'sList' (a nil value)
stack traceback:
    ...NeutronVim/lazy/nvim-hlslens/lua/hlslens/render/init.lua:89: in function 'refreshCurrentBuf'
    ...NeutronVim/lazy/nvim-hlslens/lua/hlslens/render/init.lua:424: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>

To Reproduce using nvim -u mini.lua

return {
  "kevinhwang91/nvim-hlslens",
  event = { "CmdlineEnter", "BufReadPost", "BufNewFile" },
  enabled = true,
  keys = {
    {
      "n",
      [[<cmd>execute('normal! ' . v:count1 . 'n')<cr>]] .. [[<cmd>lua require("hlslens").start()<cr>]],
    },
    {
      "N",
      [[<cmd>execute('normal! ' . v:count1 . 'N')<cr>]] .. [[<cmd>lua require("hlslens").start()<cr>]],
    },
    { "*", "*" .. [[<cmd>lua require("hlslens").start()<cr>]] },
    { "#", "#" .. [[<cmd>lua require("hlslens").start()<cr>]] },
    { "g*", "g*" .. [[<cmd>lua require("hlslens").start()<cr>]] },
    { "g#", "g#" .. [[<cmd>lua require("hlslens").start()<cr>]] },
  },
  config = true,
}

Steps to reproduce the behavior:

  1. go to CmdLine and /<search term> or n or N
  2. the first error pops up, every time u do a related keypress, the second error pops up 2 times

Expected behavior It should not throw any error

Screenshots image

daUnknownCoder commented 3 months ago

What was happening tho? Because your last commit was 2 months ago and this happened recently?

kevinhwang91 commented 3 months ago

Don't use lazy, I am not sure the issue existed before, but the code has a bug.

daUnknownCoder commented 3 months ago

Don't use lazy, I am not sure the issue existed before, but the code has a bug.

What should be the loading event? Or should I do lazy = false?

kevinhwang91 commented 3 months ago

The bug should be gone for this issue.

daUnknownCoder commented 3 months ago

The bug should be gone for this issue.

i still cannot use this i still get both wffi and sList error

Edit: i get a new cFunc error:

Error executing vim.schedule lua callback: ...NeutronVim/lazy/hlchunk.nvim/lua/hlchunk/utils/cFunc.lua:47: wrong number of arguments for function call
stack traceback:
    [C]: in function 'ml_get_buf'
    ...NeutronVim/lazy/hlchunk.nvim/lua/hlchunk/utils/cFunc.lua:47: in function 'get_line'
    ...tronVim/lazy/hlchunk.nvim/lua/hlchunk/utils/position.lua:21: in function 'get_char_at_pos'
    ...ronVim/lazy/hlchunk.nvim/lua/hlchunk/mods/chunk/init.lua:101: in function 'get_chunk_data'
    ...ronVim/lazy/hlchunk.nvim/lua/hlchunk/mods/chunk/init.lua:131: in function 'render'
    ...ronVim/lazy/hlchunk.nvim/lua/hlchunk/mods/chunk/init.lua:187: in function 'fn'
    ...NeutronVim/lazy/hlchunk.nvim/lua/hlchunk/utils/timer.lua:64: in function 'fn'
    ...NeutronVim/lazy/hlchunk.nvim/lua/hlchunk/utils/timer.lua:16: in function <...NeutronVim/lazy/hlchunk.nvim/lua/hlchunk/utils/timer.lua:15>
daUnknownCoder commented 3 months ago

with this config:

  {
    "kevinhwang91/nvim-hlslens",
    event = { "CmdlineEnter", "LazyFile" },
    enabled = true,
    keys = {
      {
        "n",
        [[<cmd>execute('normal! ' . v:count1 . 'n')<cr>]] .. [[<cmd>lua require("hlslens").start()<cr>]],
      },
      {
        "N",
        [[<cmd>execute('normal! ' . v:count1 . 'N')<cr>]] .. [[<cmd>lua require("hlslens").start()<cr>]],
      },
      { "*", "*" .. [[<cmd>lua require("hlslens").start()<cr>]] },
      { "#", "#" .. [[<cmd>lua require("hlslens").start()<cr>]] },
      { "g*", "g*" .. [[<cmd>lua require("hlslens").start()<cr>]] },
      { "g#", "g#" .. [[<cmd>lua require("hlslens").start()<cr>]] },
    },
    opts = {
      override_lens = function(render, posList, nearest, idx, relIdx)
        local sfw = vim.v.searchforward == 1
        local indicator, text, chunks
        local absRelIdx = math.abs(relIdx)
        if absRelIdx > 1 then
          indicator = ("%d%s"):format(absRelIdx, sfw ~= (relIdx > 1) and "▲" or "▼")
        elseif absRelIdx == 1 then
          indicator = sfw ~= (relIdx == 1) and "▲" or "▼"
        else
          indicator = ""
        end

        local lnum, col = unpack(posList[idx])
        if nearest then
          local cnt = #posList
          if indicator ~= "" then
            text = ("[%s %d/%d]"):format(indicator, idx, cnt)
          else
            text = ("[%d/%d]"):format(idx, cnt)
          end
          chunks = { { " " }, { text, "HlSearchLensNear" } }
        else
          text = ("[%s %d]"):format(indicator, idx)
          chunks = { { " " }, { text, "HlSearchLens" } }
        end
        render.setVirt(0, lnum - 1, col - 1, chunks, nearest)
      end,
    },
    config = true,
  },

im only getting the above cFunc error

kevinhwang91 commented 3 months ago
hlchunk.nvim

what's hlchunk.nvim?

daUnknownCoder commented 3 months ago
hlchunk.nvim

what's hlchunk.nvim?

sorry thats another plugin but the name was similar 😞, tho this hasnt been fixed

the first time its wffi, then init.lua

Error executing vim.schedule lua callback: ...NeutronVim/lazy/nvim-hlslens/lua/hlslens/render/init.lua:89: attempt to get length of field 'sList' (a nil value)
stack traceback:
    ...NeutronVim/lazy/nvim-hlslens/lua/hlslens/render/init.lua:89: in function 'refreshCurrentBuf'
    ...NeutronVim/lazy/nvim-hlslens/lua/hlslens/render/init.lua:424: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
daUnknownCoder commented 3 months ago

works ~arigato~ Thanks a lot, just one more thing: can i disable this: image the blue part -> but current_line_blame by gitsigns stays in between the orange and blue part so i wanna completely disable the blue part

kevinhwang91 commented 3 months ago

maybe other plugins render /return [3/6] with cyan color.

shellRaining commented 3 months ago

maybe other plugins render /return [3/6] with cyan color.

I remember it seems like the information displayed by noice.nvim

by the way, I can't reproduce this bug, Has it been fixed already?

daUnknownCoder commented 3 months ago

maybe other plugins render /return [3/6] with cyan color.

I remember it seems like the information displayed by noice.nvim

by the way, I can't reproduce this bug, Has it been fixed already?

yes its fixed, oh was it noice, thanks for that

daUnknownCoder commented 3 months ago

this thing is fixed thanks buddy for ur time