romgrk / barbar.nvim

The neovim tabline plugin.
2.16k stars 81 forks source link

Closing the buffer with diagnostic enabled, leads to E315: ml_get: Invalid lnum #588

Closed coffebar closed 3 weeks ago

coffebar commented 4 weeks ago

Description Constantly see E315: ml_get: Invalid lnum error when switch projects (plugins close some buffers) on latest neovim (build neovim from git master branch).

Found steps to reproduce this message with minimal config:

Error detected while processing function barbar#events#close_click_handler:
line    1:
...c/.local/share/nvim/lazy/barbar.nvim/lua/barbar/bbye.lua:60: function barbar#events
#close_click_handler[1]..DiagnosticChanged Autocommands for "*": Vim(append):E315: ml_get: Invalid lnum: 1

But when I use my personal config, I see only this message:

Error detected while processing DiagnosticChanged Autocommands for "*":
E315: ml_get: Invalid lnum: 1
Press ENTER or type command to continue

disabling barbar.nvim removes this message

To Reproduce

init.lua:

-- Install lazy.nvim if not already installed
local lazypath = "/tmp/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
    })
end
vim.opt.rtp:prepend(lazypath)

-- Use a protected call so we don't error out on first use
local ok, lazy = pcall(require, "lazy")
if not ok then
    return
end

-- install barbar
local plugins = {
    {
        "romgrk/barbar.nvim",
        dependencies = {
            "lewis6991/gitsigns.nvim", -- OPTIONAL: for git status
            "nvim-tree/nvim-web-devicons", -- OPTIONAL: for file icons
        },
        opts = {
            exclude_ft = {},
            exclude_name = {},
            highlight_inactive_file_icons = true,
        },
        init = function()
            vim.g.barbar_auto_setup = false
        end,
        version = "^1.0.0", -- optional: only update when a new 1.x version is released
    },
    {
        "neovim/nvim-lspconfig",
        config = function()
            local lsp_installed, lspconfig = pcall(require, "lspconfig")
            if not lsp_installed then
                return
            end
            lspconfig.lua_ls.setup({})
        end,
    },
}

lazy.setup(plugins)

Steps to reproduce the behavior:

  1. Save init.lua let say /tmp/barbar/init.lua
  2. Open nvim (latest master) to edit minimal config itself (to make LSP create some diagnostics) nvim -u /tmp/barbar/init.lua /tmp/barbar/init.lua
  3. Close the tab (buffer) via mouse click
  4. See error

Informations Neovim version: v0.11.0

danngreen commented 3 weeks ago

Came here to report the same. Commenting out the render.update() call in the autocommand in events.lua makes the error go away:

  create_autocmd('DiagnosticChanged', {
    callback = function(event)
      state.update_diagnostics(event.buf)
      -- render.update()
    end,
    group = augroup_render,
  })

The error happens regardless of how I close a tab: :bd or click the X in the tab.

Iron-E commented 3 weeks ago

Is barbar up to date? That file is different in master

danngreen commented 3 weeks ago

Aha, yes it works on master. I had this in my config (so does @coffebar 's minimal example)

    version = '^1.0.0', -- optional: only update when a new 1.x version is released
Iron-E commented 3 weeks ago

Ah, we've yet to create a new version with that. I'll add that to my to-do list.

Thank you for bringing this to my attention!

coffebar commented 3 weeks ago

Yep, we need a release. Removing version = '^1.0.0', tag helped for me, but this line is from readme instructions.

Iron-E commented 3 weeks ago

I've published a new release! Closing this, but let me know if there are further issues.