1
0
Fork 0
dotfiles/home/config/nvim/nifoc/repo.fnl

52 lines
1.4 KiB
Text
Raw Normal View History

2024-04-22 21:14:48 +00:00
(let [mod {}
wezterm (require :wezterm)]
(fn exe [bin] (vim.fn.exepath bin))
(fn run-cmd [program]
(vim.system program {:cwd (vim.loop.cwd)}))
2024-04-22 21:14:48 +00:00
(fn open-split [program]
(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
:gitlab (run-cmd [:glab :repo :view :--web])
: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
: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))
(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)