Closed tnhh00037 closed 4 years ago
Thanks for using the plugin! I'm able to use ESC
to in lazygit in neovim though, and it exits lazygit as expected. Do you have a tnoremap
somewhere in your init.vim
that maps escape to return to normal mode?
For what it is worth, I have something like the following in my init.vim
:
function s:AddTerminalNavigation()
echom &filetype
if &filetype ==# ''
tnoremap <buffer> <silent> <c-h> <c-\><c-n>:TmuxNavigateLeft<cr>
tnoremap <buffer> <silent> <c-j> <c-\><c-n>:TmuxNavigateDown<cr>
tnoremap <buffer> <silent> <c-k> <c-\><c-n>:TmuxNavigateUp<cr>
tnoremap <buffer> <silent> <c-l> <c-\><c-n>:TmuxNavigateRight<cr>
endif
endfunction
augroup TerminalNavigation
autocmd!
autocmd TermEnter * call s:AddTerminalNavigation()
augroup END
This adds the above keybindings to a terminal buffer when you open it, if the filetype is an empty string. Most vim plugin terminal buffers that do something specific set the name of the terminal buffer to be the name of the terminal application itself. lazygit.vim
does this as well. So this won't interfere with with any similar keybindings by lazygit.
You can also add the following to the if
block
tnoremap <Esc> <C-\><C-n>
tnoremap <C-v><Esc> <Esc>
I go back and forth on whether I want to use <Esc>
in a normal terminal.
Feel free to reopen in case if you have any questions regarding this.
@kdheepak using your suggestion makes my neovim ESC and TmuxNavigation keybinds not work when using toggleterm terminal, do you have a workaround for this? Sorry, im a noob. I understood that you have set the keybinds for terminals that don't have a filetype, but in the case of toggleterm it is the same as lazygit.
Hmm, why wouldn't it work? Using <C-\><C-n>
in the terminal in neovim will go from insert to normal mode. Can you try it in a native neovim terminal? If it is a toggleterm issue, can you ask on the toggleterm repo?
@kdheepak what is the easiest way to close LazyGit window? only Esc not working.
Currently, I'm using Esc + :q
Just hitting q
works for me. Does that work for you?
Awesome, thanks! maybe you could add it to Menu
, cuz this option is not obvious)
Hmm I have the opposite problem, hitting escape closes lazygit so how do you go "back"? Like when you are in the commits?
Hmm I have the opposite problem, hitting escape closes lazygit so how do you go "back"? Like when you are in the commits?
Have you managed to do something for this? @amritk I'm having the same problem and it is bugging me :rofl:
Yea I just deleted the keymap for escape in the terminal. The downside is I can't hit escape to close them anymore but oh well 🤷
I ended up doing this FWIW: https://github.com/SimonBrandner/dotfiles/commit/a29de2c408d6157760bbfe815a8b49bcb7f8f230
I'm using 0.4.3 branch .
Currently, Lazygit has key to exit/return inside itself.
But if I use it inside neovim, seems that key will switch neovim to mode, not returning for Lazygit.
Is there any solution? Thanks for your work!!