From 829771f33fb03aa2f6f7c5ac0e8526c22ed2a044 Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Sat, 18 Jul 2020 21:50:14 -0600 Subject: [PATCH] Add g:lazygit_use_neovim_remote option and update README.md --- README.md | 49 +++++++++++++++++++++++++++++++++++++----- ftplugin/gitcommit.vim | 2 +- plugin/lazygit.vim | 4 ++++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7bc16d1..9e2a48e 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,13 @@ Plugin for calling [lazygit](https://github.com/jesseduffield/lazygit) from within neovim. -![](https://user-images.githubusercontent.com/1813121/78614672-b8beea80-785e-11ea-8fd2-835b385ed6da.gif) - -If you are not using neovim nightly, use [this branch](https://github.com/kdheepak/lazygit.vim/tree/nvim-v0.4.3). -You can install it using the following: +![](https://user-images.githubusercontent.com/1813121/87866391-79fcfe00-c93e-11ea-94a9-204947de1b39.gif) ### Install -**[`vim-plug`](https://github.com/junegunn/vim-plug)** +If you are not using neovim nightly, use [this branch](https://github.com/kdheepak/lazygit.vim/tree/nvim-v0.4.3). + +Install using **[`vim-plug`](https://github.com/junegunn/vim-plug)**: ```vim " nvim v0.4.3 @@ -44,3 +43,43 @@ Open the configuration file for `lazygit` directly from vim. If the file does not exist it'll load the defaults for you. ![](https://user-images.githubusercontent.com/1813121/78830902-46721580-79d8-11ea-8809-291b346b6c42.gif) + +**Using neovim-remote** + +If you have [neovim-remote](https://github.com/mhinz/neovim-remote) and have configured to use it in neovim, it'll launch the commit message inside your neovim instance. + +1) `pip install neovim-remote` + +2) Add the following to your `~/.bashrc`: + +```bash +if [ -n "$NVIM_LISTEN_ADDRESS" ]; then + alias nvim=nvr -cc split --remote-wait +'set bufhidden=wipe' +fi +``` + +3) Set `EDITOR` environment variable in `~/.bashrc`: + +```bash +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 +``` + +4) Add the following to `~/.vimrc`: + +```vim +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: + +```vim +let g:lazygit_use_neovim_remote = 0 +``` diff --git a/ftplugin/gitcommit.vim b/ftplugin/gitcommit.vim index aff049a..d9bb620 100644 --- a/ftplugin/gitcommit.vim +++ b/ftplugin/gitcommit.vim @@ -1,4 +1,4 @@ -if executable("nvr") +if g:lazygit_use_neovim_remote && executable("nvr") augroup GIT autocmd! autocmd WinLeave :LazyGit diff --git a/plugin/lazygit.vim b/plugin/lazygit.vim index 16d43e5..3956bba 100644 --- a/plugin/lazygit.vim +++ b/plugin/lazygit.vim @@ -15,6 +15,10 @@ if !exists('g:lazygit_floating_window_scaling_factor') let g:lazygit_floating_window_scaling_factor = 0.9 endif +if !exists('g:lazygit_use_neovim_remote') + let g:lazygit_use_neovim_remote = 1 +endif + command! LazyGit lua require'lazygit'.lazygit() command! LazyGitFilter lua require'lazygit'.lazygitfilter()