diff options
-rw-r--r-- | lua/functions.lua | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lua/functions.lua b/lua/functions.lua index 1f088a8..3c19268 100644 --- a/lua/functions.lua +++ b/lua/functions.lua @@ -63,17 +63,18 @@ function _G.toggle_terminal() vim.g.term_win = vim.fn.win_getid() if vim.fn.exists("g:NERDTree") and vim.api.nvim_eval("g:NERDTree.IsOpen()") then - vim.cmd("NERDTreeFocus") + local nerdtree_win_num = vim.api.nvim_eval("g:NERDTree.GetWinNum()") - vim.cmd("wincmd H") + local nerdtree_win_id = vim.fn.win_getid(nerdtree_win_num) - local width_diff = vim.fn.winwidth(0) - vim.g.NERDTreeWinSize + vim.api.nvim_win_call( + nerdtree_win_id, + function() + vim.cmd("wincmd H") + end + ) - vim.cmd(width_diff .. "wincmd <") - - vim.cmd("wincmd p") - - vim.fn.feedkeys("A") + vim.api.nvim_win_set_width(nerdtree_win_id, vim.g.NERDTreeWinSize) end end end |