Skip to content

Freed-Wu/git2.nvim

Repository files navigation

git2.nvim

pre-commit.ci status github/workflow

github/downloads github/downloads/latest github/issues github/issues-closed github/issues-pr github/issues-pr-closed github/discussions github/milestones github/forks github/stars github/watchers github/contributors github/commit-activity github/last-commit github/release-date

github/license github/languages github/languages/top github/directory-file-count github/code-size github/repo-size github/v

luarocks

Use luagit2 to realize a :Git in neovim.

Related Projects

CLI

  • 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.

UI

  • 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's Fugit2Blame
  • fugit2.nvim: call libgit2 by luajit FFI. written in lua.

Plugin

Similar Projects

  • magit: git UI for emacs

Motivation

  • Many vim users are experienced CLI users, a vim command :Git like CLI's git should 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's vim.uv.timer to 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.

Dependence

# 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 tap tonyfettes/homebrew-git2
brew install libgit2 pkg-config
# Windows msys2
pacboy -S --noconfirm pkg-config libgit2 gcc

Install

rocks.nvim

Command style

:Rocks install git2.nvim

Declare style

~/.config/nvim/rocks.toml:

[plugins]
"git2.nvim" = "scm"

Then

:Rocks sync

or:

$ 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_path

Usage

:edit subdir/test.txt
:Git init
:cd subdir
:Git -C .. add %

TODO

  • full CLI APIs. wait upstream
  • completion of :Git <TAB>, wait upstream
  • UI for CLI's git commit, vim's :Git blame, :Git status, ...

Releases

No releases published

Packages

No packages published