Skip to content

Commit

Permalink
feat: store current window highlighturl state
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Apr 17, 2024
1 parent a6cdc70 commit abe1ce8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/astrocore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,18 @@ function M.delete_url_match(win)
for _, match in ipairs(vim.fn.getmatches(win)) do
if match.group == "HighlightURL" then vim.fn.matchdelete(match.id, win) end
end
vim.w[win].highlighturl_enabled = false
end

--- Add syntax matching rules for highlighting URLs/URIs
---@param win integer? the window id to remove url highlighting in (default: current window)
function M.set_url_match(win)
if not win then win = vim.api.nvim_get_current_win() end
M.delete_url_match(win)
if M.config.features.highlighturl then vim.fn.matchadd("HighlightURL", M.url_matcher, 15, -1, { window = win }) end
if M.config.features.highlighturl then
vim.fn.matchadd("HighlightURL", M.url_matcher, 15, -1, { window = win })
vim.w[win].highlighturl_enabled = true
end
end

--- Run a shell command and capture the output and if the command succeeded or failed
Expand Down

0 comments on commit abe1ce8

Please sign in to comment.