diff --git a/lua/url-open/modules/autocmd.lua b/lua/url-open/modules/autocmd.lua index 802ed2e..c4ea843 100644 --- a/lua/url-open/modules/autocmd.lua +++ b/lua/url-open/modules/autocmd.lua @@ -8,13 +8,7 @@ local M = {} M.setup = function(user_opts) if user_opts.highlight_url.enabled then - if not user_opts.highlight_url.cursor_only then - api.nvim_create_autocmd({ "VimEnter", "FileType", "BufEnter", "WinEnter" }, { - desc = "URL Highlighting", - group = api.nvim_create_augroup("HightlightAllUrl", { clear = true }), - callback = function() handlers.set_url_effect() end, - }) - else + if user_opts.highlight_url.cursor_only then api.nvim_create_autocmd({ "CursorMoved" }, { desc = "URL Highlighting CursorMoved", group = api.nvim_create_augroup("HighlightCursorUrl", { clear = true }), @@ -23,6 +17,12 @@ M.setup = function(user_opts) api.nvim_set_hl(0, "HighlightCursorUrl", { underline = true }) end, }) + else + api.nvim_create_autocmd({ "VimEnter", "FileType", "BufEnter", "WinEnter" }, { + desc = "URL Highlighting", + group = api.nvim_create_augroup("HightlightAllUrl", { clear = true }), + callback = function() handlers.set_url_effect() end, + }) end end end