vim.keymap.set('n', 'nt', ':NERDTreeToggle') vim.cmd[[ " Close the tab if NERDTree is the only window remaining in it. autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif ]]