summaryrefslogtreecommitdiff
path: root/lua/autocommands/exit.lua
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-09-18 11:39:25 +0200
committerHampusM <hampus@hampusmat.com>2022-09-18 11:39:25 +0200
commit3c238894c5b6f15c5f27cea8bd3785eb0f1ebf0f (patch)
tree68292df2b0cd698484d26057a4faf914e9ea6300 /lua/autocommands/exit.lua
parentd8fa264ac732286dcf9234bc40e60eeb7e230ca7 (diff)
add config
Diffstat (limited to 'lua/autocommands/exit.lua')
-rw-r--r--lua/autocommands/exit.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/lua/autocommands/exit.lua b/lua/autocommands/exit.lua
new file mode 100644
index 0000000..8ffac46
--- /dev/null
+++ b/lua/autocommands/exit.lua
@@ -0,0 +1,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"
+)
+]]