diff --git a/lua/config/hlslens.lua b/lua/config/hlslens.lua index e2e048f..bf02aa6 100644 --- a/lua/config/hlslens.lua +++ b/lua/config/hlslens.lua @@ -3,34 +3,29 @@ require('hlslens').setup({ nearest_only = true, }) +local activate_hlslens = function(d) + local cmd = "normal! " .. vim.v.count1 .. d .. "zzzv" + local status, msg = pcall(vim.fn.execute, cmd) + + if not status then + vim.api.nvim_echo({{msg, "ErrorMsg"}}, false, {}) + return + end + require('hlslens').start() +end + vim.keymap.set('n', 'n', '', { noremap = true, silent = true, - callback = function() - local status, msg = pcall(vim.fn.execute, "normal! " .. vim.v.count1 .. "nzzzv") - - if not status then - vim.api.nvim_echo({{msg, "ErrorMsg"}}, false, {}) - return - end - require('hlslens').start() - end + callback = function() activate_hlslens('n') end }) vim.keymap.set('n', 'N', '', { noremap = true, silent = true, - callback = function() - local status, msg = pcall(vim.fn.execute, "normal! " .. vim.v.count1 .. "Nzzzv") - - if not status then - vim.api.nvim_echo({{msg, "ErrorMsg"}}, false, {}) - return - end - require('hlslens').start() - end + callback = function() activate_hlslens('N') end }) vim.keymap.set('n', '*', "(asterisk-z*)lua require('hlslens').start()", { silent = true })