From f10abfc83d0afffb19f0c3498c92ec9d3b4236b1 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Fri, 23 Feb 2024 23:53:26 +0300 Subject: [PATCH] Nvim : Improve x buffer close. --- .config/nvim/init.lua | 1 + .config/nvim/lua/key/Buffer.lua | 14 ++++++++++++++ .config/nvim/lua/key/Navigation.lua | 6 ------ 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 .config/nvim/lua/key/Buffer.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 9e8e67c..ee29733 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -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") diff --git a/.config/nvim/lua/key/Buffer.lua b/.config/nvim/lua/key/Buffer.lua new file mode 100644 index 0000000..c939b21 --- /dev/null +++ b/.config/nvim/lua/key/Buffer.lua @@ -0,0 +1,14 @@ +require("key/Rekey") + +-- New empty buffer. +remap_normal("n", "enew") + +-- Close buffer. +function _buf_close() + pcall(vim.cmd, "w") + vim.cmd[[bp|sp|bn|bd!]] +end +rekey_normal("x", "lua _buf_close()") + +-- Close all hidden buffers. +rekey_normal("X", "BDelete hidden") diff --git a/.config/nvim/lua/key/Navigation.lua b/.config/nvim/lua/key/Navigation.lua index c92c32c..27388f2 100644 --- a/.config/nvim/lua/key/Navigation.lua +++ b/.config/nvim/lua/key/Navigation.lua @@ -12,12 +12,6 @@ rekey_normal("Q", "BufferLineMovePrev") rekey_normal("e", "BufferLineCycleNext") rekey_normal("q", "BufferLineCyclePrev") --- Close buffer. -rekey_normal("x", "bpspbnbd") - --- Close all hidden buffers. -rekey_normal("X", "BDelete hidden") - -- Splits. rekey_normal("\\", "vsplit") rekey_normal("-", "split")