Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with lewis6991/fileline.nvim #5

Open
pschmitt opened this issue Oct 14, 2024 · 7 comments
Open

Incompatibility with lewis6991/fileline.nvim #5

pschmitt opened this issue Oct 14, 2024 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@pschmitt
Copy link

pschmitt commented Oct 14, 2024

Hi,

If anyone happens to use both this here plugin and lewis6991/fileline.nvim (or wsdjeg/vim-fetch) and then opens a git-tracked file like this: nvim FILE:1 an error is thrown:

Error executing vim.schedule lua callback: ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:95: The async coroutine faile
d: ...al/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/attach.lua:269: Invalid buffer id: 1
stack traceback:
        [C]: in function '__index'
        ...al/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/attach.lua:269: in function 'fn'
        .../share/nvim/lazy/gitsigns.nvim/lua/gitsigns/debounce.lua:68: in function 'attach_throttled'
        ...al/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/attach.lua:431: in function <...al/share/nvim/lazy/gitsigns.nvim/lua/gitsig
ns/attach.lua:430>
stack traceback:
        [C]: in function 'error'
        ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:95: in function 'cb'
        ...cal/share/nvim/lazy/gitsigns.nvim/lua/gitsigns/async.lua:145: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Sample config to reproduce:

for name, url in pairs({
  gitsigns = "https://github.com/lewis6991/gitsigns.nvim",
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
  gitsigns_yadm = "https://github.com/purarue/gitsigns-yadm.nvim",
  fileline = "https://github.com/lewis6991/fileline.nvim",
  plenary = "https://github.com/nvim-lua/plenary.nvim",
}) do
  local install_path = vim.fn.fnamemodify("gitsigns_issue/" .. name, ":p")
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system({ "git", "clone", "--depth=1", url, install_path })
  end
  vim.opt.runtimepath:append(install_path)
end

require("gitsigns").setup({
  debug_mode = true, -- You must add this to enable debug messages
  -- ADD GITSIGNS CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE
  _on_attach_pre = function(_, callback)
    require("gitsigns-yadm").yadm_signs(callback)
  end,
})

and then: nvim -u FILE_FROM_ABOVE.lua MYFILE:LINE_NUMBER (eg: nvim -u init-repro.lua README.md:1)

@pschmitt
Copy link
Author

Both the fileline and vim-fetch plugins seem to close the first buffer and re-open a new one when triggered, which is probably why this error is logged.

nvim /tmp/file
:buffers
  1 %a   "/tmp/file"                    line 1

vs:

nvim /tmp/file:1
:buffers
  2 %a   "/tmp/file"                    line 1

@purarue
Copy link
Owner

purarue commented Oct 16, 2024

Thanks for reporting!

Just for my reference, need to actually open a file which is in the yadm repo for the error, so like a:

nvim -u init-repro.lua ~/.config/yadm/README.md:50

I think the error gets thrown in gitsigns code, not here, so probably cant catch that.

perhaps the argument can be checked to see if theres a line number included, I'm not sure what the API for that is like... seems quite hacky, but can take a look when I have some free time

@disrupted
Copy link

fwiw I am seeing the same error from gitsigns after making a Git commit using Neogit. I don't have the fileline.nvim plugin.

@purarue
Copy link
Owner

purarue commented Nov 13, 2024

Just to confirm, are you using a line number when opening the file like nvim README.md:1?

@disrupted
Copy link

I always open files regularly, make some changes, and commit them using Neogit. It's only after the commit message is saved and the window closes that I see the error. It goes away when I disable gitsigns-yadm. fwiw I've never used the fileline plugin

@purarue
Copy link
Owner

purarue commented Dec 5, 2024

Just to update the status here a bit, I am a bit unsure how to proceed here; this plugin is a bunch of configuration around one specific callback command which is the entire surface area of the gitsigns API this interacts with, it is not complicated at all.

Those two fields are then processed here in gitsigns.

I would have to read through/really understand gitsigns a lot more than I do currently to able to debug why this is failing, and thats not something I have a ton of time for right now.

If someone can point me in the right direction/would like to take this on and submit a PR, would be appreciated.

@purarue purarue added bug Something isn't working help wanted Extra attention is needed labels Dec 5, 2024
@disrupted
Copy link

I've temporarily fixed the issue for me by disabling this plugin for other projects (inside Git repos).

_on_attach_pre = function(bufnr, callback)
    if vim.uv.fs_stat '.git' then
        -- disable YADM if inside Git repo
        return callback()
    end
    require('gitsigns-yadm').yadm_signs(callback)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants