From acc3ed7829882a55e2e3ce29163cb9b2b907a5e5 Mon Sep 17 00:00:00 2001 From: jdhao Date: Mon, 5 Aug 2024 23:32:03 +0200 Subject: [PATCH] show error message only when no word is under cursor --- lua/config/hlslens.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lua/config/hlslens.lua b/lua/config/hlslens.lua index 3632347..c682d5c 100644 --- a/lua/config/hlslens.lua +++ b/lua/config/hlslens.lua @@ -36,11 +36,15 @@ keymap.set("n", "N", "", { }) local no_word_under_cursor = function() - local word_under_cursor = vim.fn.expand("") + local cursor_word = vim.fn.expand("") - local msg = "E348: No string under cursor" - api.nvim_err_writeln(msg) - return word_under_cursor == "" + local result = cursor_word == "" + if result then + local msg = "E348: No string under cursor" + api.nvim_err_writeln(msg) + end + + return result end keymap.set("n", "*", "", {