Sitemap
Unixification

We write about ricing different Unix systems such as macOS, and Linux. Other than Unix systems we write on various tools, like Neovim and Obsidian.

My Neovim Git Setup

3 min readDec 26, 2022

--

Screenshot by author

Today, I will be sharing my git setup for Neovim.

I recently wrote an article on lazy.nvim, therefore the installation and configuration will be using it (instead of something like packer.nvim).

Neogit

I previously used Doom Emacs and one of my favorite plugins was Magit. It had many features that gave more information and made it easier to work with git. For me, I usually only needed to commit, push, and pull. I rarely did anything fancy, so Magit was more than enough.

Neogit is a work-in-progress clone of Magit for Neovim. Even with the current features, it is more than enough for my needs.

Screenshot of Neogit by author

Installation

return {
"TimUntersberger/neogit",
cmd = "Neogit",
config = function()
require("neogit").setup({
kind = "split", -- opens neogit in a split
signs = {
-- { CLOSED, OPENED }
section = { "", "" },
item = { "", "" },
hunk = { "", "" },
},
integrations = { diffview = true }, -- adds integration with diffview.nvim
})
end,
}

The characters for section and item don’t show up, but they should work (copy/paste) with a Nerd Font. I am currently using Fira Code Nerd Font.

Keybinds

Neogit has numerous keybinds, but the ones I use the most are:

  • <C-s> Stage Everything
  • p Opens pull popup
  • P Opens push popup
  • c Opens commit popup
  • Tab Toggles diff

Gitsigns

Gitsigns is a blazingly fast plugin that adds git decorations. This plugin provides functional usage, but I mainly like it for its aesthetic.

Installation

return {
"lewis6991/gitsigns.nvim",
event = "BufReadPre",

config = function()
require("gitsigns").setup({
signs = {
add = { hl = "GitSignsAdd", text = "│", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
change = {
hl = "GitSignsChange",
text = "│",
numhl = "GitSignsChangeNr",
linehl = "GitSignsChangeLn",
},
delete = { hl = "GitSignsDelete", text = "_", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
topdelete = {
hl = "GitSignsDelete",
text = "‾",
numhl = "GitSignsDeleteNr",
linehl = "GitSignsDeleteLn",
},
changedelete = {
hl = "GitSignsChange",
text = "~",
numhl = "GitSignsChangeNr",
linehl = "GitSignsChangeLn",
},
untracked = { hl = "GitSignsAdd", text = "┆", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
},
})
end,
}

All this config does is install the plugin and set the signs.

Diffview

Diffview allows effective cycling through diffs of modified files. This makes it very easy to view changes. I don’t often use diffview but it can come in handy sometimes.

Screenshot by author

Installation

return {
"sindrets/diffview.nvim",
cmd = { "DiffviewOpen", "DiffviewClose", "DiffviewToggleFiles", "DiffviewFocusFiles" },
}

Overall, these are the git plugins I use. The one I use the most by far is Neogit. Gitsigns is mainly for the aesthetic and diffview is useful when merging.

I would recommend giving these plugins a try and remember to keep vimming.

--

--

Unixification
Unixification

Published in Unixification

We write about ricing different Unix systems such as macOS, and Linux. Other than Unix systems we write on various tools, like Neovim and Obsidian.

Michael Bao
Michael Bao

Written by Michael Bao

Neovim | Arch Linux | macOS | I love to write about random tech stuff. Tinkering around with Linux, Neovim, and computers.

No responses yet