Skip to content

lostl1ght/nvim-lazygit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nvim-lazygit

A plugin that allows using lazygit inside Neovim and avoids nested instances.

Table of contents

Requirements

Installation

Any package manager is fine.

packer.nvim:

use({
  'lostl1ght/nvim-lazygit',
  config = function()
    require('lazygit').setup({
      -- configuration or leave empty for defaults
    })
  end,
  tag = '*',
  cmd = 'Lazygit'
})

Until Neovim releases --remote-wait and +<cmd> neovim-remote must be installed too.

pip install neovim-remote

Configuration

Default setup values:

{
  width = 0.9,
  height = 0.9,
  border = 'none',
  hide_map = '<c-q>'
}

Values

width and height are technically any in [0;1] but should not be too small.

border is one of {'none', 'single', 'double', 'rounded', 'solid', 'shadow'} or see :h nvim_open_win() for custom definitions.

hide_map should me something using ctrl or alt modifiers so that the window is not getting hidden whenever typing a commit text or nil to disable.

External

To avoid nested Neovim instances set up the following variables:

bash/zsh:

if [[ -n "$NVIM" ]]; then
  alias nvim="nvim --server $NVIM --remote"
  export EDITOR="nvim --server $NVIM --remote"
  export GIT_EDITOR="nvr --servername $NVIM --remote-wait +'lua require\"lazygit\".git_editor()'"
else
  export EDITOR="nvim"
  export GIT_EDITOR="nvim"
fi

fish:

if set -q NVIM
  alias nvim "nvim --server $NVIM --remote"
  set -gx EDITOR "nvim --server $NVIM --remote"
  set -gx GIT_EDITOR "nvr --servername $NVIM --remote-wait +'lua require\"lazygit\".git_editor()'"
else
  set -gx EDITOR "nvim"
  set -gx GIT_EDITOR "nvim"
end

And update lazygit configuration:

os:
  editCommandTemplate: >-
    if [[ -n $NVIM ]]; then
      nvr --servername $NVIM --remote +'lua require"lazygit".edit_file{{filename}}'
    else
      nvim {{filename}}
    fi
promptToReturnFromSubprocess: false

Highlight

nvim-lazygit defines the following highlight groups with their defaults:

  • LazyGitNormal - linked to NormalFloat, defines fore- and background of the lazygit window.
  • LazyGitBorder - linked to FloatBorder, defines fore- and background of the lazygit window border.

Usage

Open lazygit inside cwd:

:Lazigit

Inside lazygit press edit (e by default) to open a file in current Neovim instance.

Inside lazygit press commitChangesWithEditor (C by default) to open a gitcommit buffer in current Neovim instance, write commit message, save the buffer then unload this buffer (:bd[elete]) to return to lazygit.

Acknowledgement

Heavily inspired by lazygit.nvim.

About

Lazygit inside Neovim

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages