• Stars
    star
    1,317
  • Rank 35,479 (Top 0.8 %)
  • Language
    Lua
  • License
    MIT License
  • Created over 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Plugin for calling lazygit from within neovim.

lazygit.nvim

Plugin for calling lazygit from within neovim.

See akinsho/nvim-toggleterm or voldikss/vim-floaterm as an alternative to this package.

Install

Install using vim-plug:

" nvim v0.7.2
Plug 'kdheepak/lazygit.nvim'

Install using packer.nvim:

-- nvim v0.7.2
use({
    "kdheepak/lazygit.nvim",
    -- optional for floating window border decoration
    requires = {
        "nvim-lua/plenary.nvim",
    },
})

Install using lazy.nvim:

-- nvim v0.8.0
require("lazy").setup({
    {
        "kdheepak/lazygit.nvim",
        -- optional for floating window border decoration
        dependencies = {
            "nvim-lua/plenary.nvim",
        },
    },
})

Feel free to use any plugin manager. Just remember that if you are not using the latest neovim release, you will need to use the nvim-v0.4.3 branch. Integration with nvr works better on the main branch.

You can check what version of neovim you have:

nvim --version

Usage

The following are configuration options and their defaults.

let g:lazygit_floating_window_winblend = 0 " transparency of floating window
let g:lazygit_floating_window_scaling_factor = 0.9 " scaling factor for floating window
let g:lazygit_floating_window_border_chars = ['โ•ญ','โ”€', 'โ•ฎ', 'โ”‚', 'โ•ฏ','โ”€', 'โ•ฐ', 'โ”‚'] " customize lazygit popup window border characters
let g:lazygit_floating_window_use_plenary = 0 " use plenary.nvim to manage floating window if available
let g:lazygit_use_neovim_remote = 1 " fallback to 0 if neovim-remote is not installed

let g:lazygit_use_custom_config_file_path = 0 " config file path is evaluated if this value is 1
let g:lazygit_config_file_path = '' " custom config file path
vim.g.lazygit_floating_window_winblend = 0 -- transparency of floating window
vim.g.lazygit_floating_window_scaling_factor = 0.9 -- scaling factor for floating window
vim.g.lazygit_floating_window_border_chars = ['โ•ญ','โ”€', 'โ•ฎ', 'โ”‚', 'โ•ฏ','โ”€', 'โ•ฐ', 'โ”‚'] -- customize lazygit popup window border characters
vim.g.lazygit_floating_window_use_plenary = 0 -- use plenary.nvim to manage floating window if available
vim.g.lazygit_use_neovim_remote = 1 -- fallback to 0 if neovim-remote is not installed

vim.g.lazygit_use_custom_config_file_path = 0 -- config file path is evaluated if this value is 1
vim.g.lazygit_config_file_path = '' -- custom config file path

Call :LazyGit to start a floating window with lazygit in the current working directory. And set up a mapping to call :LazyGit:

" setup mapping to call :LazyGit
nnoremap <silent> <leader>gg :LazyGit<CR>

Call :LazyGitCurrentFile to start a floating window with lazygit in the project root of the current file.

Open the configuration file for lazygit directly from vim.

:LazyGitConfig<CR>

If the file does not exist it'll load the defaults for you.

Open project commits with lazygit directly from vim in floating window.

:LazyGitFilter<CR>

Open buffer commits with lazygit directly from vim in floating window.

:LazyGitFilterCurrentFile<CR>

Using neovim-remote

If you have neovim-remote and have configured to use it in neovim, it'll launch the commit editor inside your neovim instance when you use C inside lazygit.

  1. pip install neovim-remote

  2. Add the following to your ~/.bashrc:

if [ -n "$NVIM_LISTEN_ADDRESS" ]; then
    alias nvim=nvr -cc split --remote-wait +'set bufhidden=wipe'
fi
  1. Set EDITOR environment variable in ~/.bashrc:
if [ -n "$NVIM_LISTEN_ADDRESS" ]; then
    export VISUAL="nvr -cc split --remote-wait +'set bufhidden=wipe'"
    export EDITOR="nvr -cc split --remote-wait +'set bufhidden=wipe'"
else
    export VISUAL="nvim"
    export EDITOR="nvim"
fi
  1. Add the following to ~/.vimrc:
if has('nvim') && executable('nvr')
  let $GIT_EDITOR = "nvr -cc split --remote-wait +'set bufhidden=wipe'"
endif

If you have neovim-remote and don't want lazygit.nvim to use it, you can disable it using the following configuration option:

let g:lazygit_use_neovim_remote = 0

Using nvim --listen and nvim --server to edit files in same process

You can use vanilla nvim server to edit files in the same nvim instance when you use e inside lazygit.

  1. You have to start nvim with the --listen parameter. An easy way to ensure this is to use an alias:
# ~/.bashrc
alias vim='nvim --listen /tmp/nvim-server.pipe'
  1. You have to modify lazygit to attempt connecting to existing nvim instance on edit:
# ~/.config/jesseduffield/lazygit/config.yml
os:
  editCommand: 'nvim'
  editCommandTemplate: '{{editor}} --server /tmp/nvim-server.pipe --remote-tab "$(pwd)/{{filename}}"'

Telescope Plugin

The Telescope plugin is used to track all git repository visited in one nvim session.

lazygittelplugin (background image is not included ๐Ÿ˜)

Why a telescope Plugin ?

Assuming you have one or more submodule(s) in your project and you want to commit changes in both the submodule(s) and the main repo. Though switching between submodules and main repo is not straight forward. A solution at first could be:

  1. open a file inside the submodule
  2. open lazygit
  3. do commit
  4. then open a file in the main repo
  5. open lazygit
  6. do commit

That is really annoying. Instead, you can open it with telescope.

How to use

Install using packer.nvim:

-- nvim v0.7.2
use({
    "kdheepak/lazygit.nvim",
    requires = {
        "nvim-telescope/telescope.nvim",
        "nvim-lua/plenary.nvim",
    },
    config = function()
        require("telescope").load_extension("lazygit")
    end,
})

Install using lazy.nvim:

-- nvim v0.8.0
require("lazy").setup({
    {
        "kdheepak/lazygit.nvim",
        dependencies =  {
            "nvim-telescope/telescope.nvim",
            "nvim-lua/plenary.nvim"
        },
        config = function()
            require("telescope").load_extension("lazygit")
        end,
    },
})

Lazy loading lazygit.nvim for telescope functionality is not supported. Open an issue if you wish to have this feature.

If you are not using Packer, to load the telescope extension, you have to add this line to your configuration:

require('telescope').load_extension('lazygit')

By default the paths of each repo is stored only when lazygit is triggered. Though, this may not be convenient, so it possible to do something like this:

autocmd BufEnter * :lua require('lazygit.utils').project_root_dir()

That makes sure that any opened buffer which is contained in a git repo will be tracked.

Once you have loaded the extension, you can invoke the plugin using:

lua require("telescope").extensions.lazygit.lazygit()

Highlighting groups

Highlight Group Default Group Description
LazyGitFloat Normal Float terminal foreground and background
LazyGitBorder Normal Float terminal border

More Repositories

1

taskwarrior-tui

`taskwarrior-tui`: A terminal user interface for taskwarrior
Rust
1,398
star
2

panvimdoc

Write documentation in pandoc markdown. Generate documentation in vimdoc.
CSS
242
star
3

tabline.nvim

A "buffer and tab" tabline for neovim
Lua
232
star
4

cmp-latex-symbols

Add latex symbol support for nvim-cmp.
Lua
125
star
5

TerminalUserInterfaces.jl

Terminal User Interfaces in Julia.
Julia
93
star
6

monochrome.nvim

A monochrome colorscheme for neovim
Lua
88
star
7

JuliaFormatter.vim

