Use luagit2 to realize a :Git in neovim.
- vim-fugitive: call git process synchronously. written in vim script.
- vim-gina: call git process asynchronously. written in vim script. stop maintenance.
- vim-gin: call git process asynchronously. written in denojs. same author as vim-gina.
- git.nvim: call git process asynchronously. written in lua.
- vim-flog: call git process synchronously. written in vim script.
- committia.vim: UI for CLI's
git commit. call git process synchronously. written in vim script. - nvim-tinygit: call git process asynchronously. written in lua.
- neogit: call git process asynchronously. written in lua.
- blame.nvim: UI for
git blame. call git process asynchronously. written in lua. inspired fugit2.nvim'sFugit2Blame - fugit2.nvim: call libgit2 by luajit FFI. written in lua.
- coc-git: call git process asynchronously. issue about libgit2
- fern-git-status.vim: call git process synchronously.
- fern-mapping-git.vim: call git process synchronously.
- magit: git UI for emacs
- Many vim users are experienced CLI users, a vim command
:Gitlike CLI'sgitshould be helpful to save their learning time. A good CLI even is a more significant matter than UI. In this aspect, vim-fugitive, vim-gina do well. - call git process synchronously is slow. many vim plugins select use vim
script's
jobstart()or neovim'svim.uv.timerto call git process asynchronously. fugit2.nvim is 1st plugin to call libgit2 and bring novelty to vim community. Don't call git process can avoid some bug of incorrect shell settings. On Oct 2024, official lua binding of libgit2 lua-git2 is released firstly. I believe it can bring more convenience to vim plugin developing and start the experiment.
# Ubuntu
sudo apt-get -y install libgit2-dev libgit2
sudo apt-mark auto libgit2-dev
# ArchLinux
sudo pacman -S libgit2
# Android Termux
apt-get -y install libgit2
# Nix
# use nix-shell to create a virtual environment then build
# homebrew
brew install libgit2 pkg-config
# Windows msys2
pacboy -S --noconfirm pkg-config libgit2 gcc:Rocks install git2.nvim~/.config/nvim/rocks.toml:
[plugins]
"git2.nvim" = "scm"Then
:Rocks syncor:
$ luarocks --lua-version 5.1 --local --tree ~/.local/share/nvim/rocks install git2.nvim
# ~/.local/share/nvim/rocks is the default rocks tree path
# you can change it according to your vim.g.rocks_nvim.rocks_pathrequire("lazy").setup {
spec = {
{ "Freed-Wu/git2.nvim", lazy = false },
},
}:edit subdir/test.txt
:Git init
:cd subdir
:Git -C .. add %
:Git rm --cached %:Git blameUse virtual text to display blame info like
:Fugit2Blame.
git commitwill :vsplit a diff window like
committia.
inoremap <buffer> <M-N> <C-O>:lua require('git2.nvim.committia').scroll_window('<C-V><C-F>')<CR>
inoremap <buffer> <M-P> <C-O>:lua require('git2.nvim.committia').scroll_window('<C-V><C-B>')<CR>let g:airline#extensions#hunks#enabled = 1if has('nvim')
function! s:gitModified() abort
let files = v:lua.require'git2.status'.ls(v:true)
return map(files, "{'line': v:val, 'path': v:val}")
endfunction
function! s:gitUntracked() abort
let files = v:lua.require'git2.status'.ls(v:false, v:true)
return map(files, "{'line': v:val, 'path': v:val}")
endfunction
let g:startify_lists = [
\ {'type': function('s:gitModified'), 'header': ['! Git Modified']},
\ {'type': function('s:gitUntracked'), 'header': ['? Git Untracked']},
\ ]
endif! Git Modified
[.a] README.md
? Git Untracked
[.b] a.txt
Replace fern-mapping-git.vim
if has('nvim')
nnoremap <buffer><nowait> << :<C-U>call fern#scheme#file#mapping#git#stage()<CR>
nnoremap <buffer><nowait> >> :<C-U>call fern#scheme#file#mapping#git#unstage()<CR>
endifReplace fern-git-status
if has('nvim')
call fern#scheme#file#hook#git#init()
endif git2.nvim/
autoload/ [ -]
fern/ [ -]
scheme/ [ -]
file/ [ -]
hook/ [ -]
git.vim [ M]
mapping/
bin/
lua/
packages/
plugin/
scripts/
spec/
git2.nvim-scm-1.rockspec
LICENSE
README.md [ M]
shell.nix
- full CLI APIs. wait upstream
- UI for CLI's
git commit, vim's:Git blame,:Git status, ...