A plugin that allows using lazygit inside Neovim and avoids nested instances.
- Neovim 0.8 (for Neovim 0.7 see 0.7-compat branch)
- python 3 and neovim-remote
Any package manager is fine.
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
Default setup
values:
{
width = 0.9,
height = 0.9,
border = 'none',
hide_map = '<c-q>'
}
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.
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
nvim-lazygit
defines the following highlight groups with their defaults:
LazyGitNormal
- linked toNormalFloat
, defines fore- and background of the lazygit window.LazyGitBorder
- linked toFloatBorder
, defines fore- and background of the lazygit window border.
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.
Heavily inspired by lazygit.nvim.