Feat: Adds open_in_browser() command to open MR in browser

This commit is contained in:
Harrison Cramer
2023-09-07 20:40:11 -04:00
parent 57b842cad5
commit f05b6f128b
3 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
local state = require("gitlab.state")
local M = {}
M.open_in_browser = function()
local url = state.INFO.web_url
if url == nil then
vim.notify("Could not get Gitlab URL", vim.log.levels.ERROR)
return
end
if vim.fn.has("mac") == 1 then
vim.fn.jobstart({ "open", url })
elseif vim.fn.has("unix") == 1 then
vim.fn.jobstart({ "xdg-open", url })
else
vim.notify("Opening a Gitlab URL is not supported on this OS!", vim.log.levels.ERROR)
end
end
return M