From 221ffe68ca203c1be4b1d1eb755bd8a7f6b98989 Mon Sep 17 00:00:00 2001 From: desktop Date: Sat, 6 Jan 2024 06:48:38 +0300 Subject: [PATCH] Nvim : now ignores non-writable buffers. --- .config/nvim/lua/key/Common.lua | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.config/nvim/lua/key/Common.lua b/.config/nvim/lua/key/Common.lua index 39fb3e0..212a444 100644 --- a/.config/nvim/lua/key/Common.lua +++ b/.config/nvim/lua/key/Common.lua @@ -1,15 +1,21 @@ require('key/Rekey') -rekey_normal('.', '@:') -- repeat command. -rekey_visual('.', '@:') -- repeat command. -rekey_normal('zz', 'wa') -- save all files. -rekey_normal('z', 'wqa') -- save & quit all. -rekey_normal('v', 'v') -- visual select (duplicate). -rekey_normal('gh', '0') -- go left. -rekey_normal('gl', '$') -- go right. -rekey_normal('gj', 'G') -- go bottom. -rekey_normal('gk', 'gg') -- go top. -rekey_normal('U', '') -- redo. +-- Write all we can and exit. Created this to drop non-writable stuff when piping to nvim. +function bye() + pcall(vim.cmd, "wa") + vim.cmd[[qa!]] +end + +rekey_normal('.', '@:') -- repeat command. +rekey_visual('.', '@:') -- repeat command. +rekey_normal('zz', 'wa') -- save all files. +rekey_normal('z', 'lua bye()') -- save & quit all. +rekey_normal('v', 'v') -- visual select (duplicate). +rekey_normal('gh', '0') -- go left. +rekey_normal('gl', '$') -- go right. +rekey_normal('gj', 'G') -- go bottom. +rekey_normal('gk', 'gg') -- go top. +rekey_normal('U', '') -- redo. rekey_normal(';', ':') -- remap ; to :. rekey_visual(';', ':') -- remap ; to :.