aboutsummaryrefslogtreecommitdiffhomepage
path: root/.config
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-05-24 01:12:29 +0900
committernsfisis <nsfisis@gmail.com>2025-05-24 01:12:29 +0900
commit99c0519fbdc4c6be52943f2c00bfe4023d08f2d9 (patch)
treeaf7b7d5e4fe7444f6c035da6877a4d0330e751a8 /.config
parente08dd066f6c6f75ab552483623dcc9428d23f8f7 (diff)
downloaddotfiles-99c0519fbdc4c6be52943f2c00bfe4023d08f2d9.tar.gz
dotfiles-99c0519fbdc4c6be52943f2c00bfe4023d08f2d9.tar.zst
dotfiles-99c0519fbdc4c6be52943f2c00bfe4023d08f2d9.zip
nvim: :SmartOpen now closes another empty window after opening new window
Diffstat (limited to '.config')
-rw-r--r--.config/nvim/lua/init/02-commands.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/.config/nvim/lua/init/02-commands.lua b/.config/nvim/lua/init/02-commands.lua
index 96c83da..a36906f 100644
--- a/.config/nvim/lua/init/02-commands.lua
+++ b/.config/nvim/lua/init/02-commands.lua
@@ -26,6 +26,12 @@ C(
C(
'SmartOpen',
function(opts)
+ local only_one_empty_window = F.winnr('$') == 1 and
+ F.bufname() == '' and
+ not F.getbufinfo().changed and
+ F.line('$') == 1 and
+ F.getline(1) == ''
+
local modifiers
if F.winwidth(F.winnr()) < 150 then
modifiers = 'topleft'
@@ -48,6 +54,10 @@ C(
return
end
+ if only_one_empty_window then
+ vim.cmd.wincmd('o')
+ end
+
if O.filetype == 'help' then
if vim.bo.textwidth > 0 then
vim.cmd(('vertical resize %d'):format(vim.bo.textwidth))