-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathhlslens.lua
46 lines (42 loc) · 1.3 KB
/
hlslens.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
local M = {}
M.config = function()
local status_ok, hlslens = pcall(require, "hlslens")
if not status_ok then
return
end
local opts = {
auto_enable = true,
calm_down = true,
enable_incsearch = false,
nearest_only = false,
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,
}
hlslens.setup(opts)
require("user.keybindings").set_hlslens_keymaps()
end
return M