2024-07-10 20:11:06 +00:00
|
|
|
vim.api.nvim_create_user_command("Pin", function()
|
2024-07-11 09:06:10 +00:00
|
|
|
vim.bo.bufhidden = nil
|
2024-07-10 20:11:06 +00:00
|
|
|
end, {})
|
|
|
|
|
|
|
|
vim.api.nvim_create_user_command("Drop", function()
|
2024-07-11 09:06:10 +00:00
|
|
|
vim.bo.bufhidden = "delete"
|
2024-07-10 20:11:06 +00:00
|
|
|
end, {})
|
|
|
|
|
|
|
|
vim.api.nvim_create_user_command("Ephemeral", function(params)
|
|
|
|
if params.args == "" then
|
2024-07-16 07:16:52 +00:00
|
|
|
vim.api.nvim_echo({
|
|
|
|
{"New buffers are "},
|
|
|
|
vim.g.ephemeral_buffers
|
|
|
|
and {"ephemeral", "DiffDelete"}
|
|
|
|
or {"permanent", "DiffAdd"};
|
|
|
|
}, false, {})
|
2024-07-10 20:11:06 +00:00
|
|
|
elseif params.args == "on" then
|
|
|
|
vim.g.ephemeral_buffers = true
|
|
|
|
elseif params.args == "off" then
|
|
|
|
vim.g.ephemeral_buffers = false
|
|
|
|
else
|
|
|
|
vim.api.nvim_echo({{"Unknown option: "}, {params.args, "error"}}, false, {})
|
|
|
|
end
|
|
|
|
end, {nargs = "?", complete = function(lead)
|
|
|
|
return vim.fn.filter({ "on", "off" }, function(_, val)
|
|
|
|
return val:find("^" .. lead)
|
|
|
|
end)
|
|
|
|
end})
|
|
|
|
|
|
|
|
vim.g.ephemeral_buffers = false
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd("BufAdd", {
|
|
|
|
callback = function(args)
|
|
|
|
if vim.g.ephemeral_buffers then
|
|
|
|
vim.bo[args.buf].bufhidden = "delete"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|