tanvirtin / vgit.nvim

Visual git plugin for Neovim
MIT License
583 stars 11 forks source link

Live gutter enabled check too late #366

Closed notEvil closed 1 month ago

notEvil commented 1 month ago

Hi,

while editing a large yaml file I noticed a significant slow down while/soon after edits (~3s lags). Profiling with https://github.com/stevearc/profile.nvim led me to vgit and a short dip into the code. With live_gutter={enabled=false}, LiveGutter.fetch still diffs the file and enabled=false seems to disable just the rendering part. The following patch removes the lags entirely:

diff --git a/lua/vgit/features/buffer/LiveGutter.lua b/lua/vgit/features/buffer/LiveGutter.lua
index d952d84..4e52461 100644
--- a/lua/vgit/features/buffer/LiveGutter.lua
+++ b/lua/vgit/features/buffer/LiveGutter.lua
@@ -12,6 +12,10 @@ function LiveGutter:constructor()
 end

 LiveGutter.fetch = loop.debounce_coroutine(function(self, buffer)
+  if not live_gutter_setting:get('enabled') then
+    return self
+  end
+
   loop.free_textlock()
   if not buffer:is_valid() then return self end