Nvim : Improve <Leader>x buffer close.

This commit is contained in:
Dmitry Voronin 2024-02-23 23:53:26 +03:00
parent 13f0a96510
commit f10abfc83d
3 changed files with 15 additions and 6 deletions

View file

@ -8,6 +8,7 @@ require("config/Search")
require("config/Tab")
require("key/Autocomplete")
require("key/Buffer")
require("key/Comment")
require("key/Common")
require("key/Filetree")

View file

@ -0,0 +1,14 @@
require("key/Rekey")
-- New empty buffer.
remap_normal("<Leader>n", "<cmd>enew<cr>")
-- Close buffer.
function _buf_close()
pcall(vim.cmd, "w")
vim.cmd[[bp|sp|bn|bd!]]
end
rekey_normal("<Leader>x", "<cmd>lua _buf_close()<cr>")
-- Close all hidden buffers.
rekey_normal("<Leader>X", "<cmd>BDelete hidden<cr><C-l>")

View file

@ -12,12 +12,6 @@ rekey_normal("<Leader>Q", "<cmd>BufferLineMovePrev<cr>")
rekey_normal("<Leader>e", "<cmd>BufferLineCycleNext<cr>")
rekey_normal("<Leader>q", "<cmd>BufferLineCyclePrev<cr>")
-- Close buffer.
rekey_normal("<Leader>x", "<cmd>bp<bar>sp<bar>bn<bar>bd<cr>")
-- Close all hidden buffers.
rekey_normal("<Leader>X", "<cmd>BDelete hidden<cr><C-l>")
-- Splits.
rekey_normal("<Leader>\\", "<cmd>vsplit<cr>")
rekey_normal("<Leader>-", "<cmd>split<cr>")