summaryrefslogtreecommitdiff
path: root/lua/autocommands/exit.lua
blob: 8ffac469b0a202b21aa9e9c8965871de2784a6ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require("utility.autocmd")

-- Exit Vim if NERDTree is the only window remaining in the only tab.
--[[
autocmd(
	"BufEnter",
	"*",
	"if tabpagenr('$') == 1 && winnr('$') == 1 && " ..
		"exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif"
)
]]

-- Exit Vim if a terminal is the only window remaining in the only tab.
--[[
autocmd(
	"BufEnter",
	"*",
	"if tabpagenr('$') == 1 && winnr('$') == 1 && g:is_term_open == 1 | quit | endif"
)

-- Exit Vim if the only windows remaining is NERDTree and terminal.
autocmd(
	"BufEnter",
	"*",
	"if tabpagenr('$') == 1 && winnr('$') == 2 && g:NERDTree.IsOpen() && " ..
		"g:is_term_open == 1 | qall | endif"
)
]]

-- Close a single NERDTree tab.
--[[
autocmd(
	"BufEnter",
	"*",
	"if len(tabpagebuflist()) == 1 && bufname(tabpagebuflist()[0]) =~ \"^NERD_tree\" " ..
		"| tabclose | endif"
)
]]