diff --git a/README.md b/README.md index 2eb1a7a..c607ece 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,7 @@ The plugin does not set up any keybindings outside of these buffers, you need to ```lua local gitlab = require("gitlab") +vim.keymap.set("n", "glr", gitlab.review) vim.keymap.set("n", "gls", gitlab.summary) vim.keymap.set("n", "glA", gitlab.approve) vim.keymap.set("n", "glR", gitlab.revoke) @@ -234,6 +235,7 @@ vim.keymap.set("n", "glad", gitlab.delete_assignee) vim.keymap.set("n", "glra", gitlab.add_reviewer) vim.keymap.set("n", "glrd", gitlab.delete_reviewer) vim.keymap.set("n", "glp", gitlab.pipeline) +vim.keymap.set("n", "glo", gitlab.open_in_browser) ``` ## Troubleshooting diff --git a/lua/gitlab/actions/miscellaneous.lua b/lua/gitlab/actions/miscellaneous.lua new file mode 100644 index 0000000..0f6ea08 --- /dev/null +++ b/lua/gitlab/actions/miscellaneous.lua @@ -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 diff --git a/lua/gitlab/init.lua b/lua/gitlab/init.lua index a5d0a30..39d1b83 100644 --- a/lua/gitlab/init.lua +++ b/lua/gitlab/init.lua @@ -9,6 +9,7 @@ local assignees_and_reviewers = require("gitlab.actions.assignees_and_reviewers" local comment = require("gitlab.actions.comment") local pipeline = require("gitlab.actions.pipeline") local approvals = require("gitlab.actions.approvals") +local miscellaneous = require("gitlab.actions.miscellaneous") local info = state.dependencies.info local project_members = state.dependencies.project_members @@ -44,4 +45,5 @@ return { -- Other functions 🤷 state = state, print_settings = state.print_settings, + open_in_browser = async.sequence({ info }, miscellaneous.open_in_browser), }