https://github.com/Freed-Wu/git2.nvim
[WIP!!!] Use luagit2 to realize a :Git in neovim
https://github.com/Freed-Wu/git2.nvim
libgit2 lua neovim vim
Last synced: 11 months ago
JSON representation
[WIP!!!] Use luagit2 to realize a :Git in neovim
- Host: GitHub
- URL: https://github.com/Freed-Wu/git2.nvim
- Owner: Freed-Wu
- License: gpl-3.0
- Created: 2024-11-28T16:28:56.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-03T20:44:17.000Z (11 months ago)
- Last Synced: 2025-02-03T21:33:17.922Z (11 months ago)
- Topics: libgit2, lua, neovim, vim
- Language: Lua
- Homepage: https://luarocks.org/modules/Freed-Wu/git2.nvim
- Size: 24.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# git2.nvim
[](https://results.pre-commit.ci/latest/github/Freed-Wu/git2.nvim/main)
[](https://github.com/Freed-Wu/git2.nvim/actions)
[](https://github.com/Freed-Wu/git2.nvim/releases)
[](https://github.com/Freed-Wu/git2.nvim/releases/latest)
[](https://github.com/Freed-Wu/git2.nvim/issues)
[](https://github.com/Freed-Wu/git2.nvim/issues?q=is%3Aissue+is%3Aclosed)
[](https://github.com/Freed-Wu/git2.nvim/pulls)
[](https://github.com/Freed-Wu/git2.nvim/pulls?q=is%3Apr+is%3Aclosed)
[](https://github.com/Freed-Wu/git2.nvim/discussions)
[](https://github.com/Freed-Wu/git2.nvim/milestones)
[](https://github.com/Freed-Wu/git2.nvim/network/members)
[](https://github.com/Freed-Wu/git2.nvim/stargazers)
[](https://github.com/Freed-Wu/git2.nvim/watchers)
[](https://github.com/Freed-Wu/git2.nvim/graphs/contributors)
[](https://github.com/Freed-Wu/git2.nvim/graphs/commit-activity)
[](https://github.com/Freed-Wu/git2.nvim/commits)
[](https://github.com/Freed-Wu/git2.nvim/releases/latest)
[](https://github.com/Freed-Wu/git2.nvim/blob/main/LICENSE)
[](https://github.com/Freed-Wu/git2.nvim)
[](https://github.com/Freed-Wu/git2.nvim)
[](https://github.com/Freed-Wu/git2.nvim)
[](https://github.com/Freed-Wu/git2.nvim)
[](https://github.com/Freed-Wu/git2.nvim)
[](https://github.com/Freed-Wu/git2.nvim)
[](https://luarocks.org/modules/Freed-Wu/git2.nvim)
Use [luagit2](https://github.com/libgit2/luagit2) to realize a `:Git` in neovim.
## Related Projects
### CLI
- [vim-fugitive](https://github.com/tpope/vim-fugitive): call git process
**synchronously**. written in vim script.
- [vim-gina](https://github.com/lambdalisue/vim-gina): call git process
asynchronously. written in vim script. **stop maintenance**.
- [vim-gin](https://github.com/lambdalisue/vim-gin): call git process
asynchronously. written in denojs. same author as vim-gina.
### UI
- [vim-flog](https://github.com/rbong/vim-flog): call git process
**synchronously**. written in vim script.
- [committia.vim](https://github.com/rhysd/committia.vim): UI for CLI's `git
commit`. call git process **synchronously**. written in vim script.
- [nvim-tinygit](https://github.com/chrisgrieser/nvim-tinygit): call git process
asynchronously. written in lua.
- [neogit](https://github.com/NeogitOrg/neogit): call git process
asynchronously. written in lua.
- [blame.nvim](https://github.com/FabijanZulj/blame.nvim): UI for `git blame`.
call git process asynchronously. written in lua. inspired fugit2.nvim's
`Fugit2Blame`
- [fugit2.nvim](https://github.com/SuperBo/fugit2.nvim): call libgit2 by luajit
FFI. written in lua.
### Plugin
- [coc-git](https://github.com/neoclide/coc-git): call git process
asynchronously.
[issue about libgit2](https://github.com/neoclide/coc-git/issues/216)
- [fern-git-status.vim](http://github.com/lambdalisue/fern-git-status.vim): call
git process synchronously.
- [fern-mapping-git.vim](http://github.com/lambdalisue/fern-mapping-git.vim): call
git process synchronously.
## Similar Projects
- [magit](https://github.com/magit/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](https://github.com/rhysd/committia.vim/issues/66) of incorrect shell
settings. On Oct 2024, official lua binding of libgit2
[lua-git2](https://luarocks.org/modules/neopallium/lua-git2) is released
firstly. I believe it can bring more convenience to vim plugin developing and
start the experiment.
## Dependence
- [libgit2](https://github.com/libgit2/libgit2)
```sh
# 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
```vim
:Rocks install git2.nvim
```
#### Declare style
`~/.config/nvim/rocks.toml`:
```toml
[plugins]
"git2.nvim" = "scm"
```
Then
```vim
:Rocks sync
```
or:
```sh
$ 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
```vim
:edit subdir/test.txt
:Git init
:cd subdir
:Git -C .. add %
```
## TODO
- full CLI APIs. wait [upstream](https://github.com/libgit2/luagit2/issues/10)
- completion of `:Git `, wait
[upstream](https://github.com/mpeterv/argparse/issues/28)
- UI for CLI's `git commit`, vim's `:Git blame`, `:Git status`, ...