-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c830e4c
commit d4a86d5
Showing
3 changed files
with
38 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
local bo = vim.bo | ||
local cmd = vim.cmd | ||
local api = vim.api | ||
|
||
local M = {} | ||
|
||
function M.bufdelete() | ||
if bo.modified then | ||
cmd("write") | ||
end | ||
|
||
local bufnr = api.nvim_get_current_buf() | ||
|
||
-- TODO: Get list of valid buffers | ||
local buffers = vim.tbl_filter(function(buf) | ||
return bo[buf].buflisted and api.nvim_buf_is_valid(buf) | ||
end, api.nvim_list_bufs()) | ||
|
||
if #buffers == 1 then | ||
-- TODO: Hide scrollview before close buffer | ||
cmd("silent! ScrollViewDisable | bd " .. bufnr .. " | silent! ScrollViewEnable") | ||
|
||
-- TODO: Show Dashboard when closing the last buffer | ||
require("dashboard").instance(true) | ||
else | ||
if bufnr ~= buffers[#buffers] then | ||
cmd("bnext") | ||
else | ||
cmd("bprevious") | ||
end | ||
|
||
-- TODO: Hide scrollview before close buffer | ||
cmd("silent! ScrollViewDisable | bd " .. bufnr .. " | silent! ScrollViewEnable") | ||
end | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters