@@ -188,25 +188,29 @@ end
188
188
--- @param force ? boolean Whether or not to foce close the buffers or confirm changes (default : false )
189
189
function M .close (bufnr , force )
190
190
if not bufnr or bufnr == 0 then bufnr = vim .api .nvim_get_current_buf () end
191
- if astro .is_available " mini.bufremove" and M .is_valid (bufnr ) and # vim .t .bufs > 1 then
192
- mini_confirm (require (" mini.bufremove" ).delete , bufnr , force )
193
- else
194
- local buftype = vim .bo [bufnr ].buftype
195
- vim .cmd ((" silent! %s %d" ):format ((force or buftype == " terminal" ) and " bdelete!" or " confirm bdelete" , bufnr ))
191
+ if M .is_valid (bufnr ) and # vim .t .bufs > 1 then
192
+ if astro .is_available " snacks.nvim" then return require (" snacks" ).bufdelete { buf = bufnr , force = force } end
193
+ if astro .is_available " mini.bufremove" then return mini_confirm (require (" mini.bufremove" ).delete , bufnr , force ) end
196
194
end
195
+ -- fallback
196
+ local buftype = vim .bo [bufnr ].buftype
197
+ vim .cmd ((" silent! %s %d" ):format ((force or buftype == " terminal" ) and " bdelete!" or " confirm bdelete" , bufnr ))
197
198
end
198
199
199
200
--- Fully wipeout a given buffer
200
201
--- @param bufnr ? integer The buffer to wipe or the current buffer if not provided
201
202
--- @param force ? boolean Whether or not to foce close the buffers or confirm changes (default : false )
202
203
function M .wipe (bufnr , force )
203
204
if not bufnr or bufnr == 0 then bufnr = vim .api .nvim_get_current_buf () end
204
- if astro . is_available " mini.bufremove " and M .is_valid (bufnr ) and # vim .t .bufs > 1 then
205
- mini_confirm ( require ( " mini.bufremove " ). wipeout , bufnr , force )
206
- else
207
- local buftype = vim . bo [ bufnr ]. buftype
208
- vim . cmd (( " silent! %s %d " ): format (( force or buftype == " terminal " ) and " bwipeout! " or " confirm bwipeout " , bufnr ))
205
+ if M .is_valid (bufnr ) and # vim .t .bufs > 1 then
206
+ if astro . is_available " snacks.nvim " then
207
+ return require ( " snacks " ). bufdelete { buf = bufnr , force = force , wipe = true }
208
+ end
209
+ if astro . is_available " mini.bufremove " then return mini_confirm ( require ( " mini.bufremove " ). wipeout , bufnr , force ) end
209
210
end
211
+ -- fallback
212
+ local buftype = vim .bo [bufnr ].buftype
213
+ vim .cmd ((" silent! %s %d" ):format ((force or buftype == " terminal" ) and " bwipeout!" or " confirm bwipeout" , bufnr ))
210
214
end
211
215
212
216
--- Close all buffers
0 commit comments