Skip to content

Git + Fzf for neovim. Run forgit and git commands interactively inside nvim.

License

Notifications You must be signed in to change notification settings

shaunwen/forgit.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

forgit.nvim

Interactive git commands with fzf.

This plug is a wrapper of interactive git commands

  • forgit by Wenxuan Zhang
  • git-fuzzy
  • 42 git commands alias
  • integrated with diffview.nvim
  • Wraps vim-fugitive commands
  • Up to 100 git commands / alias supported

You need

  • install forgit
  • fzf so you can confirm/select the matches to apply your changes, also check fzf-vim-integration, as vim plugin and fzf README-VIM
  • install git-fuzzy (optional)
  • by default the plugin using fd to list all files in the current folder, you can use git ls_file
  • a diff pager, e.g. delta
  • vim-fugitive (highly recommended)
forgit.mp4

install

Plug 'ray-x/guihua.lua'  "lua GUI lib
Plug 'ray-x/forgit.nvim'

Configure

require'forgit'.setup({
  debug = false, -- enable debug logging default path is ~/.cache/nvim/forgit.log
  diff_pager = 'delta', -- you can use `diff`, `diff-so-fancy`
  diff_cmd = '', -- you can use `DiffviewOpen`, `Gvdiffsplit` or `!git diff`, auto if not set
  fugitive = false, -- git fugitive installed?
  git_alias = true,  -- git command extensions see: Git command alias
  show_result = 'quickfix', -- show cmd result in quickfix or notify

  shell_mode = true, -- set to true if you using zsh/bash and can not run forgit commands
  height_ratio = 0.6, -- height ratio of floating window when split horizontally
  width_ratio = 0.6, -- width ratio of floating window when split vertically
  cmds_list = {} -- additional commands to show in Forgit command list
  --  e.g. cmd_list = {text = 'Gs get_hunks', cmd = 'Gitsigns get_hunks'}
})

Screenshot

ga

gbd

usage

  • forgit commands supported by this plugin
Command Action
Ga{!} Interactive git add generator, bang! will unstage files
Glo Interactive git log generator
Gi Interactive .gitignore generator
Gd Interactive git diff viewer
Grh Interactive git reset HEAD <file> selector
Gcf Interactive git checkout <file> selector
Gcb Interactive git checkout <branch> selector
Gbd Interactive git branch -D <branch> selector
Gct Interactive git checkout <tag> selector
Gco Interactive git checkout <commit> selector
Grc Interactive git revert <commit> selector
Gss Interactive git stash viewer
Gsp Interactive git stash push selector
Gclean Interactive git clean selector
Gcp Interactive git cherry-pick selector
Grb Interactive git rebase -i selector
Gbl Interactive git blame selector
Gfu Interactive git commit --fixup && git rebase -i --autosquash selector
  • git + fzf commands supported only by this plugin
Command Action
Gac Interactive git add generator, if file staged, run 'git commit'
Gfz run git fuzzy, sub commands supports, e.g. Gfz status
Gbc Interactive git branch && checkout generator
Gdl Interactive git diff --name-only & edit selected file generator
Gdl! Interactive git diff master/main --name-only & edit selected file generator
Gcbc Interactive git branch --sort=-committerdate && checkout generator, The preview is graphic view of git log
Gdc Interactive git log commit_hash & show diff against current generator
Gldt Interactive git log commit_hash & difftool hash of selected filename generator
Gldt! Interactive git log commit_hash & difftool hash of all files generator

|Gbdo | Interactive git branch & DiffviewOpen selected branch with diffview.nvim generator | |Gldo | Interactive git log commit_hash & DiffviewOpen current file with diffview.nvim generator | |Gldo! | Interactive git log commit_hash & DiffviewOpen all diff files with diffview.nvim generator | |Grlg | Interactive git rev-list & git grep generator |

⌨ Forgit Keybinds

Key Action
Enter Confirm
Tab Toggle mark and move up
Shift - Tab Toggle mark and move down
? Toggle preview window
Alt - W Toggle preview wrap
Ctrl - S Toggle sort
Ctrl - R Toggle selection
Ctrl - Y Copy commit hash*
Ctrl - K / P Selection move up
Ctrl - J / N Selection move down
Alt - K / P Preview move up
Alt - J / N Preview move down

⌨ Git command alias

Command Action
Gaa git add --all
Gap git add -pu
Gash git stash
Gasha git stash apply
Gashp git stash pop
Gashu git stash --include-untracked
Gau git add -u
Gc git commit, if -m not specify, will prompt a ui.input
Gce git clean
Gcef git clean -fd
Gcl git clone
Gdf git diff --
Gdnw git diff -w --
Gdw git diff --word-diff
Gdmn git diff master/main --name-only | fzf
Gdn git diff --name-only | fzf
Gf git fetch
Gfa git fetch --all
Gfr git fetch; and git rebase
Glg git log --graph --decorate
Gm git merge
Gmff git merge --ff
Gmnff git merge --no-ff
Gopen git config --get remote.origin.url
Gpl git pull
Gplr git pull --rebase
Gps git push
Gpsf git push --force-with-lease
Gr git remote -v
Grb git rebase
Grbi git rebase -i
Grbc git rebase --continue
Grba git rebase --abort
Grs git reset --
Grsh git reset --hard
Grsl git reset HEAD~
Gs git status
Gsh git show
Gt git tag
Gtop git rev-parse --show-toplevel
Gurl git config --get remote.origin.url

🍱 All in One

Forgit allows you to list all commands in a list and you can fuzzy search and run any command you want.

  • vim-fugitive commands
  • forgit commands
  • forgit.nvim commands (acronym)
  • vim-flog commands
  • gitsigns commands

📦 Optional dependencies

About

Git + Fzf for neovim. Run forgit and git commands interactively inside nvim.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%