nvim: very basic glab integration
This commit is contained in:
parent
7e0645978e
commit
4aae815264
4 changed files with 52 additions and 3 deletions
|
@ -198,6 +198,7 @@
|
|||
];
|
||||
|
||||
TREEFMT_CONFIG_FILE = config.treefmt.build.configFile;
|
||||
REMOTE_REPO_TYPE = "forgejo";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
neogit (require :neogit)
|
||||
wk (require :which-key)
|
||||
repl (require :nifoc.repl)
|
||||
repo (require :nifoc.repo)
|
||||
formatting (require :nifoc.formatting)]
|
||||
(fn mod.setup []
|
||||
(keymap.set :n :<space> :<nop> {:noremap true})
|
||||
|
@ -43,6 +44,9 @@
|
|||
(keymap.set :n :<leader>vl #(gitsigns.blame_line {:full true})
|
||||
{:desc "Blame Line"})
|
||||
(keymap.set :n :<leader>vd :<cmd>DiffviewOpen<CR> {:desc "Open DiffView"})
|
||||
(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>lk telescope-builtin.keymaps
|
||||
{:desc "Show Keymappings"})
|
||||
(keymap.set :n :<leader>ld #(telescope-builtin.diagnostics telescope-ivy)
|
||||
|
|
33
home/config/nvim/nifoc/repo.fnl
Normal file
33
home/config/nvim/nifoc/repo.fnl
Normal file
|
@ -0,0 +1,33 @@
|
|||
(let [mod {}
|
||||
wezterm (require :wezterm)]
|
||||
(fn exe [bin] (vim.fn.exepath bin))
|
||||
|
||||
(fn open-split [program]
|
||||
(let [args [:cli :split-pane :--bottom :--percent :60 "--"]]
|
||||
(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 (vim.system [: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])
|
||||
:forgejo nil))
|
||||
|
||||
(fn mod.open-ci []
|
||||
(case vim.env.REMOTE_REPO_TYPE
|
||||
:github nil
|
||||
:gitlab (open-split [(exe :glab) :pipeline :ci :view])
|
||||
:forgejo nil))
|
||||
|
||||
mod)
|
|
@ -7,6 +7,7 @@
|
|||
web-devicons (require :nvim-web-devicons)
|
||||
colors (. (require :nifoc.theme) :colors)
|
||||
formatting (require :nifoc.formatting)
|
||||
repo (require :nifoc.repo)
|
||||
nifoc-treesitter (require :nifoc.treesitter)
|
||||
navic (require :nvim-navic)
|
||||
neogit (require :neogit)]
|
||||
|
@ -150,6 +151,11 @@
|
|||
;; 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"}}
|
||||
:init (fn [self]
|
||||
(let [git-status vim.b.gitsigns_status_dict]
|
||||
(set self.git-head git-status.head)
|
||||
|
@ -167,11 +173,16 @@
|
|||
:callback #(neogit.open {:kind :split})}
|
||||
:hl {:fg colors.black :bg colors.orange :bold true}}
|
||||
3 mod.space
|
||||
4 {:provider #(.. " " $1.git-added " ")
|
||||
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)}}
|
||||
5 {:provider #(.. " " $1.git-added " ")
|
||||
:hl {:fg colors.bright_green}}
|
||||
5 {:provider #(.. " " $1.git-removed " ")
|
||||
6 {:provider #(.. " " $1.git-removed " ")
|
||||
:hl {:fg colors.bright_red}}
|
||||
6 {:provider #(.. " " $1.git-changed) :hl {:fg colors.cyan}}})
|
||||
7 {:provider #(.. " " $1.git-changed) :hl {:fg colors.cyan}}})
|
||||
;; Diagnostics
|
||||
(set mod.diagnostics {:condition heirline-conditions.has_diagnostics
|
||||
:init (fn [self]
|
||||
|
|
Loading…
Reference in a new issue