hydra.nvim
hydra.nvim copied to clipboard
fix(hint): nolazyredraw
Fix a rendering issue that causes the cursor to appear at the end of the hint if lazyredraw
is enabled and hint is shown in the echo area.
Problem
If a hydra shows its hint in the echo area (config.hint.type = 'cmdline'
) and the user has lazyredraw
on, the hint renders correctly when first invoked, but any subsequent action (within the hydra) causes the cursor to appear at the end of the hint.
Solution
Add an on_enter
function to the default config to turn lazyredraw
off for the duration of the hydra.
Minimal reproducible example
The problem can be demonstrated (prior to this commit) by invoking nvim like,
nvim -u minimal.lua +'call append(0, "1234")' +'goto 1'
with the following minimal.lua init file:
vim.opt.lazyredraw = true
vim.opt.wrap = false -- allow horizontal scrolling
local hydra = require('hydra')
hydra({
name = 'scroll',
mode = 'n',
body = 'z',
heads = { { 'l', 'zl' }, { 'h', 'zh' } },
config = { hint = { type = 'cmdline' } },
})
Type zl
to invoke the hydra, and the hint is drawn correctly.
Type l
to scroll again, and now the cursor is drawn at the end of the hint.