From 81764d44f86917a38744f22a8c494be3589ae995 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Tue, 2 Nov 2021 15:25:21 +0300 Subject: nvim: mapping fixes --- .config/nvim/lua/mappings.lua | 22 ++++++++++++++++------ .config/nvim/lua/settings.lua | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua index df7e3d3..ad40879 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/mappings.lua @@ -39,16 +39,17 @@ map('n', '*', ':keepjumps normal! mi*`i') map('n', '#', ':keepjumps normal! mi#`i ') -- save file as sudo on files that require root permission -map('c', 'w!!', 'execute "silent! write !sudo tee % >/dev/null" edit!') +map('c', 'w!!', 'execute "silent! write !sudo tee % >/dev/null" edit!', { silent = false }) -- replace ex mode with gq (format lines) map('n', 'Q', 'gq') -- set formatprg to sentences, for prose -map('n', 'fp', ":set formatprg=~/.local/bin/sentences") +map('n', 'fp', ":set formatprg=~/.local/bin/sentences", { silent = false }) -- replace all is aliased to S. -map('n', 'S', ':%s//g') +map('n', 'S', ':%s//g', { silent = false }) +map('v', 'S', ':s//g', { silent = false }) -- if you like "Y" to work from the cursor to the end of line (which is more -- logical, but not Vi-compatible) @@ -58,8 +59,8 @@ map('n', 'Y', 'y$', { noremap = false }) map('n', 'b', ':ls:b') -- up and down are more logical with g.. -map('n', 'k', 'gk') -map('n', 'j', 'gj') +map('n', 'k', '(v:count == 0 ? "gk" : "k")', { expr = true }) +map('n', 'j', '(v:count == 0 ? "gj" : "j")', { expr = true }) map('i', '', 'gka') map('i', '', 'gja') @@ -92,7 +93,16 @@ map('n', 'nr', ':call CreateReference(expand(""))') -- create a new note map('n', 'nn', ':call CreateNote()') -vim.cmd("cnoremap %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'") +-- :%% to get current file path +map('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", { expr = true, silent = false }) + +-- reselect visual selection after indent +map('v', '>', '>gv') +map('v', '<', '