nyngwang / NeoTerm.lua

You can attach a terminal-buffer for each buffer.
MIT License
69 stars 4 forks source link

Should preserve window-layout when closing non-floating terminal buffer window. #23

Closed nyngwang closed 1 year ago

nyngwang commented 1 year ago

Migrated from: https://github.com/nyngwang/NeoZoom.lua/issues/78, since the title has nothing to do with it after the breaking change.

current progress ```lua vim.api.nvim_create_autocmd({ 'TermOpen' }, { group = curfile_augroup, callback = function () local buf_term = vim.api.nvim_get_current_buf() local buf_enter = vim.fn.bufnr('#') vim.api.nvim_set_current_buf(buf_enter) local view_enter = vim.fn.winsaveview() vim.api.nvim_set_current_buf(buf_term) vim.api.nvim_create_autocmd({ 'WinClosed' }, { buffer = buf_term, group = curfile_augroup, callback = function (args) if -- it's another buffer/win being closed. vim.api.nvim_get_current_buf() ~= args.buf or vim.api.nvim_win_get_config(0).relative ~= '' then return end vim.cmd('split') if vim.api.nvim_buf_is_valid(buf_enter) then vim.api.nvim_set_current_buf(buf_enter) vim.fn.winrestview(view_enter) else vim.api.nvim_set_current_buf(vim.api.nvim_create_buf(true, false)) end end, }) end, }) ```
nyngwang commented 1 year ago

Can remove the hotfix autocmd in 5e33b29 as long as the upstream issue https://github.com/neovim/neovim/issues/5176 would be resolved by someone. To remove it, simply comment out the following line:

https://github.com/nyngwang/NeoTerm.lua/blob/4faf0994cd8339a16c665bfac4c68d8b2bf3f36c/lua/neo-term/utils/autocmd.lua#L86

nyngwang commented 1 year ago

Note: this is pinned because it should be resolved upstream.