Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jump to last search when doing :s/ #60

Closed
AckslD opened this issue Jan 12, 2023 · 5 comments
Closed

Jump to last search when doing :s/ #60

AckslD opened this issue Jan 12, 2023 · 5 comments

Comments

@AckslD
Copy link

AckslD commented Jan 12, 2023

  • nvim --version: v0.8.2
  • Operating system/version: arch linux 6.1.3-arch1-1

Describe the bug
A clear and concise description of what the bug is.

If I first search for something, let's say for foo in the following file:

foo
bar

then I clear the search and move to the line with bar and I start typing :s/fo to replace something on the second line (which does not exist in this case), then the cursor jumps to the first line which seems to be caused by hlslens.

To Reproduce using nvim -u mini.lua

    use {
        'kevinhwang91/nvim-hlslens',
        keys = '/',
        module = 'hlslens',
        setup = 'require("plugin_settings.hlslens").setup()',
        config = 'require("plugin_settings.hlslens").config()',
    }

with

local M = {}

M.setup = function() -- {{{
    local noremap = {noremap = true}
    local silent = {noremap = true, silent = true}
    vim.api.nvim_set_keymap('n', 'n', '<Cmd>execute("normal! " . v:count1 . "n")<CR><Cmd>lua require("hlslens").start()<CR>zzzv', silent)
    vim.api.nvim_set_keymap('n', 'N', '<Cmd>execute("normal! " . v:count1 . "N")<CR><Cmd>lua require("hlslens").start()<CR>zzzv', silent)
    vim.api.nvim_set_keymap('n', '*', '*<Cmd>lua require("hlslens").start()<CR>', noremap)
    vim.api.nvim_set_keymap('n', '#', '#<Cmd>lua require("hlslens").start()<CR>', noremap)
    vim.api.nvim_set_keymap('n', 'g*', 'g*<Cmd>lua require("hlslens").start()<CR>', noremap)
    vim.api.nvim_set_keymap('n', 'g#', 'g#<Cmd>lua require("hlslens").start()<CR>', noremap)
end -- }}}

M.config = function()
  require('hlslens').setup()
end

return M

Screenshots

hlslens_bug.mp4

Additional context

I haven't tried it yet with a minimal config. Maybe something is going wrong with this and live preview?

@AckslD
Copy link
Author

AckslD commented Jan 12, 2023

Seems to be the case also with this minimal config:

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
vim.g.loaded_remote_plugins = 1
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/opt/packer.nvim'
local compile_path = package_root .. '/packer/start/packer_compiled/plugin/packer_compiled.lua'

local function load_plugins()
  vim.cmd('packadd packer.nvim')
  require('packer').startup{
    {
      {
        'wbthomason/packer.nvim',
        module = 'packer',
        cmds = {'PackerSync'},
        config = function()
        end,
      },
      {
        'kevinhwang91/nvim-hlslens',
        keys = '/',
        module = 'hlslens',
        setup = function()
          local noremap = {noremap = true}
          local silent = {noremap = true, silent = true}
          vim.api.nvim_set_keymap('n', 'n', '<Cmd>execute("normal! " . v:count1 . "n")<CR><Cmd>lua require("hlslens").start()<CR>zzzv', silent)
          vim.api.nvim_set_keymap('n', 'N', '<Cmd>execute("normal! " . v:count1 . "N")<CR><Cmd>lua require("hlslens").start()<CR>zzzv', silent)
          vim.api.nvim_set_keymap('n', '*', '*<Cmd>lua require("hlslens").start()<CR>', noremap)
          vim.api.nvim_set_keymap('n', '#', '#<Cmd>lua require("hlslens").start()<CR>', noremap)
          vim.api.nvim_set_keymap('n', 'g*', 'g*<Cmd>lua require("hlslens").start()<CR>', noremap)
          vim.api.nvim_set_keymap('n', 'g#', 'g#<Cmd>lua require("hlslens").start()<CR>', noremap)
        end,
        config = function()
          require('hlslens').setup()
        end,
      },
    },
    config = {
      auto_clean = false,
      package_root = package_root,
      compile_path = compile_path,
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Cloning packer.")
  print(vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path })
  if vim.v.shell_error ~= 0 then
    print('got error, aborting')
    return
  end
else
  print("Packer already cloned.")
end
if vim.fn.filereadable(compile_path) == 0 then
  load_plugins()
  print("Sync packer")
  require('packer').sync()
  vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]
else
  load_config()
end

@kevinhwang91
Copy link
Owner

Reproduced

@AckslD
Copy link
Author

AckslD commented Jan 12, 2023

Thanks @kevinhwang91, unfortunately I'm still seeing the same issue.

@AckslD
Copy link
Author

AckslD commented Jan 12, 2023

Can confirm that it works as expected now, thanks! 🚀

@kevinhwang91
Copy link
Owner

Great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants