nvim-hlslens
nvim-hlslens copied to clipboard
Lens flicker on file write
nvim --version:- Operating system/version:
Describe the bug A clear and concise description of what the bug is.
To Reproduce using nvim -u mini.lua
Example:
cat mini.lua
-- packer
use {'kevinhwang91/nvim-hlslens'}
require('hlslens').setup()
local kopts = {noremap = true, silent = true}
vim.api.nvim_set_keymap('n', 'n',
[[<Cmd>execute('normal! ' . v:count1 . 'n')<CR><Cmd>lua require('hlslens').start()<CR>]],
kopts)
vim.api.nvim_set_keymap('n', 'N',
[[<Cmd>execute('normal! ' . v:count1 . 'N')<CR><Cmd>lua require('hlslens').start()<CR>]],
kopts)
vim.api.nvim_set_keymap('n', '*', [[*<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('n', '#', [[#<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('n', 'g*', [[g*<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('n', 'g#', [[g#<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('x', '*', [[*<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('x', '#', [[#<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('x', 'g*', [[g*<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('x', 'g#', [[g#<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('n', '<Leader>l', ':noh<CR>', kopts)
Steps to reproduce the behavior:
- Search for something using
*or/ - Clear highlight using
:nohl - Write the file using
:w - Keep repeating step 3, sometimes the highlights and lens will be visible for a short time
Expected behavior
Saving a file shouldn't cause flicker.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
https://github.com/kevinhwang91/nvim-hlslens/blob/5e3e9088fba7508cee3612ee50b14dfdd3ab19af/lua/hlslens/cmdline/init.lua#L330-L334
The flicker is triggered from this code.
Can't reproduce it, maybe some script change your hlsearch.
Okay, I reproduced it like this:
vim.api.nvim_create_autocmd("BufWritePre", {
callback = function()
vim.wait(2000)
end,
})
- Search for something using
*or/ - Clear highlight using
:nohl - Write the file using
:w - When the
vim.waitis happening, move the cursor (e.g. pressj) - Every once in a while search highlight and lens will flicker
Here vim.wait(2000) is artificially delaying the file save. But in my actual config it happens because of lsp code formatting that runs before the buffer is written.
Sorry, still can't rerpoduce it.
I have the same problem. When I save a file, it shows the lens quickly on every line and then disappears. My config:
require("hlslens").setup()
Nvim version:
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1693350652