From 1844f0f71ccf933823ee51cbe8c4e4de35f97678 Mon Sep 17 00:00:00 2001 From: protiumx Date: Fri, 17 Nov 2023 20:41:43 +0100 Subject: [PATCH] use instead of : --- stow/nvim/.config/nvim/lua/config/keymaps.lua | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/stow/nvim/.config/nvim/lua/config/keymaps.lua b/stow/nvim/.config/nvim/lua/config/keymaps.lua index 2728cd72..2e286ba8 100644 --- a/stow/nvim/.config/nvim/lua/config/keymaps.lua +++ b/stow/nvim/.config/nvim/lua/config/keymaps.lua @@ -10,7 +10,7 @@ vim.keymap.set('v', 'd', '"_d', { silent = true }) vim.keymap.set('n', 'wr', [[:%s/\<\>//g]]) vim.keymap.set('i', '', '', { silent = true }) -vim.keymap.set("n", "Q", "", { silent = true }) +vim.keymap.set('n', 'Q', '', { silent = true }) vim.keymap.set('n', 'Y', 'y$', { silent = true }) -- Jump next/prev but centered @@ -26,21 +26,21 @@ vim.keymap.set('n', '', 'zz', { silent = true }) vim.keymap.set('n', '', 'zz', { silent = true }) -- Move lines up/down preserving format -vim.keymap.set('n', '', ':m .+1==', { silent = true }) -vim.keymap.set('n', '', ':m .-2==', { silent = true }) -vim.keymap.set('i', '', ':m .+1==gi', { silent = true }) -vim.keymap.set('i', '', ':m .-2==gi', { silent = true }) -vim.keymap.set('v', '', ':m \'>+1gv=gv', { silent = true }) -vim.keymap.set('v', '', ':m \'<-2gv=gv', { silent = true }) +vim.keymap.set('n', '', 'm .+1==', { silent = true }) +vim.keymap.set('n', '', 'm .-2==', { silent = true }) +vim.keymap.set('i', '', 'm .+1==gi', { silent = true }) +vim.keymap.set('i', '', 'm .-2==gi', { silent = true }) +vim.keymap.set('v', '', "m '>+1gv=gv", { silent = true }) +vim.keymap.set('v', '', "m '<-2gv=gv", { silent = true }) -- Join line with cursor at beginning of line using z as mark -vim.keymap.set("n", "J", "mzJ`z", { silent = true }) +vim.keymap.set('n', 'J', 'mzJ`z', { silent = true }) -- Resize windows -vim.keymap.set('n', '', ':resize -2', { silent = true }) -vim.keymap.set('n', '', ':resize +2', { silent = true }) -vim.keymap.set('n', '', ':vertical resize +2', { silent = true }) -vim.keymap.set('n', '', ':vertical resize -2', { silent = true }) +vim.keymap.set('n', '', 'resize -2', { silent = true }) +vim.keymap.set('n', '', 'resize +2', { silent = true }) +vim.keymap.set('n', '', 'vertical resize +2', { silent = true }) +vim.keymap.set('n', '', 'vertical resize -2', { silent = true }) -- Navigate windows vim.keymap.set('n', 'h', 'h', { silent = true }) vim.keymap.set('n', 'j', 'j', { silent = true }) @@ -50,15 +50,15 @@ vim.keymap.set('n', 'l', 'l', { silent = true }) -- Toggle between current and prev buffers vim.keymap.set('n', '``', '', { silent = true }) -- Close buffer without changing window layout -vim.keymap.set('n', '--', ':e # | bd #', { silent = true }) +vim.keymap.set('n', '--', 'e # | bd #', { silent = true }) -- Close all except the current buffer -vim.keymap.set('n', '', ':%bd | e #', { silent = true }) +vim.keymap.set('n', '', '%bd | e #', { silent = true }) -- Go next/prev buffer using Tab -vim.keymap.set('n', '', ':bn', { silent = true }) -vim.keymap.set('n', '', ':bp', { silent = true }) +vim.keymap.set('n', '', 'bn', { silent = true }) +vim.keymap.set('n', '', 'bp', { silent = true }) -- Tab navigation -vim.keymap.set({ 't', 'n' }, '', 'tabn', { silent = true }) +vim.keymap.set({ 't', 'n' }, "", 'tabn', { silent = true }) vim.keymap.set({ 't', 'n' }, '', 'tabp', { silent = true }) -- Select all text in current buffer @@ -66,10 +66,10 @@ vim.keymap.set('n', '', 'ggVG', { silent = true }) vim.keymap.set('i', '', 'ggVG', { silent = true }) -- Open new file adjacent to current file -vim.keymap.set('n', 'o', ':e =expand("%:h") . "/"') -vim.keymap.set('n', 'vo', ':vsp | e =expand("%:h") . "/"') +vim.keymap.set('n', 'o', 'e =expand("%:h") . "/"') +vim.keymap.set('n', 'vo', 'vsp | e =expand("%:h") . "/"') -- Go to previous buffer and open # in vertical split -vim.keymap.set('n', 'bb', ':bp | vs #') +vim.keymap.set('n', 'bb', 'bp | vs #') -- Paste formatted vim.keymap.set('n', 'p', 'p=`]', { silent = true }) @@ -95,29 +95,27 @@ if macos then -- Copy to system clipboard vim.keymap.set('v', '', '"*y', { silent = true }) vim.keymap.set('n', 'P', function() - local path = vim.fn.expand("%:~:.") - vim.fn.setreg("*", path) + local path = vim.fn.expand('%:~:.') + vim.fn.setreg('*', path) print('Copied: ' .. path) end, { desc = 'copy current path to clipboard' }) vim.keymap.set('n', 'L', function() - local path = vim.fn.expand("%:h") .. "/" .. vim.fn.expand("%:t") .. ":" .. vim.fn.line(".") - vim.fn.setreg("*", path) - print('Copied: ' .. path) - end, - { desc = 'copy current path with line and column to clipboard' }) + local path = vim.fn.expand('%:h') .. '/' .. vim.fn.expand('%:t') .. ':' .. vim.fn.line('.') + vim.fn.setreg('*', path) + print('Copied: ' .. path) + end, { desc = 'copy current path with line and column to clipboard' }) else vim.keymap.set('v', '', '"+y', { silent = true }) vim.keymap.set('n', 'P', function() - local path = vim.fn.expand("%:~:.") - vim.fn.setreg("+", path) + local path = vim.fn.expand('%:~:.') + vim.fn.setreg('+', path) print('Copied: ' .. path) end, { desc = 'copy current path to clipboard' }) vim.keymap.set('n', 'L', function() - local path = vim.fn.expand("%:h") .. "/" .. vim.fn.expand("%:t") .. ":" .. vim.fn.line(".") - vim.fn.setreg("+", path) - print('Copied: ' .. path) - end, - { desc = 'copy current path with line and column to clipboard' }) + local path = vim.fn.expand('%:h') .. '/' .. vim.fn.expand('%:t') .. ':' .. vim.fn.line('.') + vim.fn.setreg('+', path) + print('Copied: ' .. path) + end, { desc = 'copy current path with line and column to clipboard' }) end -- Git @@ -126,9 +124,9 @@ vim.keymap.set('n', 's', function() print('Staged: ' .. vim.fn.expand('%')) end, { desc = '[Git] stage current file', silent = true }) -vim.keymap.set('n', '', ':!git push', { desc = '[Git] push' }) +vim.keymap.set('n', '', '!git push', { desc = '[Git] push' }) -vim.keymap.set('n', '', ':!git pull', { desc = '[Git] pull' }) +vim.keymap.set('n', '', '!git pull', { desc = '[Git] pull' }) vim.keymap.set('n', 'R', function() vim.cmd('!git checkout origin/main %') @@ -139,13 +137,15 @@ vim.keymap.set('n', '', 'gv', { silent = true, desc = 'activate previous vi vim.keymap.set('i', 'ud', function() local uuid, _ = vim.fn.system('uuidgen'):gsub('\n', ''):lower() - vim.api.nvim_put({ uuid }, "c", false, true) -end, { silent = true, desc = "Insert UUID" }) + vim.api.nvim_put({ uuid }, 'c', false, true) +end, { silent = true, desc = 'Insert UUID' }) -- Insert current date as ISO YYYY-MM-DD-HH:mm vim.keymap.set('i', 'id', '"=strftime("%Y-%m-%dT%H:%M")p') -- Insert build date vim.keymap.set('i', 'bd', '"=strftime("%Y%m%d%H%M")p') -- Quickfix navigation -vim.keymap.set('n', 'q', ':cn') -vim.keymap.set('n', 'Q', ':cp') +vim.keymap.set('n', 'q', 'cn') +vim.keymap.set('n', 'Q', 'cp') + +vim.keymap.set('v', '\\', 'y/"', { desc = 'search for highlighted text' })