willothy / nvim-cokeline

:nose: A Neovim bufferline for people with addictive personalities
MIT License
548 stars 38 forks source link

E5108: Error executing lua: cokeline/lua/cokeline/buffers.lua:94: attempt to call method 'enumerate' (a nil value) #183

Closed Zombiefleischer closed 10 months ago

Zombiefleischer commented 10 months ago

Hi, I'm getting the following error, when hovering with the mouse over a buffer with vim.opt.mousemoveevent = true

E5108: Error executing lua: ...vim/site/pack/lazy/opt/cokeline/lua/cokeline/buffers.lua:94: attempt to call method 'enumerate' (a nil value)
stack traceback:
        ...vim/site/pack/lazy/opt/cokeline/lua/cokeline/buffers.lua:94: in function 'compute_unique_prefixes'
        ...vim/site/pack/lazy/opt/cokeline/lua/cokeline/buffers.lua:417: in function 'get_valid_buffers'
        ...vim/site/pack/lazy/opt/cokeline/lua/cokeline/buffers.lua:468: in function 'get_visible'
        ...arvim/site/pack/lazy/opt/cokeline/lua/cokeline/hover.lua:38: in function 'get_current'
        ...arvim/site/pack/lazy/opt/cokeline/lua/cokeline/hover.lua:156: in function 'on_hover'
        ...arvim/site/pack/lazy/opt/cokeline/lua/cokeline/hover.lua:314: in function <...arvim/site/pack/lazy/opt/cokeline/lua/cokeline/hover.lua:311>

When disabling the option, I still get the error when opening vim, but from a different source:

E5108: Error executing lua ...vim/site/pack/lazy/opt/cokeline/lua/cokeline/buffers.lua:94: attempt to call method 'enumerate' (a nil value)
stack traceback:
        ...vim/site/pack/lazy/opt/cokeline/lua/cokeline/buffers.lua:94: in function 'compute_unique_prefixes'
        ...vim/site/pack/lazy/opt/cokeline/lua/cokeline/buffers.lua:417: in function 'get_valid_buffers'
        ...vim/site/pack/lazy/opt/cokeline/lua/cokeline/buffers.lua:468: in function 'get_visible'
        ...narvim/site/pack/lazy/opt/cokeline/lua/cokeline/init.lua:27: in function <...narvim/site/pack/lazy/opt/cokeline/lua/cokeline/init.lua:26>

I'm running lunarvim release-1.3/neovim-0.9-d1c1bace and neovim v0.9.4

This is my lunarvim (bare minimum testing) config.lua

