NOTE: This plugin is currently a work in progress and not stable, or ready for public use.
This Neovim plugin is designed to make it easy to review Gitlab MRs from within the editor. The plugin wraps around the Gitlab CLI tool.
gitlab_nvim_demo.mp4
- Go
- The Gitlab CLI
- lazy.nvim
- nui.nvim
- nvim-notify
- diffview.nvim
First, configure the Gitlab CLI. Next, you'll need to have the following environment variable available in your shell:
export GITLAB_TOKEN="your_gitlab_token"
Then install the plugin with Lazy:
return {
"harrisoncramer/gitlab",
dependencies = {
"sindrets/diffview.nvim",
"rcarriga/nvim-notify",
"MunifTanjim/nui.nvim"
},
config = function()
local gitlab = require("gitlab")
gitlab.setup({ project_id = 3 })
end,
}
By default, the tool will look for and interact with MRs against a "main" branch. You can configure this by passing in the base_branch
option:
require('gitlab_nvim').setup({ project_id = 3, base_branch = 'master' })
The first time you call the setup function the Go binary will be built.
First, check out the branch that you want to review locally.
The summary
command will pull down the MR description into a buffer so that you can read it
require("gitlab_nvim").summary()
The review
command will open up a diffview of all your changed files, using the diffview plugin
require("gitlab_nvim").review()
The approve
command will approve the merge request for the current branch
require("gitlab_nvim").approve()
The revoke
command will revoke approval for the merge request for the current branch.
require("gitlab_nvim").revoke()
The comment
command will open up a NUI popover that will allow you to create a Gitlab comment on the current line. To send the comment, use <leader>s
require("gitlab_nvim").comment()
This plugin does not create any keybindings by default, except for inside of the popups, where:
<esc>
quits the popups<leader>s
sends the comment
These bindings are local and do not overwrite anything in your configuration.
These are the keybindings that I'm using:
local gitlab = require("gitlab")
vim.keymap.set("n", "<leader>gls", gitlab.summary)
vim.keymap.set("n", "<leader>glr", gitlab.review)
vim.keymap.set("n", "<leader>gla", gitlab.approve)
vim.keymap.set("n", "<leader>glR", gitlab.revoke)
vim.keymap.set("n", "<leader>glc", gitlab.comment)