Skip to content

wsdjeg/git.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

72 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

git.nvim

git.nvim is an asynchronous git command wrapper plugin, using :Git command instead of :!git.

GitHub License GitHub Issues or Pull Requests GitHub commit activity GitHub Release

✨ Features

  • Asynchronous Git commands β€” Run Git commands via :Git without blocking Neovim UI.
  • Full Git coverage β€” Status, add, commit, push/pull, fetch, diff, branch, log, reflog, rebase, and more.
  • Branch Manager UI β€” Interactive branch list with key mappings for checkout, delete, log, and diff.
  • Picker.nvim sources β€” Includes fuzzy finder sources like git-branch for quick branch switching.
  • Statusline integration β€” Easily display current branch in your statusline via Lua API.

πŸ“¦ Installation

Use your preferred Neovim plugin manager to install git.nvim.

Using nvim-plug

require('plug').add({
    {
        'wsdjeg/git.nvim',
        depends = {
            { 'wsdjeg/job.nvim' },
            { 'wsdjeg/notify.nvim' },
        },
    },
})

Then use :PlugInstall git.nvim to install this plugin.

Using luarocks

luarocks install --server=https://luarocks.org/manifests/wsdjeg git.nvim

βš™οΈ Basic Usage

Use :Git to execute git commands directly inside Neovim, with behavior identical to the git command-line tool. It supports command and argument completion, runs git commands asynchronously without blocking the UI, and opens commit messages and rebase messages in split windows for a native, in-editor editing experience.

The plugin does not provide default key binding, here is an example:

vim.keymap.set('n', '<leader>gs', '<cmd>Git status<cr>', { silent = true })
vim.keymap.set('n', '<leader>gA', '<cmd>Git add .<cr>', { silent = true })
vim.keymap.set('n', '<leader>gc', '<cmd>Git commit<cr>', { silent = true })
vim.keymap.set('n', '<leader>gv', '<cmd>Git log<cr>', { silent = true })
vim.keymap.set('n', '<leader>gV', '<cmd>Git log %<cr>', { silent = true })
vim.keymap.set('n', '<leader>gp', '<cmd>Git push<cr>', { silent = true })
vim.keymap.set('n', '<leader>gd', '<cmd>Git diff<cr>', { silent = true })

git-add

just same as git add <path>, % will be replaced as current file.

git-blame

Show the revision and author that last modified each line of a file, displayed in split windows for easy inspection.

The blame view lets you quickly trace changes line-by-line and jump between file revisions without leaving Neovim.

key bindings in blame windows.

key binding description
<Enter> open previous of current line
<BS> switch back to newer version

git-branch

:Git branch without argument will open branch manager, within the branch manager these key bindings are available:

key binding description
dd delete branch under cursor
<Enter> checkout branch under cursor
v view git log of branch under cursor
f view git diff between current branch and branch under cursor

Git-rm

Remove files from the working tree and from the index. Supports file name completion after :Git rm command.

🎨 Statusline

If you want to display branch info on statusline, you can use v:lua.require("git.command.branch").current(), for example:

using statusline.nvim:

require('plug').add({
  {
    'wsdjeg/statusline.nvim',
    events = { 'VimEnter' },
    config = function()
      require('statusline').register_sections('vcs', function()
        return '%{ v:lua.require("git.command.branch").current() }'
      end)
      require('statusline').setup({
        left_sections = { 'winnr', 'filename', 'vcs' },
      })
    end,
  },
})

To display unicode spinners on statusline. You need to use git.nvim together with utils.nvim:

return {
    'wsdjeg/statusline.nvim',
    events = { 'VimEnter' },
    config = function()
        require('statusline').register_sections('vcs', function()
            return '%{ v:lua.require("git.command.branch").current() .. v:lua.require("git.command.pull").status() .. v:lua.require("git.command.push").status() }'
        end)
        require('statusline').setup({
            left_sections = { 'winnr', 'filename', 'major mode', 'syntax checking', 'vcs' },
            right_sections = { 'fileformat', 'fileencoding', 'cursorpos' },
        })
    end,
    type = 'rocks',
    desc = 'module statusline',
    dev = true,
}

Image

πŸ” Picker source

This plugin also provides sources for picker.nvim

  • git-branch: fuzzy find git branch to checkout
  • git-ghosts: fuzzy find deleted files

πŸ“£ Self-Promotion

Like this plugin? Star the repository on GitHub.

Love this plugin? Follow me on GitHub

πŸ’¬ Feedback

If you encounter any bugs or have suggestions, please file an issue in the issue tracker

About

git.nvim is a plugin to use git command in neovim

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Contributors 2

  •  
  •