Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug exiting lazyGit #78

Open
paulhmurray opened this issue Oct 20, 2022 · 9 comments
Open

Bug exiting lazyGit #78

paulhmurray opened this issue Oct 20, 2022 · 9 comments
Labels
bug Something isn't working

Comments

@paulhmurray
Copy link

Describe the bug
Loading LazyGit with NeoVim plugin there is conflict when using Esc and then trying to exit LazyGit with 'q' command for quit

To Reproduce
Steps to reproduce the behavior:

Load LazyGit
Press Esc
Then try and leave LazyGit by pressing 'q' for quit won't work
Only way to exit is to use Vim's ":q"
Expected behavior
That exiting the floating LazyGit screen will work regardless of pressing the 'esc' button

Screenshots
Not much need for a screenshot, as the floating LazyGit window just hangs until I select ":q" for vim exit

Version info:
LazyGit Version 0.34
Git version 2.34.1

@paulhmurray paulhmurray added the bug Something isn't working label Oct 20, 2022
@huyz
Copy link

huyz commented Oct 29, 2022

I'm not sure if my issue is related or not, but I can't exit out of LazyGit anymore. Whether I hit q, <Esc>, or Ctrl+C, it just gives a blank screen and I have to :q to exit.
I do see an error at the bottom that says:

^I...uyz/git/+huyz/dot-vim/plugged/lazygit.nvim/lua/lazygit.lua:28: in function <...uyz/git/+huyz/dot-vim/plugged/lazygit.nvim/lua/lazygit.lua:17>

It seems there's some sort of exception at

vim.api.nvim_set_current_win(prev_win)

@paulhmurray do you see the same error?

@thefux
Copy link
Contributor

thefux commented Nov 1, 2022

can't reproduce on my side, maybe clashes with some configuration or mapping from other plugin !?

@huyz
Copy link

huyz commented Nov 2, 2022

I was able to resolve the error. I use a TermClose autocmd, as suggested in the neovim docs, but that sample code interferes with lazygit's exit.

This works though:

    " NOTE: added lazygit check to avoid lua error
    " NOTE: added "silent!" to avoid error when FZF terminal window is closed.
    autocmd TermClose * if &filetype != 'lazygit' && !v:event.status | silent! exe 'bdelete! '..expand('<abuf>') | endif

@gcleroux
Copy link

gcleroux commented Nov 4, 2022

I was able to reproduce the bug with ToggleTerm installed. Like @thefux said, it might be a conflict somewhere in the configs.

@drewxs
Copy link

drewxs commented Feb 5, 2023

See if you have the following keymap set somewhere (i.e. your toggleterm setup file).
Either remove it or rebind it to something else.

vim.keymap.set("t", "<esc>", [[<C-\><C-n>]], opts)

from: https://github.com/akinsho/toggleterm.nvim#terminal-window-mappings

@eddyekofo94
Copy link

The bug is still not fixed?

@kdheepak
Copy link
Owner

kdheepak commented Dec 8, 2023

Are you able to reproduce this bug with a minimal neovim setup? For example with a file like this:

" If after installing lazygit.vim, you are having trouble getting it to work, try the following minimal vimrc file.
set nocompatible " be iMproved, required
filetype off " required
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.local/share/nvim/plugged')
Plug '~/gitrepos/lazygit.nvim'
" Initialize plugin system
call plug#end()
let mapleader = " "
nnoremap <silent> <leader>lg :LazyGit<CR>
" Save the above to a file `MINRC`, and run `nvim -u MINRC` and type `<leader>lg` in normal mode.

I don't believe this is a bug in lazygit.nvim per say, just a configuration collision. In neovim's terminal mode, hitting esc may or may not change the terminal mode to normal mode, depending on your configuration. See comments above for the conflicting configuration.

@carmen-gh
Copy link

carmen-gh commented Apr 4, 2024

I don't have any other Terminal Plugin like toggleTerm. But with following keymapping the plugin is not usable. After disabling this mapping it works
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })

also mapping like this is causing problems. So rebinding it does not help.

vim.keymap.set("t", "jj", "<C-\\><C-n>", { desc = "Exit terminal mode" })

Is there a way to enable these mappings for non lazygit terminals or disable them for lazygit terminal windows?

@kdheepak
Copy link
Owner

kdheepak commented Apr 4, 2024

When lazygit.nvim opens a terminal it sets the buffer name to lazygit. You can use an autocmd to check for the buffer name on BufOpen and set whatever bindings you want conditionally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants