diff options
| author | jdhao <jdhao@hotmail.com> | 2022-04-29 21:51:23 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2022-04-29 21:51:23 +0800 |
| commit | 4b4331d3940e2494e3e4373e740d5cd26b7646fa (patch) | |
| tree | 0a750507f9c1ca140e17a37e98848bb4e93dbbeb | |
| parent | aaafaf58d6010228639fcc17b35d4fa0387b5b2f (diff) | |
refactor: simplify hlslens conf
| -rw-r--r-- | lua/config/hlslens.lua | 31 |
1 files changed, 13 insertions, 18 deletions
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', '*', "<Plug>(asterisk-z*)<Cmd>lua require('hlslens').start()<CR>", { silent = true }) |
