tanvirtin / vgit.nvim

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

Replace `j`, `k` with event `CursorMoved` #344

Closed notEvil closed 5 months ago

notEvil commented 1 year ago

Hi!

I was wondering if you would consider changing the input method in lists (and trees) to react to the event CursorMoved instead of a particular keymap for up/down. The rationale: navigation by 1 (hjkl) is usually replaced with more efficient methods, and it feels irritating that moving the cursor by other means doesn't have the same effect.

It looks like the required changes are minimal. The following works for buffer_history_preview

diff --git a/lua/vgit/features/screens/HistoryScreen/init.lua b/lua/vgit/features/screens/HistoryScreen/init.lua
index 6dc6902..a4ea433 100644
--- a/lua/vgit/features/screens/HistoryScreen/init.lua
+++ b/lua/vgit/features/screens/HistoryScreen/init.lua
@@ -120,6 +120,11 @@ function HistoryScreen:show()
     },
   })

+  self.table_view.scene:get('table').buffer:on('CursorMoved', function()
+    self.store:set_index(self.table_view:move())
+    self.diff_view:render_debounced(function() self.diff_view:navigate_to_mark(1) end)
+  end)
+
   return true
 end

https://github.com/tanvirtin/vgit.nvim/issues/340 could be related

notEvil commented 1 year ago

proof of concept: https://github.com/notEvil/vgit.nvim/tree/i344

Issues:

stale[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

tanvirtin commented 5 months ago

Thanks this is much better.