nvim-lualine / lualine.nvim

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

Bug: diff component does not automatically update upon file changes or repo changes (commits) outside of neovim #1166

Open camoz opened 6 months ago

camoz commented 6 months ago

Self Checks

How to reproduce the problem

Expected behaviour

Actual behaviour

Additional information

From skimming the code, it seems to me that the git diff result is cached and only updated upon the event BufWritePost (but I'm not sure): https://github.com/nvim-lualine/lualine.nvim/blob/2248ef254d0a1488a72041cfb45ca9caada6d994/lua/lualine/components/diff/git_diff.lua#L27

I was able to fix the part for external changes to the file by adding another line

modules.utils.define_autocmd('FileChangedShellPost', "lua require'lualine.components.diff.git_diff'.update_git_diff()")

but I'm really not sure if this is the correct way of fixing this.

I guess fixing the part where the changes of the open file are (partly) committed to the repo is a bit more complicated and maybe out of scope?