From 99c0519fbdc4c6be52943f2c00bfe4023d08f2d9 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 24 May 2025 01:12:29 +0900 Subject: nvim: :SmartOpen now closes another empty window after opening new window --- .config/nvim/lua/init/02-commands.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to '.config/nvim/lua/init/02-commands.lua') 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)) -- cgit v1.2.3-70-g09d2