1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

fix error when there is no cursor word

This commit is contained in:
jdhao 2024-08-05 00:22:29 +02:00
parent 933b887281
commit e165276763

View File

@ -35,14 +35,28 @@ keymap.set("n", "N", "", {
end,
})
local no_word_under_cursor = function()
local word_under_cursor = vim.fn.expand("<cword>")
local msg = "E348: No string under cursor"
api.nvim_err_writeln(msg)
return word_under_cursor == ""
end
keymap.set("n", "*", "", {
callback = function()
if no_word_under_cursor() then
return
end
vim.fn.execute("normal! *N")
hlslens.start()
end,
})
keymap.set("n", "#", "", {
callback = function()
if no_word_under_cursor() then
return
end
vim.fn.execute("normal! #N")
hlslens.start()
end,