diff options
Diffstat (limited to 'lua/functions.lua')
-rw-r--r-- | lua/functions.lua | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lua/functions.lua b/lua/functions.lua index da238e4..6ec4658 100644 --- a/lua/functions.lua +++ b/lua/functions.lua @@ -20,6 +20,12 @@ local function set_terminal_height(height) vim.api.nvim_win_set_height(vim.g.term_win, height) end +local function get_nerdtree_win_id() + local nerdtree_win_num = vim.api.nvim_eval("g:NERDTree.GetWinNum()") + + return vim.fn.win_getid(nerdtree_win_num) +end + function _G.check_back_space() local col = vim.api.nvim_win_get_cursor(0)[2] @@ -61,9 +67,7 @@ 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 - local nerdtree_win_num = vim.api.nvim_eval("g:NERDTree.GetWinNum()") - - local nerdtree_win_id = vim.fn.win_getid(nerdtree_win_num) + local nerdtree_win_id = get_nerdtree_win_id() vim.api.nvim_win_call( nerdtree_win_id, @@ -96,6 +100,12 @@ function _G.remove_hidden_windowless_buffers() end function _G.close_current_buffer() + local curr_win_id = vim.fn.win_getid() + + if curr_win_id == vim.g.term_win or curr_win_id == get_nerdtree_win_id() then + return + end + local current_buf_nr = vim.fn.bufnr() local all_buffers = vim.fn.getbufinfo() |