-
Notifications
You must be signed in to change notification settings - Fork 1
/
links.lua
46 lines (40 loc) · 1.41 KB
/
links.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
local M = {}
---@param config Config
function M.setup(config)
config.hyperlink_rules = {
-- Linkify things that look like URLs and the host has a TLD name.
--
-- Compiled-in default. Used if you don't specify any hyperlink_rules.
{
regex = "\\b\\w+://[\\w.-]+\\.[a-z]{2,15}\\S*\\b",
format = "$0",
},
-- linkify email addresses
-- Compiled-in default. Used if you don't specify any hyperlink_rules.
{
regex = [[\b\w+@[\w-]+(\.[\w-]+)+\b]],
format = "mailto:$0",
},
-- file:// URI
-- Compiled-in default. Used if you don't specify any hyperlink_rules.
{
regex = [[\bfile://\S*\b]],
format = "$0",
},
-- Linkify things that look like URLs with numeric addresses as hosts.
-- E.g. http://127.0.0.1:8000 for a local development server,
-- or http://192.168.1.1 for the web interface of many routers.
{
regex = [[\b\w+://(?:[\d]{1,3}\.){3}[\d]{1,3}\S*\b]],
format = "$0",
},
-- Make username/project paths clickable. This implies paths like the following are for GitHub.
-- As long as a full URL hyperlink regex exists above this it should not match a full URL to
-- GitHub or GitLab / BitBucket (i.e. https://gitlab.com/user/project.git is still a whole clickable URL)
{
regex = [[["]?([\w\d]{1}[-\w\d]+)(/){1}([-\w\d\.]+)["]?]],
format = "https://www.github.com/$1/$3",
},
}
end
return M