瀏覽代碼

while using lazygit inside fterm, esc key will act as quit instead of going to normal mode (#762)

Abouzar Parvan 4 年之前
父節點
當前提交
51c0f48970
共有 2 個文件被更改,包括 15 次插入0 次删除
  1. 11 0
      lua/lv-floatterm/init.lua
  2. 4 0
      lua/lv-utils/init.lua

+ 11 - 0
lua/lv-floatterm/init.lua

@@ -40,6 +40,17 @@ M.config = function()
     end
     lazy:toggle()
   end
+
+  -- Map esc to exit inside lazygit
+  vim.api.nvim_exec([[
+  function LazyGitNativation()
+    echom &filetype
+    if &filetype ==# 'FTerm'
+      tnoremap <Esc> q
+      tnoremap <C-v><Esc> <Esc>
+    endif
+  endfunction
+  ]], false)
 end
 
 return M

+ 4 - 0
lua/lv-utils/init.lua

@@ -76,6 +76,10 @@ lv_utils.define_augroups {
     -- will cause split windows to be resized evenly if main window is resized
     { "VimResized ", "*", "wincmd =" },
   },
+  _fterm_lazygit = {
+    -- will cause esc key to exit lazy git
+    {"TermEnter", "*", "call LazyGitNativation()"}
+  },
   -- _mode_switching = {
   --   -- will switch between absolute and relative line numbers depending on mode
   --   {'InsertEnter', '*', 'if &relativenumber | let g:ms_relativenumberoff = 1 | setlocal number norelativenumber | endif'},