diff options
author | HampusM <hampus@hampusmat.com> | 2024-05-30 22:14:53 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-05-30 22:14:53 +0200 |
commit | 9baf707465de96c28a5f3da8ce24dd71a9c586cc (patch) | |
tree | 2adc7c241365973b603bfa46af06e2350e47b0cd | |
parent | a6123a6dd5ee3f7e63077cf72a40a1085cebada1 (diff) |
make NERDTree resizingf & moving more robust
-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 |