Skip to content

SuperBo/fugit2.nvim

Repository files navigation

A Git Porcelain inside Neovim

Neovim Lua GitHub Workflow Status

Git plugin for Neovim (based on libgit2).

Fugit2 Main View Fugit2 Graph View

✨ Features

  • ✔ Floating git source window.
  • ✔ Magit style menu.
  • ✔ Patch View.
  • ✔ Stage/Unstage hunkes in patch view.
  • ✔ Nice git graph.
  • ☐ TODO: In-memory rebase.
  • ☐ TODO: Diff view.
  • ☐ TODO: Remap default key binding.
  • ☐ TODO: Proper help menu.
  • ☐ TODO: Native branch popup.

📦 Installation

Third party libraries:

Libgit2

How to install libgit2

Libgit2 is required for this plugin to work. So you have to install it in your OS before starting with Fugit2. For more information, you can refer to this https://libgit2.org/

Ubuntu 22.04

sudo apt-get install -y libgit2-1.1
# sudo ln -s /usr/lib/x86_64-linux-gnu/libgit2.so.1.1 /usr/local/lib/libgit2.so
# sudo ldconfig

Set libgit2_path value in config options like this

{
  'SuperBo/fugit2.nvim',
  opts = {
    libgit2_path = 'libgit2.so.1.1',
  },
  ...
}

Ubuntu 23.10

sudo apt-get install -y libgit2-1.5
# sudo ln -s /usr/lib/x86_64-linux-gnu/libgit2.so.1.5 /usr/local/lib/libgit2.so
# sudo ldconfig

Set libgit2_path value in config options like this

{
  'SuperBo/fugit2.nvim',
  opts = {
    libgit2_path = 'libgit2.so.1.5',
  },
  ...
}

Ubuntu 24.04

sudo apt-get install -y libgit2-1.7

Set libgit2_path value in config options like this

{
  'SuperBo/fugit2.nvim',
  opts = {
    libgit2_path = 'libgit2.so.1.7',
  },
  ...
}

Arch Linux

sudo pacman -S libgit2

Fedora

yum install libgit2

Set libgit2_path value in config options like this, change corresponding version.

{
  'SuperBo/fugit2.nvim',
  opts = {
    libgit2_path = 'libgit2.so.1.7',
  },
  ...
}

Mac OS

brew install libgit2

Set libgit2_path value in config options like this if you have problem loading libgit2 library with default settings.

Mac Arm M1/M2/M3

{
  'SuperBo/fugit2.nvim',
  opts = {
    libgit2_path = '/opt/homebrew/lib/libgit2.dylib',
  },
}

Mac Intel

{
  'SuperBo/fugit2.nvim',
  opts = {
    libgit2_path = '/usr/local/opt/libgit2/lib/libgit2.dylib',
  },
}

Windows

choco install libgit2

GPGme

How to install gpgme

If you do config enabling git gpg signing, you must install GPGme lib for fugit2 to work.

In addition, you should config gpg-agent to use a GUI Pinentry, so that it don't disrupt terminal when asking passphrase.

Mac OS

brew install gpgme pinentry-mac
echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf

Ubuntu/Debian

sudo apt-get install libgpgme-dev

Arch Linux

sudo pacman -S gpgme

Neovim

LuaRocks

Rocks.nvim

:Rocks install fugit2.nvim

Lazy

If you are using lazy, you can use this config

{
  'SuperBo/fugit2.nvim',
  opts = {
    width = 70,
  },
  dependencies = {
    'MunifTanjim/nui.nvim',
    'nvim-tree/nvim-web-devicons',
    'nvim-lua/plenary.nvim',
    {
      'chrisgrieser/nvim-tinygit', -- optional: for Github PR view
      dependencies = { 'stevearc/dressing.nvim' }
    },
  },
  cmd = { 'Fugit2', 'Fugit2Graph' },
  keys = {
    { '<leader>F', mode = 'n', '<cmd>Fugit2<cr>' }
  }
},
{
  -- optional: for diffview.nvim integration
  'sindrets/diffview.nvim',
  dependencies = { 'nvim-tree/nvim-web-devicons' },
  -- lazy, only load diffview by these commands
  cmd = {
    'DiffviewFileHistory', 'DiffviewOpen', 'DiffviewToggleFiles', 'DiffviewFocusFiles', 'DiffviewRefresh'
  }
}

Default options dictionary

---@class Fugit2Config
---@field width integer|string Main popup width
---@field max_width integer|string Main popup popup width when expand patch view
---@field min_width integer File view width when expand patch view
---@field content_width File view content width
---@field height integer|string Main popup height
local opts = {
  width = 100,
  min_width = 50,
  content_width = 60,
  max_width = "80%",
  height = "60%",
}

pckr.nvim

TODO: add later

Keyboard and Usage

Main Git Status View

Trigger this view by ":Fugit2" command or by any shortcut that you assigned to.

Hot keys and usages:

  • Enter: Open current file for editting.
  • Space: Toggle staged/unstaged of current entry.
  • -: Toggle staged/unstaged of current entry.
  • s: Stage current entry.
  • u: Unstage current entry.
  • =: Toggle patch view of current entry.
  • x: Discard current entry.
  • D: Discard current entry.
  • j: Move cursor to next entry.
  • k: Move cursor to previous entry.
  • l: Move cursor to patch view if visible.
  • q: Quit view.
  • Esc: Quite view.
  • c: Open Commit menu.
  • b: Open Branch menu.
  • d: Open Diffing menu.
  • f: Open Fetching menu.
  • p: Open Pull menu.
  • P: Open Push menu.
  • N: Open Github integration menu.

Commit Message Pane

Fugit2 Commit Input

Input your commit message.

Hot keys and usages:

  • Esc: Quit current commit action.
  • q: Quit current commit action.
  • Enter: Finish commit message and complete current commit action.
  • Ctrl-c: Quit current commit action while in insert mode.
  • Ctrl-Enter: Finish commit message and complete current commit action while in insert mode.

Git Status Patch Pane

Fugit2 Diff View

Trigger Patch view by pressing "=" in main status view, then use "h", "l" to navigate between them.

Hot keys and usages:

  • =: Toggle Patch pane view.
  • l: Move cursor to right pane.
  • h: Move cursor to left pane.
  • s: Stage hunk or visual selection.
  • u: Unstage hunk or visual selection.
  • -: Stage if you are in Unstaged pane, Unstage if you are in Staged pane.
  • zc: Fold current hunk.
  • zo: Unfold current folded hunk.
  • J: Move to next hunk.
  • K: Move to previous hunk.

Git Graph View

Keys and usages:

  • k, j: move up and down.
  • yy: copy commit id.
  • yc: copy commit id to clipboard.

Credits