From 43d476107e2db399beefe9bdabb643fc2cd8ffaf Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Thu, 5 Aug 2021 21:19:26 +0200 Subject: [PATCH] Add hlslens --- configs/nvim/lua/mappings.lua | 8 +++++ configs/nvim/lua/plugins/init.lua | 3 ++ configs/nvim/lua/plugins/nvim-hlslens.lua | 36 +++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 configs/nvim/lua/plugins/nvim-hlslens.lua diff --git a/configs/nvim/lua/mappings.lua b/configs/nvim/lua/mappings.lua index a4c684f..ac1034b 100644 --- a/configs/nvim/lua/mappings.lua +++ b/configs/nvim/lua/mappings.lua @@ -23,6 +23,14 @@ local function init() map('n', 'r', 'lua vim.lsp.buf.references()') map('n', 's', 'lua vim.lsp.buf.document_symbol()') + -------------------- HlsLens ------------------------------- + map('n', 'n', "execute('normal! ' . v:count1 . 'n')lua require('hlslens').start()") + map('n', 'N', "execute('normal! ' . v:count1 . 'N')lua require('hlslens').start()") + map('n', '*', "*lua require('hlslens').start()") + map('n', '#', "#lua require('hlslens').start()") + map('n', 'g*', "g*lua require('hlslens').start()") + map('n', 'g#', "g#lua require('hlslens').start()") + -------------------- LAZYGIT ------------------------------- -- Install docs : https://github.com/jesseduffield/lazygit map('n', 'lg', 'LazyGit') diff --git a/configs/nvim/lua/plugins/init.lua b/configs/nvim/lua/plugins/init.lua index 1e14ac2..0d98a97 100644 --- a/configs/nvim/lua/plugins/init.lua +++ b/configs/nvim/lua/plugins/init.lua @@ -6,6 +6,7 @@ function configure_packages() call_with_helpers(require('plugins.nvim-comment').init) call_with_helpers(require('plugins.nvim-autopairs').init) call_with_helpers(require('plugins.nvim-notify').init) + call_with_helpers(require('plugins.nvim-hlslens').init) end function install_packages() @@ -34,6 +35,8 @@ function install_packages() use 'terrortylor/nvim-comment' use 'rcarriga/nvim-notify' -- fancy notification use 'romgrk/barbar.nvim' -- Tabs, as understood by any other editor. + use 'tpope/vim-endwise' -- auto complete block with end + use 'kevinhwang91/nvim-hlslens' -- nvim-hlslens helps you better glance at matched information, seamlessly jump between matched instances. use 'mhinz/vim-startify' -- The fancy start screen for Vim. end diff --git a/configs/nvim/lua/plugins/nvim-hlslens.lua b/configs/nvim/lua/plugins/nvim-hlslens.lua new file mode 100644 index 0000000..53d1031 --- /dev/null +++ b/configs/nvim/lua/plugins/nvim-hlslens.lua @@ -0,0 +1,36 @@ +local function init() + require('hlslens').setup { + calm_down = true, + override_lens = function(render, plist, nearest, idx, r_idx) + local sfw = vim.v.searchforward == 1 + local indicator, text, chunks + local abs_r_idx = math.abs(r_idx) + if abs_r_idx > 1 then + indicator = string.format('%d%s', abs_r_idx, sfw ~= (r_idx > 1) and '' or '') + elseif abs_r_idx == 1 then + indicator = sfw ~= (r_idx == 1) and '' or '' + else + indicator = '' + end + + local lnum, col = unpack(plist[idx]) + if nearest then + local cnt = #plist + if indicator ~= '' then + text = string.format('[%s %d/%d]', indicator, idx, cnt) + else + text = string.format('[%d/%d]', idx, cnt) + end + chunks = {{' ', 'Ignore'}, {text, 'HlSearchLensNear'}} + else + text = string.format('[%s %d]', indicator, idx) + chunks = {{' ', 'Ignore'}, {text, 'HlSearchLens'}} + end + render.set_virt(0, lnum - 1, col - 1, chunks, nearest) + end + } +end + +return { + init = init +} \ No newline at end of file