A (N)Vim plugin for formatting Julia code using JuliaFormatter.jl.
Vim Script
70
star
8

Presentation.jl

Julia
41
star
9

c3.py

Commit Counter Chart is a Python Flask app to view git history using D3.js
HTML
39
star
10

FIGlet.jl

Julia
26
star
11

awesome-advent-of-code

19
star
12

dotfiles

Shell
16
star
13

ReverseStackTraces.jl

Display stack traces in reverse order
Julia
13
star
14

github-release

github-release is a command line utility tool that allows you to easily manage your releases on GitHub.
Nim
13
star
15

nvim-dap-julia

Lua
13
star
16

moonshine.nvim

Rust
12
star
17

keystrokes.nvim

Show keystrokes in neovim.
Lua
11
star
18

PyomoGettingStarted

IPython notebooks that illustrate the Pyomo optimization modeling software
Python
10
star
19

JET.nvim

Julia
10
star
20

pandoc-ieee-template

TeX
9
star
21

psst

Python
9
star
22

pelican-smoothie

Pelican-Smoothie - A Bootstrap theme for the static site generator Pelican
CSS
8
star
23

think-git

A intermediate git tutorial
HTML
7
star
24

PySyntax.jl

(*deprecated*) PySyntax.jl allows Python-like syntax in Julia. Py.jl provides a light wrapper on top of PyCall.jl in the form of a macro.
Jupyter Notebook
6
star
25

TERMIOS.jl

This Julia package provides an TERMIOS interface to the POSIX calls for tty I/O control.
Julia
6
star
26

Pandoc.jl

Pandoc Interface and Types in Julia
Julia
5
star
27

Notcurses.jl

Julia
5
star
28

blog

My personal thoughts and notes
TeX
4
star
29

sveltekit-shiki-endpoint-error

JavaScript
4
star
30

tasker_sl4a

Python Code that parses public Google Calendar feed for events and event location
Python
4
star
31

juliacon2020-terminal-user-interfaces-in-julia

Julia
3
star
32

quarto-svgbob

Render svgbob diagrams directly in your quarto documents.
Lua
3
star
33

mpld3_plugins

Python
3
star
34

ts-julia-actions

Lua
3
star
35

libcrossterm

libcrossterm is a Rust cdylib library providing a C-API to access the excellent crossterm crate.
Rust
3
star
36

pandoc-paper

CSS
3
star
37

Crossterm.jl

Julia
2
star
38

fono

Find number of optimal order from websites considering shipping costs
Python
2
star
39

jupyter-notebook

HTML
2
star
40

kdheepak.github.io

TeX
2
star
41

GeekToolBash

A bash script to download random Calvin and Hobbes comic strips from gocomics.com/calvinandhobbes/
Shell
2
star
42

juliacon2019-open-source-power-system-production-cost-modeling-in-julia

Jupyter Notebook
2
star
43

Tasker_WhatsPush

Forward Whatsapp Messages to and Reply from Desktop
1
star
44

pandasplexos

Python
1
star
45

mwe-swig-python3-anaconda

C
1
star
46

game-of-life

Rust
1
star
47

juliacon2019-why-writing-c-interfaces-in-julia-is-so-easy-asterisk

Julia
1
star
48

adventofcode

Julia
1
star
49

iou

Solve for the optimally minimum number of transactions to settle debts and expenses with friends
Python
1
star
50

pandoc-ipynb

HTML
1
star
51

opendss-mirror

Pascal
1
star
52

interactive-data-visualizations-with-bokeh

Interactive Data Visualizations with Bokeh
JavaScript
1
star
53

license

`license` is a command line utility tool that allows you to easily add licenses to your open source projects
Nim
1
star
54

mergetool.nvim

1
star
55

d2-markdown-preview

d2 vscode markdown preview extension
TypeScript
1
star
56

nvim

Lua
1
star
57

remark-svgbob

Convert markdown codeblock with ascii diagram to svg using svgbob wasm
JavaScript
1
star