Просмотр исходного кода

nixpkgs/neovim: automatically close terminal on exit

Default nvim behavior is to keep the buffer open but closes the window
on keypress. The initial workaround was to exit insert mode so that it's
not closed automatically on keypress but we have to quit it manually.

Since we're running an autocmd for this anyway, we might as well use
bufremove to close it while preserving the window layout which is the
main motivation for this.
Thomas Dy 2 лет назад
Родитель
Сommit
7fd5eb4fd3
1 измененных файлов с 6 добавлено и 3 удалено
  1. 6 3
      .config/nixpkgs/neovim/autocmd.lua

+ 6 - 3
.config/nixpkgs/neovim/autocmd.lua

@@ -7,10 +7,13 @@ vim.api.nvim_create_autocmd('TermOpen', {
   end
 })
 
--- leave insert when terminal process exits
--- this prevents the window from closing
+-- preserve window structure when exiting terminal via C-d
 vim.api.nvim_create_autocmd('TermClose', {
-  command = 'stopinsert',
+  callback = function(opts)
+    MiniBufremove.delete(opts.buf)
+  end,
+  -- needed so statusline properly updates
+  nested = true,
 })
 
 -- automatically enter/leave terminal mode