vgit.nvim icon indicating copy to clipboard operation
vgit.nvim copied to clipboard

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

Open notEvil opened this issue 2 years ago • 2 comments

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 avatar Jun 22 '23 13:06 notEvil

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

Issues:

  • project_diff_preview: when staging the first hunk of a file, the file gets added to the 'staged' part of the tree which essentially moves the cursor up

notEvil avatar Jun 22 '23 19:06 notEvil

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.

stale[bot] avatar Oct 20 '23 20:10 stale[bot]

Thanks this is much better.

tanvirtin avatar Apr 05 '24 22:04 tanvirtin