From f6d3a363dae05243d6c2b64cb3df5add48f7bc10 Mon Sep 17 00:00:00 2001 From: Tran Vo Son Tung Date: Fri, 15 Sep 2023 15:00:24 +0700 Subject: [PATCH] fix: change the location in if else in autocmd module --- lua/url-open/modules/autocmd.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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