mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
The * can now search selected text by default. The cursor stay feature can also be simulated.
49 lines
879 B
Lua
49 lines
879 B
Lua
local api = vim.api
|
|
local keymap = vim.keymap
|
|
|
|
local hlslens = require("hlslens")
|
|
|
|
hlslens.setup {
|
|
calm_down = true,
|
|
nearest_only = true,
|
|
}
|
|
|
|
local activate_hlslens = function(direction)
|
|
local cmd = string.format("normal! %s%szzzv", vim.v.count1, direction)
|
|
local status, msg = pcall(vim.cmd, cmd)
|
|
|
|
if not status then
|
|
-- 13 is the index where real error message starts
|
|
msg = msg:sub(13)
|
|
api.nvim_err_writeln(msg)
|
|
return
|
|
end
|
|
|
|
hlslens.start()
|
|
end
|
|
|
|
keymap.set("n", "n", "", {
|
|
callback = function()
|
|
activate_hlslens("n")
|
|
end,
|
|
})
|
|
|
|
keymap.set("n", "N", "", {
|
|
callback = function()
|
|
activate_hlslens("N")
|
|
end,
|
|
})
|
|
|
|
keymap.set("n", "*", "", {
|
|
callback = function()
|
|
vim.fn.execute("normal! *N")
|
|
hlslens.start()
|
|
end,
|
|
})
|
|
keymap.set("n", "#", "", {
|
|
callback = function()
|
|
vim.fn.execute("normal! #N")
|
|
hlslens.start()
|
|
end,
|
|
})
|