Bekaboo / dropbar.nvim

IDE-like breadcrumbs, out of the box
GNU General Public License v3.0
1.05k stars 24 forks source link

[Bug]: attempt to call field 'iter' (a nil value) #1

Closed nicktify closed 1 year ago

nicktify commented 1 year ago

Description

Hello. I'm having a problem after installation.

Just after installing, I open a .js file and the error attempt to call field 'iter' (a nil value) appears.

I search for the function iter in the codebase of the dropbar .lua files and comment the following code and all works perfectly.

The code is in lua/sources/lsp.lua line 288

-- Code uncommented doesn't work
  for idx, symbol in vim.iter(lsp_symbols):enumerate():rev() do
    if cursor_in_range(cursor, symbol.range) then
      table.insert(
        dropbar_symbols,
        utils.to_dropbar_symbol(unify_document_symbol(symbol, lsp_symbols, idx))
      )
      if symbol.children then
        convert_document_symbol_list(symbol.children, dropbar_symbols, cursor)
      end
      return
    end
  end
--  This code commented, all works perfectly
  -- for idx, symbol in vim.iter(lsp_symbols):enumerate():rev() do
  --   if cursor_in_range(cursor, symbol.range) then
  --     table.insert(
  --       dropbar_symbols,
  --       utils.to_dropbar_symbol(unify_document_symbol(symbol, lsp_symbols, idx))
  --     )
  --     if symbol.children then
  --       convert_document_symbol_list(symbol.children, dropbar_symbols, cursor)
  --     end
  --     return
  --   end
  -- end

nvim version

NVIM v0.9.1

dropbar.nvim version

7ae61cc14877dcfe5e127b8c66c87247b1ef2eaa

Operating system and version

MacOS 13.3.1

Minimal config

require('dropbar').setup()

Steps to reproduce

  1. Install with Packer use('Bekaboo/dropbar.nvim')
  2. require('dropbar').setup()
  3. Open a javascript file

Expected behavior

Work without errors

Actual behavior

Error executing vim.schedule lua callback: ...ck/packer/start/dropbar.nvim/lua/dropbar/sources/lsp.lua:288: attempt to call fi
eld 'iter' (a nil value)
stack traceback:
        ...ck/packer/start/dropbar.nvim/lua/dropbar/sources/lsp.lua:288: in function 'convert_document_symbol_list'
        ...ck/packer/start/dropbar.nvim/lua/dropbar/sources/lsp.lua:311: in function 'get_symbols'
        ...e/pack/packer/start/dropbar.nvim/lua/dropbar/configs.lua:119: in function 'get_symbols'
        .../site/pack/packer/start/dropbar.nvim/lua/dropbar/bar.lua:280: in function 'update'
        ...ck/packer/start/dropbar.nvim/lua/dropbar/sources/lsp.lua:343: in function 'handler'
        ...w/Cellar/neovim/0.9.1/share/nvim/runtime/lua/vim/lsp.lua:1394: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Additional information

No response

Bekaboo commented 1 year ago

Sorry about the inconvenience! I made a mistake about the nvim version required for this plugin, actually it is required to have nvim nightly (>= 0.10.0) for dropbar.nvim to work since the vim.iter module is new feature introduced in nvim nightly. Thanks for reporting.