mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 16:39:04 +02:00
enc: lua format custem
This commit is contained in:
parent
65857a4226
commit
384c0b5768
68 changed files with 1450 additions and 1450 deletions
|
@ -1,44 +1,44 @@
|
|||
local M = {}
|
||||
function M.bufremove(buf)
|
||||
buf = buf or 0
|
||||
buf = buf == 0 and vim.api.nvim_get_current_buf() or buf
|
||||
buf = buf or 0
|
||||
buf = buf == 0 and vim.api.nvim_get_current_buf() or buf
|
||||
|
||||
if vim.bo.modified then
|
||||
local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel")
|
||||
if choice == 0 then -- Cancel
|
||||
return
|
||||
end
|
||||
if choice == 1 then -- Yes
|
||||
vim.cmd.write()
|
||||
end
|
||||
end
|
||||
if vim.bo.modified then
|
||||
local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel")
|
||||
if choice == 0 then -- Cancel
|
||||
return
|
||||
end
|
||||
if choice == 1 then -- Yes
|
||||
vim.cmd.write()
|
||||
end
|
||||
end
|
||||
|
||||
for _, win in ipairs(vim.fn.win_findbuf(buf)) do
|
||||
vim.api.nvim_win_call(win, function()
|
||||
if not vim.api.nvim_win_is_valid(win) or vim.api.nvim_win_get_buf(win) ~= buf then
|
||||
return
|
||||
end
|
||||
-- Try using alternate buffer
|
||||
local alt = vim.fn.bufnr("#")
|
||||
if alt ~= buf and vim.fn.buflisted(alt) == 1 then
|
||||
vim.api.nvim_win_set_buf(win, alt)
|
||||
return
|
||||
end
|
||||
for _, win in ipairs(vim.fn.win_findbuf(buf)) do
|
||||
vim.api.nvim_win_call(win, function()
|
||||
if not vim.api.nvim_win_is_valid(win) or vim.api.nvim_win_get_buf(win) ~= buf then
|
||||
return
|
||||
end
|
||||
-- Try using alternate buffer
|
||||
local alt = vim.fn.bufnr("#")
|
||||
if alt ~= buf and vim.fn.buflisted(alt) == 1 then
|
||||
vim.api.nvim_win_set_buf(win, alt)
|
||||
return
|
||||
end
|
||||
|
||||
-- Try using previous buffer
|
||||
local has_previous = pcall(vim.cmd, "bprevious")
|
||||
if has_previous and buf ~= vim.api.nvim_win_get_buf(win) then
|
||||
return
|
||||
end
|
||||
-- Try using previous buffer
|
||||
local has_previous = pcall(vim.cmd, "bprevious")
|
||||
if has_previous and buf ~= vim.api.nvim_win_get_buf(win) then
|
||||
return
|
||||
end
|
||||
|
||||
-- Create new listed buffer
|
||||
local new_buf = vim.api.nvim_create_buf(true, false)
|
||||
vim.api.nvim_win_set_buf(win, new_buf)
|
||||
end)
|
||||
end
|
||||
if vim.api.nvim_buf_is_valid(buf) then
|
||||
pcall(vim.cmd, "bdelete! " .. buf)
|
||||
end
|
||||
-- Create new listed buffer
|
||||
local new_buf = vim.api.nvim_create_buf(true, false)
|
||||
vim.api.nvim_win_set_buf(win, new_buf)
|
||||
end)
|
||||
end
|
||||
if vim.api.nvim_buf_is_valid(buf) then
|
||||
pcall(vim.cmd, "bdelete! " .. buf)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue