1
0
Fork 0

nvim: update git remote software integration

This commit is contained in:
Daniel Kempkens 2024-04-23 16:01:25 +02:00
parent 12c779cd10
commit 843b01cecd
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
3 changed files with 35 additions and 15 deletions

View file

@ -47,6 +47,7 @@
(keymap.set :n :<leader>vvr #(repo.open-repo) {:desc "Open repository"})
(keymap.set :n :<leader>vvm #(repo.open-merge-request) {:desc "Open MR"})
(keymap.set :n :<leader>vvc #(repo.open-ci) {:desc "Open CI"})
(keymap.set :n :<leader>vtc #(repo.run-ci) {:desc "Trigger CI"})
(keymap.set :n :<leader>lk telescope-builtin.keymaps
{:desc "Show Keymappings"})
(keymap.set :n :<leader>ld #(telescope-builtin.diagnostics telescope-ivy)

View file

@ -2,8 +2,18 @@
wezterm (require :wezterm)]
(fn exe [bin] (vim.fn.exepath bin))
(fn run-cmd [program]
(vim.system program {:cwd (vim.loop.cwd)}))
(fn open-split [program]
(let [args [:cli :split-pane :--bottom :--percent :60 "--"]]
(let [args [:cli
:split-pane
:--bottom
:--percent
:60
:--cwd
(vim.loop.cwd)
"--"]]
(each [_ value (ipairs program)]
(table.insert args value))
(wezterm.exec args
@ -15,13 +25,13 @@
(fn mod.open-repo []
(case vim.env.REMOTE_REPO_TYPE
:github nil
:gitlab (vim.system [:glab :repo :view :--web])
:gitlab (run-cmd [:glab :repo :view :--web])
:forgejo nil))
(fn mod.open-merge-request []
(case vim.env.REMOTE_REPO_TYPE
:github nil
:gitlab (vim.system [:glab :mr :view :--web])
:gitlab (run-cmd [:glab :mr :view :--web])
:forgejo nil))
(fn mod.open-ci []
@ -30,4 +40,12 @@
: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))
mod)

View file

@ -151,13 +151,15 @@
;; git
(set mod.git
{:condition heirline-conditions.is_git_repo
:static {:git-repo-type vim.env.REMOTE_REPO_TYPE
:git-repo-icon {:github " " :gitlab " " :forgejo ""}
:git-repo-color {:github "#f6f8fa"
:gitlab "#d15232"
:forgejo "#c22d15"}}
:static {:git-repo-type (or vim.env.REMOTE_REPO_TYPE :default)
:git-repo-icons {:github ""
:gitlab ""
:forgejo ""
:default ""}}
:init (fn [self]
(let [git-status vim.b.gitsigns_status_dict]
(set self.git-repo-icon
(. self.git-repo-icons self.git-repo-type))
(set self.git-head git-status.head)
(set self.git-added (or git-status.added 0))
(set self.git-removed (or git-status.removed 0))
@ -168,16 +170,15 @@
self.git-changed]))
(set self.check-length (length self.git-head))))
1 mod.space-if-count-or-length
2 {:provider #(.. "  " $1.git-head " ")
2 {:provider #(.. " " $1.git-repo-icon " ")
:on_click {:name :heirline_git_repo_type
:callback #(repo.open-repo)}
:hl {:fg colors.black :bg colors.orange :bold true}}
3 {:provider #(.. $1.git-head " ")
:on_click {:name :heirline_git_branch
:callback #(neogit.open {:kind :split})}
:hl {:fg colors.black :bg colors.orange :bold true}}
3 mod.space
4 {:condition #(not= $1.git-repo-type nil)
:provider #(.. (. $1.git-repo-icon $1.git-repo-type) " ")
:on_click {:name :heirline_git_repo_type
:callback #(repo.open-repo)}
:hl #{:fg (. $1.git-repo-color $1.git-repo-type)}}
4 mod.space
5 {:provider #(.. " " $1.git-added " ")
:hl {:fg colors.bright_green}}
6 {:provider #(.. " " $1.git-removed " ")