From 1028cb2d88923d4a141e44fa9fc277b5b1ec07b2 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Fri, 8 Mar 2024 20:28:40 +0300 Subject: [PATCH] Nvim : Add ' to toggle tab width. --- module/common/nvim/key/Common.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/module/common/nvim/key/Common.lua b/module/common/nvim/key/Common.lua index 06452016..2e8ff04d 100644 --- a/module/common/nvim/key/Common.lua +++ b/module/common/nvim/key/Common.lua @@ -4,6 +4,24 @@ function bye() vim.cmd[[qa!]] end +function toggle_tab_width() + if vim.bo.shiftwidth == 2 then + vim.bo.shiftwidth = 4 + vim.bo.tabstop = 4 + vim.bo.softtabstop = 4 + elseif vim.bo.shiftwidth == 4 then + vim.bo.shiftwidth = 8 + vim.bo.tabstop = 8 + vim.bo.softtabstop = 8 + elseif vim.bo.shiftwidth == 8 then + vim.bo.shiftwidth = 2 + vim.bo.tabstop = 2 + vim.bo.softtabstop = 2 + end +end + +rekey_normal("'", "lua toggle_tab_width()") + -- Repeat previous command. rekey_normal(".", "@:") rekey_visual(".", "@:")