```lua -- Read the docs: https://www.lunarvim.org/docs/configuration -- Video Tutorials: https://www.youtube.com/watch?v=sFA9kX-Ud_c&list=PLhoH5vyxr6QqGu0i7tt_XoVK9v-KvZ3m6 -- Forum: https://www.reddit.com/r/lunarvim/ -- Discord: https://discord.com/invite/Xb9B4Ny -- lvim.builtin.nvimtree.setup.view.relativenumber = true vim.opt.shiftwidth = 2 vim.opt.tabstop = 2 vim.opt.relativenumber = true vim.opt.wrap = true vim.opt.mousemoveevent = true lvim.transparent_window = true lvim.colorscheme = "nord" -- Set soft-wrap text at the edge of the window vim.cmd("set textwidth=0") vim.cmd("set wrapmargin=0") vim.cmd("set wrap") vim.cmd("set linebreak") -- Set colored line at 80 and 160 column vim.cmd("set colorcolumn=80,160") lvim.builtin.nvimtree.active = false -- Note: Using neo-tree lvim.builtin.bufferline.active = false -- Note: Using cokeline vim.cmd("set termguicolors") -- install plugins via lazy lvim.plugins = { { "nordtheme/vim", name = "nord" }, { "sindrets/diffview.nvim", event = "BufRead", }, { "nvim-neo-tree/neo-tree.nvim", branch = "v2.x", dependencies = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons", "MunifTanjim/nui.nvim", }, config = function() require("neo-tree").setup({ event_handlers = { { event = "neo_tree_buffer_enter", handler = function(arg) vim.cmd [[ setlocal relativenumber ]] end, } }, source_selector = { winbar = true, }, close_if_last_window = true, window = { width = 35, }, buffers = { follow_current_file = true, }, filesystem = { follow_current_file = true, filtered_items = { hide_dotfiles = false, hide_gitignored = false, never_show = { ".DS_Store", "thumbs.db" }, }, }, }) end }, { "willothy/nvim-cokeline", name = "cokeline", dependencies = { "nvim-lua/plenary.nvim", -- Required for v0.4.0+ "nvim-tree/nvim-web-devicons", -- If you want devicons "stevearc/resession.nvim" -- Optional, for persistent history }, config = true } } -- cokeline configuration local get_hex = require('cokeline.hlgroups').get_hl_attr local mappings = require('cokeline.mappings') local comments_fg = get_hex('Comment', 'fg') local errors_fg = get_hex('DiagnosticError', 'fg') local warnings_fg = get_hex('DiagnosticWarn', 'fg') local red = vim.g.terminal_color_1 local green = vim.g.terminal_color_2 local yellow = vim.g.terminal_color_3 local components = { space = { text = ' ', truncation = { priority = 1 } }, two_spaces = { text = ' ', truncation = { priority = 1 }, }, space_bg = { text = ' ', bg = get_hex('Normal', 'bg'), truncation = { priority = 1 } }, separator_left = { text = '', fg = get_hex('ColorColumn', 'bg'), bg = get_hex('Normal', 'bg'), truncation = { priority = 1 } }, devicon = { text = function(buffer) return (mappings.is_picking_focus() or mappings.is_picking_close()) and buffer.pick_letter .. ' ' or buffer.devicon.icon end, fg = function(buffer) return (mappings.is_picking_focus() and yellow) or (mappings.is_picking_close() and red) or buffer.devicon.color end, bold = function(_) return (mappings.is_picking_focus() or mappings.is_picking_close()) or nil end, italic = function(_) return (mappings.is_picking_focus() or mappings.is_picking_close()) or nil end, truncation = { priority = 1 } }, index = { text = function(buffer) return buffer.index .. '¦ ' end, truncation = { priority = 1 } }, unique_prefix = { text = function(buffer) return buffer.unique_prefix end, fg = comments_fg, italic = true, truncation = { priority = 3, direction = 'left', }, }, filename = { text = function(buffer) return buffer.filename end, bold = function(buffer) return (buffer.is_focused and buffer.diagnostics.errors ~= 0) or buffer.is_focused or nil end, undercurl = function(buffer) return (buffer.is_focused and buffer.diagnostics.errors ~= 0) or buffer.diagnostics.errors ~= 0 or nil end, underline = function(buffer) return (buffer.is_focused) or nil end, truncation = { priority = 2, direction = 'left', }, }, diagnostics = { text = function(buffer) return (buffer.diagnostics.errors ~= 0 and '  ' .. buffer.diagnostics.errors) or (buffer.diagnostics.warnings ~= 0 and '  ' .. buffer.diagnostics.warnings) or '' end, fg = function(buffer) return (buffer.diagnostics.errors ~= 0 and errors_fg) or (buffer.diagnostics.warnings ~= 0 and warnings_fg) or nil end, truncation = { priority = 1 }, }, close_or_unsaved = { text = function(buffer) return buffer.is_modified and '●' or '' end, fg = function(buffer) return buffer.is_modified and green or nil end, delete_buffer_on_left_click = true, truncation = { priority = 1 }, }, separator_right = { text = '', fg = get_hex('ColorColumn', 'bg'), bg = get_hex('Normal', 'bg'), truncation = { priority = 1 }, }, } require('cokeline').setup({ show_if_buffers_are_at_least = 1, default_hl = { fg = function(buffer) return buffer.is_focused and get_hex('Normal', 'fg') or get_hex('Comment', 'fg') end, bg = function() return get_hex('ColorColumn', 'bg') end, }, -- rendering = { -- max_buffer_width = 30, -- }, sidebar = { filetype = { 'NvimTree', 'neo-tree', 'SidearNvim' }, components = { { text = function() return vim.fn.getcwd() end, delete_buffer_on_left_click = false, } } }, components = { components.space_bg, components.separator_left, components.space, components.devicon, components.space, components.index, components.unique_prefix, components.filename, components.diagnostics, components.two_spaces, components.close_or_unsaved, components.separator_right, }, }) -- cokeline configuration END lvim.builtin.which_key.mappings["e"] = { "Neotree toggle=true reveal=true", "Explorer" } ```

willothy commented 10 months ago

Have you updated plenary.nvim anytime recently? That's the only thing I can think of, enumerate definitely exists. I'll look into this tomorrow if you can still reproduce with the latest version of plenary.

At some point I can drop plenary and just use vim.iter, but that's still too new and would cut off too many users :/

Zombiefleischer commented 10 months ago

plenary.nvim was also installed with lazy so I think it's the latest version

● plenary.nvim 0.11ms   neo-tree.nvim
dir    /home/zombiefleischer/.local/share/lunarvim/site/pack/lazy/opt/plenary.nvim
url    https://github.com/nvim-lua/plenary.nvim
branch master
commit 9ac3e95
readme README.md
cmd      PlenaryBustedFile   PlenaryBustedDirectory

... when I check the commit on github it's from Apr. 10. ...

Zombiefleischer commented 10 months ago

Lunarvim installs this plugin with this line:

{ "nvim-lua/plenary.nvim", cmd = { "PlenaryBustedFile", "PlenaryBustedDirectory" }, lazy = true },

So no version is specified and I don't quite understand which version lazy defaults to...

willothy commented 10 months ago

It should update to the latest version as long as you run :Lazy update or :Lazy sync somewhat regularly.

... when I check the commit on github it's from Apr. 10. ...

You'll need a newer version - you can update it individually with :Lazy update plenary.nvim.

Zombiefleischer commented 10 months ago

I run the update almost daily and it says

● plenary.nvim 0.11ms   neo-tree.nvim     ■ already up to date 
willothy commented 10 months ago

Have you tried :Lazy sync?

Zombiefleischer commented 10 months ago

yes

willothy commented 10 months ago

Hmm, not sure why it's not updating then, maybe it's worth opening an issue on the lazy.nvim repo? This isn't a cokeline issue; I'm happy to help however I can, but it seems like an issue with your config.

Zombiefleischer commented 10 months ago

I need to specifiy commit = '*' and now I have the latest version... weird

willothy commented 10 months ago

Strange, could be an issue with Lazy. You definitely don't normally need to specify a commit. Glad you got it working though! I'll close this now but feel free to reopen if you run into more issues :)