ThePrimeagen / harpoon

MIT License
6.25k stars 348 forks source link

Error on attaching to list: Attempt to call method 'list' (a nil value) #613

Closed JordanBourne closed 3 days ago

JordanBourne commented 1 week ago

Trying to use Harpoon2 and running into an issue after initialization and on the first time I am trying to add a file to the harpoon list:

E5108: Error executing lua: /Users/jordanbourne/.config/nvim/init.lua:574: attempt to call method 'list' (a nil value)
stack traceback:
        /Users/jordanbourne/.config/nvim/init.lua:574: in function </Users/jordanbourne/.config/nvim/init.lua:573>

This is my config:

{
    'ThePrimeagen/harpoon',
    branch = 'harpoon2',
    opts = {
      menu = {
        width = vim.api.nvim_win_get_width(0) - 4,
      },
      settings = {
        save_on_toggle = true,
      },
    },
    keys = function()
      local keys = {
        {
          '<leader>H',
          function()
            require('harpoon'):list():add()
          end,
          desc = 'Harpoon File',
        },
        {
          '<leader>h',
          function()
            local harpoon = require 'harpoon'
            harpoon.ui:toggle_quick_menu(harpoon:list())
          end,
          desc = 'Harpoon Quick Menu',
        },
      }

      for i = 1, 5 do
        table.insert(keys, {
          '<leader>' .. i,
          function()
            require('harpoon'):list():select(i)
          end,
          desc = 'Harpoon to File ' .. i,
        })
      end
      return keys
    end,
  }

Note: I also tried a fresh nvim config install on the LazyVim setup and was running into the same issue.

JordanBourne commented 3 days ago

Must have had a bad install or something - removed the package from ~/.local/share/nvim/lazy and reinstalled it and ended up working.