2024-04-22 21:14:48 +00:00
|
|
|
(let [mod {}
|
|
|
|
wezterm (require :wezterm)]
|
|
|
|
(fn exe [bin] (vim.fn.exepath bin))
|
|
|
|
|
2024-04-23 14:01:25 +00:00
|
|
|
(fn run-cmd [program]
|
|
|
|
(vim.system program {:cwd (vim.loop.cwd)}))
|
|
|
|
|
2024-04-22 21:14:48 +00:00
|
|
|
(fn open-split [program]
|
2024-04-23 14:01:25 +00:00
|
|
|
(let [args [:cli
|
|
|
|
:split-pane
|
|
|
|
:--bottom
|
|
|
|
:--percent
|
|
|
|
:60
|
|
|
|
:--cwd
|
|
|
|
(vim.loop.cwd)
|
|
|
|
"--"]]
|
2024-04-22 21:14:48 +00:00
|
|
|
(each [_ value (ipairs program)]
|
|
|
|
(table.insert args value))
|
|
|
|
(wezterm.exec args
|
|
|
|
(fn [result]
|
|
|
|
(when (not= result.code 0)
|
|
|
|
(vim.notify "wezterm: Error opening split window"
|
|
|
|
vim.log.levels.ERROR []))))))
|
|
|
|
|
|
|
|
(fn mod.open-repo []
|
|
|
|
(case vim.env.REMOTE_REPO_TYPE
|
|
|
|
:github nil
|
2024-04-23 14:01:25 +00:00
|
|
|
:gitlab (run-cmd [:glab :repo :view :--web])
|
2024-04-23 21:22:44 +00:00
|
|
|
:forgejo (run-cmd [:tea :open])))
|
2024-04-22 21:14:48 +00:00
|
|
|
|
|
|
|
(fn mod.open-merge-request []
|
|
|
|
(case vim.env.REMOTE_REPO_TYPE
|
|
|
|
:github nil
|
2024-04-23 14:01:25 +00:00
|
|
|
:gitlab (run-cmd [:glab :mr :view :--web])
|
2024-04-22 21:14:48 +00:00
|
|
|
:forgejo nil))
|
|
|
|
|
|
|
|
(fn mod.open-ci []
|
|
|
|
(case vim.env.REMOTE_REPO_TYPE
|
|
|
|
:github nil
|
|
|
|
:gitlab (open-split [(exe :glab) :pipeline :ci :view])
|
|
|
|
:forgejo nil))
|
|
|
|
|
2024-04-23 14:01:25 +00:00
|
|
|
(fn mod.run-ci []
|
|
|
|
(case vim.env.REMOTE_REPO_TYPE
|
|
|
|
:github nil
|
|
|
|
:gitlab (do
|
|
|
|
(run-cmd [:glab :pipeline :run])
|
|
|
|
(open-split [(exe :glab) :pipeline :ci :view]))
|
|
|
|
:forgejo nil))
|
|
|
|
|
2024-04-22 21:14:48 +00:00
|
|
|
mod)
|