feat: improve hyperlink matching with regular expressions

This commit is contained in:
2024-10-21 05:48:34 -04:00
parent 7ea66629e9
commit 85a6f84c5a
+36 -1
View File
@@ -5,7 +5,42 @@
local M = {}
-- Hyperlink Rules
CONFIG.hyperlink_rules = WEZTERM.default_hyperlink_rules()
CONFIG.hyperlink_rules = {
-- Matches: a URL in parens: (URL)
{
regex = "\\((\\w+://\\S+)\\)",
format = "$1",
highlight = 1,
},
-- Matches: a URL in brackets: [URL]
{
regex = "\\[(\\w+://\\S+)\\]",
format = "$1",
highlight = 1,
},
-- Matches: a URL in curly braces: {URL}
{
regex = "\\{(\\w+://\\S+)\\}",
format = "$1",
highlight = 1,
},
-- Matches: a URL in angle brackets: <URL>
{
regex = "<(\\w+://\\S+)>",
format = "$1",
highlight = 1,
},
-- implicit mailto link
{
regex = "\\b\\w+@[\\w-]+(\\.[\\w-]+)+\\b",
format = "mailto:$0",
},
-- Then handle URLs not wrapped in brackets
{
regex = "\\w+://[^\\s\\]})(]+",
format = "$0",
},
}
-- Add support for GitHub link style