forked from NvChad/NvChad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
local get_url = require('lab/gx/lib/get_url') | ||
local handler = function (line, matched) | ||
local os = vim.loop.os_uname().sysname | ||
if vim.loop.os_uname().sysname ~= 'Darwin' then | ||
return vim.notify('unsupported os: ' .. os, vim.log.levels.WARN) | ||
end | ||
|
||
local command = string.format('open %s', matched) | ||
vim.fn.system(command) | ||
vim.notify(command) | ||
end | ||
local match = get_url | ||
local name = 'url' | ||
|
||
return { | ||
handler = handler, | ||
match = match, | ||
name = name, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
---라인 매칭에서 매칭 수행 반환은 url | ||
---@param input string | ||
---@return string|nil | ||
local get_url = function (input) | ||
local pattern = ".*(https?://[%w-_%.%?%.:/%+=&]+).*" | ||
|
||
return input:match(pattern) | ||
end | ||
|
||
return get_url |