Closed tranzystorekk closed 1 year ago
Please provide repro steps without lazy.nvim. The issue template illustrated how to do this.
Sorry, missed that part, updated.
The issue seems to have appeared after this commit: 5a2b120
This guess of mine is probably incorrect, I tried to load earlier gitsigns versions without success.
The repro looks fairly minimal so hopefully it won't take too long to debug (when I get around to looking at it)
With the minimal config posted above:
- Open a git directory with nvim . and open an already committed file to let the session manager register a session
- Exit neovim to save the session
- Open the same directory again with nvim . to autoload the session
- nvim-session-manager autoloads the previously opened file, but git signs no longer show in gutter when changing the file.
I tried this and it appears to work fine.
I am facing the same problem. It did come out after this commit 5a2b1205841bc06ffb15719b14d54987e17b22ae
I noticed it doesn't reproduce in all of my projects, so confusing :/
Maybe try a project you can reproduce in, and delete files until the issue goes away.
After playing around a little with the repo and non-repro projects, here's some more observations:
In a non-repro project, debug_messages contains two attach
messages:
trigger=setup
for the project directory (opened via nvim .
)trigger=BufReadPost
for the file opened with the session managerIn a repro case, there's only the initial trigger=setup
attach, even tho the actual file is opened as well, so it seems as if for some reason gitsigns isn't notified about the file being opened.
A noticeable difference is that the non-repro project contains thousands of subdirs and files, so it takes neovim/session manager a couple seconds to reopen the reloaded file. This could explain why gitsigns has enough time to get properly notified and attached in that case.
If anyone comes here looking for a remedy, for now the workaround is to simply manually call :Gitsigns attach
after the session has been loaded
In the repro case does debug messages always say attach(1): Already attached
?
If so it looks like Gitsigns is trying to attach but incorrectly thinks it already has.
No, it says attach(1): Attaching (trigger setup)
, which is probably expected because gitsigns tries to attach to the nvim tree buffer. The problem is that neovim session manager loads a session and opens its file, but that doesn't come as an attach event.
attach(1)
means the attach function is running for buffer 1. If this fails then there should be a message explaining why it didn't attach later in the log.
IIUC that attach correctly fails with "new: Not a git repo" because it's the project directory itself. My point is, there should subsequently occur another attach for the file opened by the session manager, but that never happens in the repro case.
Same problem here with neo-tree.nvim . When I launch neovim with nvim .
(which opens a neo-tree buffer for me), gitsigns does not automatically attach when I open any files afterwards.
Same problem here with neo-tree.nvim . When I launch neovim with
nvim .
(which opens a neo-tree buffer for me), gitsigns does not automatically attach when I open any files afterwards.
Repro steps please!
Saying "me too!" doesn't help progress anything.
Having the same issue/behavior as @dmitrykruglov, here is how I can reproduce it every time:
Setup:
Steps:
nvim .
attach
function manually@fabivs could you prepare and post a minimal reproducible config, using the template in New issue -> Bug report form? It would be invaluable for this issue.
hi @tranzystorek-io I was about to fill the bug report like you asked, but because I did some changes in my config today I noticed that I couldn't recreate the issue anymore. Then after messing around with it for a bit I was able to figure out the piece of config that makes it work.
Originally I had only the plugin installation under lazy, so basically this:
return require('lazy').setup({
-- other plugins...
{
'lewis6991/gitsigns.nvim',
config = function()
require('gitsigns').setup()
end
}
-- other plugins...
})
And nothing else configured for Gitsigns.
Today I happened to add this code in my after/plugin/gitsigns.lua
file, and with this it works fine, I can't recreate the issue anymore. Hope this information helps.
@fabivs I think you misunderstood, I meant in the bug report form there is a template for a minimal reproduction config file (doesn't use lazy, sets up a separate, clean plugin dir etc.).
Alright, I opened the issue here, with this minimal config I am able to re-create the problem.
Have you tried disabling the statuscolumn? See https://github.com/luukvbaal/statuscol.nvim/issues/83#issuecomment-1751537535.
It did work in my case to bring back gitsigns. The issue is directly or indirectly caused, apparently, by gitsigns using extmarks now by default instead of legacy vim signs. That's as much as I could deduce, I don't have much background in this context.
This issue predates extmark signs being default. Please try not to confuse multiple issues as one.
I recently switched my session management setup to be simpler and more predicatable and this issue no longer reproduces for me on any of the previously problematic repos.
Some observations on what was a probable culprit in my case:
nvim .
, that caused nvim-tree
to first hijack it, then the session manager was called to restore session, which in turn wipes all buffers. Now I have directory hijacking disabled, and instead I use VimEnter autocmd to check if a directory is opened and then run session and nvim-tree there.localoptions
in vim.o.sessionoptions
, which seems to cause a whole bunch of plugin issues when loading sessions, e.g. LSP and possibly gitsigns starting unattached, filetypes being undetected etc.Ok, since there's no way to reproduce this and other people are commenting on unrelated issues, I'll close this. Please open a new issue with repro steps if any problems continue.
Description
Gitsigns no longer appear in my gutter when I open a project directory
nvim .
and let the https://github.com/Shatur/neovim-session-manager plugin autoload a saved session.The issue seems to have appeared after this commit: https://github.com/lewis6991/gitsigns.nvim/commit/5a2b1205841bc06ffb15719b14d54987e17b22ae
Neovim version
0.9.1
Operating system and version
Void Linux
Expected behavior
Git signs appear in the gutter when opening a directory with a git project, e.g.
nvim .
with a neovim-session-manager autoload config (included below).Actual behavior
No git signs appear in the gutter of the autoloaded file
Minimal config
Steps to reproduce
With the minimal config posted above:
nvim .
and open an already committed file to let the session manager register a sessionnvim .
to autoload the sessionnvim-session-manager
autoloads the previously opened file, but git signs no longer show in gutter when changing the file.Gitsigns debug messages
After opening a git directory with session autoload:
After opening a file (i.e.
nvim <filename>
) in a git repo (no session autoload):