Reactivating hlslens
after scroll with mini.animate
#460
-
Hi, on scroll with return {
{
"kevinhwang91/nvim-hlslens",
init = function()
require("hlslens").setup {
virt_priority = 0,
calm_down = true
}
local map = vim.keymap.set
local function decorate_search(s)
return s .. [[<Cmd>lua require("mini.animate").execute_after("scroll", function() require("hlslens").start() end)<CR>]]
end
map({ "n", "v" }, "n", decorate_search([[<Cmd>execute("normal! " . v:count1 . "n")<CR>]]))
end
}
} Has anybody made it work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Executing something after animation is done admittedly is not a very strong side of 'mini.animate'. Especially when it comes to UI. For some functions (like Try this "more Lua" version of this code: require('hlslens').setup({ virt_priority = 0, calm_down = true })
local executing_normal_jump = function(keys)
local hlslens_start = require('hlslens').start
return function()
vim.cmd('normal! ' .. vim.v.count1 .. keys)
if MiniAnimate == nil then return hlslens_start() end
MiniAnimate.execute_after('scroll', function() vim.defer_fn(hlslens_start, 10) end)
end
end
vim.keymap.set({ 'n', 'x' }, 'n', executing_normal_jump('n'))
vim.keymap.set({ 'n', 'x' }, 'N', executing_normal_jump('N')) This seems to work on every second execution, which to me seems like an issue with 'nvim-hlslens'. Mostly because it consistently enables and disables search highlighting. |
Beta Was this translation helpful? Give feedback.
Executing something after animation is done admittedly is not a very strong side of 'mini.animate'. Especially when it comes to UI.
For some functions (like
prev_hunk()
andnext_hunk()
from 'lewis6991/gitsigns.nvim') I found that deferring function by small number of milliseconds improves experience.Try this "more Lua" version of this code: