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

cursor jumps out of window on window movements, windowing wiki page

Open matu3ba opened this issue 3 years ago • 2 comments
trafficstars

Consider

local Hydra = require('hydra')
M.window_hdyra = Hydra({
   body = '<C-w>',
   heads = {
      { 'h', '<C-w>h' },
      { 'j', '<C-w>j' },
      { 'k', '<C-w>k' },
      { 'l', '<C-w>l' },
      { '<Esc>', nil,  { exit = true, desc = false } },
   },
})

And having 2 windows positioned side by side. From the left one starting, pressing C-w l (activates hydra), l moves the cursor to the commandline window,

Also, I dont understand why the example in the wiki uses { 'k', pcmd('wincmd k', 'E11', 'close') },.

Personally I would favor having a simpler example to get people started with hydra: only 1. movements hjkl, 2. basic resizing (<,>,+,-,=), 3. splits (s,v), 4. simple swap C-w shift, 5. closing and only window (c, o), 6. exiting

Personally I think buffers are more efficiently managed in combination with harpoon + :b and autocompleter (I use nvim-comp). Combining both seems like overkill to me, at least for starters.

matu3ba avatar Aug 17 '22 10:08 matu3ba

I would suggest for the wiki to offer a simpler mapping without external plugins as more minimalistic example:

-- keep windowing simple and fast
M.window_hdyra = Hydra({
   body = '<C-w>',
   heads = {
      { 'h', '<C-w>h' },
      { 'j', '<C-w>j' },
      { 'k', '<C-w>k' },
      { 'l', '<C-w>l' },
      { 's', '<C-w>s' },
      { 'v', '<C-w>v' },
      { '+', '<C-w>+' },
      { '-', '<C-w>-' },
      -- neovim is slower on moving lines (<- and -> movements of window)
      { '>', '<C-w>>' },
      { '<', '<C-w><' },
      { '=', '<C-w>=' },
      { 'q', '<cmd>close<CR>' },
      { 'o', '<cmd>only<CR>' },
      --{ '<S>', '<C-w><S>' }, -- TODO figure out how to remap this
      --{ '_', '<C-w>_' },
      --{ '|', '<C-w>|' }, -- requires prefixed numbers => other hydra heaad
      { '<Esc>', nil,  { exit = true, desc = false } },
   },
})

matu3ba avatar Aug 22 '22 23:08 matu3ba

One possible side effect of this is that if key frequency is too fast, then keeping > pressed will deactivate of the hydra and do indentation instead.

matu3ba avatar Sep 01 '22 09:09 matu3ba

The underlying bug is fixed and pressing < and > continuously works. It still looks like the cursor jumps out, but I guess that is for drawing?! Anyway, the use case is solved.

matu3ba avatar Sep 26 '22 21:09 matu3ba