Skip to content

📦 Installation

SuperBo edited this page Jul 4, 2024 · 9 revisions

Third party libraries:

  • Required: libgit2
  • Optional (if use gpg signing with gpg key): GPGme

Neovim

LuaRocks

Rocks.nvim

Make sure you have rocks.nvim >= 2.34.0.

:Rocks install fugit2.nvim

The setup function must be called before using this plugin, you can achieve in either way

-- somewhere in your config after Rocks.nvim setup

require('fugit2').setup({
  -- options dictionary
})

or

# rocks.toml with rocks-config.nvim installed
[plugins."fugit2.nvim".config]
width = 100
libgit2_path = "libgit2"

If you have error with GIT2_DIR or GIT2_LIB while installing, please refer to Install-libgit2.

For config details, please refer to Plugin-setup. This plugin is lazy by default, you don't need rocks-lazy.nvim :D.

Lazy

If you are using lazy, you can use this config

{
  'SuperBo/fugit2.nvim',
  opts = {
    width = 100,
  },
  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', 'Fugit2Diff', 'Fugit2Graph' },
  keys = {
    { '<leader>F', mode = 'n', '<cmd>Fugit2<cr>' }
  }
},

In case you want to use more stable diffview.nvim for diff split view.

{
  'SuperBo/fugit2.nvim',
  opts = {
    width = 70,
    external_diffview = true, -- tell fugit2 to use diffview.nvim instead of builtin implementation.
  },
  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', 'Fugit2Diff', 'Fugit2Graph' },
  keys = {
    { '<leader>F', mode = 'n', '<cmd>Fugit2<cr>' }
  }
},
{
  'sindrets/diffview.nvim',
  dependencies = { 'nvim-tree/nvim-web-devicons' },
  -- lazy, only load diffview by these commands
  cmd = {
    'DiffviewFileHistory', 'DiffviewOpen', 'DiffviewToggleFiles', 'DiffviewFocusFiles', 'DiffviewRefresh'
  }
}

pckr.nvim

TODO: add later

Plugin Setup

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
---@field libgit2_path string? path to libgit2 lib, default: "libgit2"
---@field gpgme_path string? path to gpgme lib, default: "gpgme"
---@field external_diffview boolean whether to use external diffview.nvim or Fugit2 implementation
---@field blame_priority integer priority of blame virtual text
---@field blame_info_width integer width of blame hunk detail popup
---@field blame_info_height integer height of blame hunk detail popup
---@field colorscheme string? custom color scheme override
local opts = {
  width = 100,
  min_width = 50,
  content_width = 60,
  max_width = "80%",
  height = "60%",
  external_diffview = false,
  blame_priority = 1,
  blame_info_height = 10,
  blame_info_width = 60,
}