From 5a0c981679093abe6185fc9782a172bfc41f8252 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 7 Nov 2023 04:01:31 +0100 Subject: nvim: Rework sorting and transposition --- .config/nvim/lua/mango/packer.lua | 1 + .config/nvim/lua/mango/remap.lua | 19 ++++--------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/.config/nvim/lua/mango/packer.lua b/.config/nvim/lua/mango/packer.lua index 83e0ff3..02aa11a 100644 --- a/.config/nvim/lua/mango/packer.lua +++ b/.config/nvim/lua/mango/packer.lua @@ -23,6 +23,7 @@ return require('packer').startup(function(use) use 'kylechui/nvim-surround' use 'mattn/emmet-vim' use 'tpope/vim-commentary' + use 'christoomey/vim-sort-motion' -- Git integration use 'tpope/vim-fugitive' diff --git a/.config/nvim/lua/mango/remap.lua b/.config/nvim/lua/mango/remap.lua index 824ad53..2c41cfc 100644 --- a/.config/nvim/lua/mango/remap.lua +++ b/.config/nvim/lua/mango/remap.lua @@ -42,18 +42,10 @@ remap('i', '', '"+pa') remap('nv', "'", '`') remap('nv', '`', "'") --- Transpose characters without clobbering registers -local function transpose_chars(rev) - lib.save_regs('a', function() - vim.cmd.normal('"a' .. (rev and 'X' or 'x') .. '"ap') - end) -end - --- Transpose characters -remap('n', 't', transpose_chars) -remap('n', 'T', function() - transpose_chars(true) -end) +-- Transpose characters; for some reason it has a noticable delay if I just give +-- a string instead of lambda functions +remap('n', 't', function() vim.cmd.normal('"zx"zp') end) +remap('n', 'T', function() vim.cmd.normal('"zX"zp') end) -- Open netrw quickly remap('n', '-', ':Ex') @@ -63,6 +55,3 @@ remap('n', '-', ':Ex') -- bottom instead of the left or top remap('n', 'ā€“', ':vsplit | Ex') remap('n', 'gā€“', ':split | Ex') - --- Sort lines in selection -remap('v', 's', ':sort') -- cgit v1.2.3