1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

Add mapping to delete other buffers

This commit is contained in:
jdhao 2024-08-17 17:32:24 +02:00
parent f9780c2dff
commit c3d8dc3e1d

View File

@ -45,7 +45,21 @@ keymap.set("n", [[\x]], "<cmd>windo lclose <bar> cclose <cr>", {
-- Delete a buffer, without closing the window, see https://stackoverflow.com/q/4465095/6064933
keymap.set("n", [[\d]], "<cmd>bprevious <bar> bdelete #<cr>", {
silent = true,
desc = "delete buffer",
desc = "delete current buffer",
})
keymap.set("n", [[\D]], function()
local buf_ids = vim.api.nvim_list_bufs()
local cur_buf = vim.api.nvim_win_get_buf(0)
for _, buf_id in pairs(buf_ids) do
-- do not Delete unlisted buffers, which may lead to unexpected errors
if vim.api.nvim_get_option_value("buflisted", { buf = buf_id }) and buf_id ~= cur_buf then
vim.api.nvim_buf_delete(buf_id, { force = true })
end
end
end, {
desc = "delete other buffers",
})
-- Insert a blank line below or above current line (do not move the cursor),
@ -218,18 +232,20 @@ keymap.set("n", "<leader>cb", function()
return
end
timer:start(0, 100, vim.schedule_wrap(function()
vim.cmd [[
timer:start(
0,
100,
vim.schedule_wrap(function()
vim.cmd([[
set cursorcolumn!
set cursorline!
]]
]])
if cnt == blink_times then
timer:close()
end
if cnt == blink_times then
timer:close()
end
cnt = cnt + 1
end)
cnt = cnt + 1
end)
)
end,
{ desc = "show cursor" })
end, { desc = "show cursor" })