44--- @field filetype Filetype
55
66--- @class Config
7- --- @field main { width : number } ;
8- --- @field top Integration[] ;
9- --- @field right { min_width : number ; [number] : Integration[] } ;
10- --- @field bottom Integration[] ;
11- --- @field left { min_width : number ; [number] : Integration[] } ;
7+ --- @field main ? { width ? : number } ;
8+ --- @field top ? Integration[] ;
9+ --- @field right ? { min_width ? : number ; [number] ? : Integration[] } ;
10+ --- @field bottom ? Integration[] ;
11+ --- @field left ? { min_width ? : number ; [number] ? : Integration[] } ;
1212
13- --- @type Config
13+ --- @type Config ?
1414local opts = {
1515 main = { width = 148 },
1616 top = {},
@@ -21,6 +21,7 @@ local opts = {
2121local state = {
2222 [vim .api .nvim_get_current_tabpage ()] = { left = nil , right = nil },
2323}
24+ local is_quitting = false
2425
2526local function create_window (position )
2627 if position == " left" then
@@ -223,7 +224,7 @@ local function close(filetype)
223224 end
224225end
225226
226- --- @param options Config
227+ --- @param options ? Config
227228local function setup (options )
228229 -- Default splitting will cause your main splits to jump when opening an integration.
229230 -- To prevent this, set `splitkeep` to either `screen` or `topline`.
@@ -292,15 +293,30 @@ local function setup(options)
292293 if is_popup_window (vim .api .nvim_get_current_win ()) then
293294 return
294295 end
295- if vim . tbl_count ( get_editable_files ()) == 1 and not is_buff_integration (args .buf ) then
296- close_side_buffer ( " left " )
297- close_side_buffer ( " right " )
296+ if is_buff_integration (args .buf ) then
297+ return
298+ end
298299
299- for _ , position in ipairs ({ " top" , " right" , " bottom" , " left" }) do
300- for _ , integration in pairs (opts [position ]) do
301- if type (integration ) == " table" then
302- close (integration .filetype )
303- end
300+ local editable_count = 0
301+ for _ , win in ipairs (vim .api .nvim_list_wins ()) do
302+ if not is_popup_window (win ) then
303+ local buf = vim .api .nvim_win_get_buf (win )
304+ if not is_buff_integration (buf ) then
305+ editable_count = editable_count + 1
306+ end
307+ end
308+ end
309+ if editable_count ~= 1 then
310+ return
311+ end
312+
313+ close_side_buffer (" left" )
314+ close_side_buffer (" right" )
315+
316+ for _ , position in ipairs ({ " top" , " right" , " bottom" , " left" }) do
317+ for _ , integration in pairs (opts [position ]) do
318+ if type (integration ) == " table" then
319+ close (integration .filetype )
304320 end
305321 end
306322 end
0 commit comments