nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
6.18k stars 466 forks source link

Bug: lualine causes .git/index.lock file to persist, blocking subsequent git operations #1096

Open svermeulen opened 1 year ago

svermeulen commented 1 year ago

Self Checks

How to reproduce the problem

Expected behaviour

lualine should not block unrelated git operations

Actual behaviour

sometimes, when opening certain files inside a git repo, an index.lock file appears at .git/index.lock, and stays there

Minimal config to reproduce the issue

N/A

I really tried to repro with a minimal .vimrc but I could not. However - I am still pretty confident it's related to something lualine is doing, since removing lualine completely prevents the issue from happening.

Feel free to close the issue though. Even as a closed issue it might be valuable to anyone else having this problem, since it took me awhile to narrow this one down.

Additional information

My guess is that there is a git operation that lualine runs that crashes and then leaves the index.lock file there.

Should note also that I'm not using fugitive.vim, not sure if relevant

The file I noticed it with most has unix style endings, and this occurred on windows, though that is probably not relevant

scanny commented 1 year ago

Solution might be the same as mentioned in this vim-fugitive issue, a number of other plugins have added the --no-optional-locks option to git status that is mentioned there. https://github.com/tpope/vim-fugitive/issues/1624#issuecomment-731840747

scanny commented 1 year ago

Confirmed that only removing/replacing the "diff" item from lualine causes this problem to go away and come back. I have the fugitive extension installed, but it works fine without the diff item.

I encounter this when running :Gwrite from the fugitive plugin for a second time on the same file (as you do during merge conflict resolution when you can't remember whether you already did it once).

svermeulen commented 1 year ago

Thanks! Your mention of diff item led me through the code, where I discovered that git_diff.lua was sometimes force-killing the git diff operation

shadmansaleh commented 1 year ago

I'd like to get it fixed. Meanwhile, it's likely everyone already has other more git-focused plugins more thoroughly tracking diff status than lualine. You can let diff component use those as source of info instead of lualines implementation. I'm using gitsigns as source for diff. Here's an example how to do it https://github.com/nvim-lualine/lualine.nvim/wiki/Component-snippets#using-external-source-for-diff