A lazygit integration into Neovim.
- Requirements
- Installation
- Usage
- Preventing nesting
- Plugin Configuration
- Lazygit Configuration
- Default Mappings
- neovim 0.10
- lazygit 0.38
- flatten.nvim (optional)
- nvim-unception (optional)
With lazy.nvim:
return {
'lostl1ght/lazygit.nvim',
lazy = true,
cmd = 'Lazygit',
keys = { { '<leader>g', '<cmd>Lazygit<cr>', desc = 'Lazygit' } },
}
---@param path string?
---@param use_last boolean?
require('lazygit').open(path?, use_last?)
:Lazygit[!] {path} Open lazygit on {path}. Bang toggles "use_last".
With flatten.nvim:
require('flatten').setup({
window = { open = 'smart' },
callbacks = {
pre_open = vim.schedule_wrap(function() require('lazygit').hide() end),
block_end = vim.schedule_wrap(function() require('lazygit').show() end),
},
})
With nvim-unception:
vim.env['GIT_EDITOR'] = [[nvim --cmd 'let g:unception_block_while_host_edits=1']]
vim.api.nvim_create_autocmd('User', {
pattern = 'UnceptionEditRequestReceived',
callback = function() require('lazygit').hide() end,
})
Configure the plugin by calling require('lazygit').setup()
.
Default setup
values:
{
winscale = 0.85,
mappings = {
t = {
['q'] = 'hide', -- matches 'quit' lazygit mapping
},
n = {
['q'] = 'hide', -- matches 'quit' lazygit mapping
},
},
}
Set mapping's action to false to disable.
An action can be a function. This function accepts 1 argument which is a buffer number.
function(bufnr)
print('Lazygit bufnr is' .. bufnr)
end
os:
editPreset: 'nvim-remote'
promptToReturnFromSubprocess: false
Mappings | Action | Configuration option |
---|---|---|
<c-q> |
Hide Lazygit window | hide |