2024-04-22 21:14:48 +00:00
|
|
|
(let [mod {}
|
2024-05-01 11:21:41 +00:00
|
|
|
wezterm (require :wezterm)
|
|
|
|
remote-origin (vim.fn.system "git remote get-url origin")]
|
|
|
|
(match remote-origin
|
|
|
|
(where r (r:find :git.kempkens.io)) (set mod.type :forgejo)
|
|
|
|
(where r (r:find :git.app.nedeco.de)) (set mod.type :gitlab)
|
|
|
|
(where r (r:find :github.com)) (set mod.type :github)
|
|
|
|
_ (set mod.type (or vim.env.REMOTE_REPO_TYPE :default)))
|
|
|
|
|
2024-04-22 21:14:48 +00:00
|
|
|
(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 []
|
2024-05-01 11:21:41 +00:00
|
|
|
(case mod.type
|
2024-04-22 21:14:48 +00:00
|
|
|
: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 []
|
2024-05-01 11:21:41 +00:00
|
|
|
(case mod.type
|
2024-04-22 21:14:48 +00:00
|
|
|
: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 []
|
2024-05-01 11:21:41 +00:00
|
|
|
(case mod.type
|
2024-04-22 21:14:48 +00:00
|
|
|
:github nil
|
|
|
|
:gitlab (open-split [(exe :glab) :pipeline :ci :view])
|
|
|
|
:forgejo nil))
|
|
|
|
|
2024-04-23 14:01:25 +00:00
|
|
|
(fn mod.run-ci []
|
2024-05-01 11:21:41 +00:00
|
|
|
(case mod.type
|
2024-04-23 14:01:25 +00:00
|
|
|
: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)
|