kevinhwang91 / nvim-hlslens

Hlsearch Lens for Neovim
BSD 3-Clause "New" or "Revised" License
748 stars 10 forks source link

search count message not get updated after remap `n/N` key, if `lazyredraw` is on #34

Closed aceforeverd closed 2 years ago

aceforeverd commented 2 years ago

Describe the bug

Personally I'd like keep search count message at bottom-right, so in my vimrc I have set shortmess-=S. After enable hlslens, those count message do not get updated anymore after hit n/N, I found this is because map the n/N key with the example in README:

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)

To Reproduce using nvim -u mini.lua

vim.cmd[[ set shortmess-=S ]]
-- packer
use {'kevinhwang91/nvim-hlslens'}

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)

Steps to reproduce the behavior:

  1. / search something
  2. hit n/N
  3. check if search count message get updated

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

kevinhwang91 commented 2 years ago

can't reproduce, try below config and cmd.

vim.cmd('pa nvim-hlslens')
vim.cmd[[ set shortmess-=S ]]

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)

nvim -u mini.lua --noplugin

aceforeverd commented 2 years ago

@kevinhwang91 thanks for the reply.

I rechecked, the problem happens when lazyredraw is on. just like this:

vim.cmd [[
set lazyredraw
set shortmess-=S
packadd nvim-hlslens
]]
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)

if lazyredraw is off or hlslens is not load, the search count message got updated after n/N

kevinhwang91 commented 2 years ago

It's not an issue of hlslens.

set lazyredraw
set shortmess-=S
nnoremap n <Cmd>execute('normal! ' . v:count1 . 'n')<CR>

can't update the info, you should post this remapping issue to vim instead of neovim or hlslens.