diff --git a/nvim/lua/mappings.lua b/nvim/lua/mappings.lua index d5f2b4a..81dcf51 100644 --- a/nvim/lua/mappings.lua +++ b/nvim/lua/mappings.lua @@ -8,23 +8,23 @@ local opts = { -- default options -- basic -- ==================================================================== -map("n", "d", ":Dashboard", opts) -- show dashboard -map("n", "U", "", opts) -- disable U (scary behvaior) +map("n", "d", ":Dashboard", opts) -- show dashboard: https://github.com/nvimdev/dashboard-nvim +map("n", "U", "", opts) -- disable U (scary behvaior) -- Scroling and finding -map("n", "", "zz", opts) -- centered cursor when scrolling down -map("n", "", "zz", opts) -- centered cursor when scrolling up -map('n', 'n', 'nzzzv') -- Next search result stays centered -map('n', 'N', 'Nzzzv') -- Previous search result stays centered +map("n", "", "zz", opts) -- centered cursor when scrolling down +map("n", "", "zz", opts) -- centered cursor when scrolling up +map('n', 'n', 'nzzzv') -- Next search result stays centered +map('n', 'N', 'Nzzzv') -- Previous search result stays centered -- Saving and quitting -map("n", "", ":w", opts) -- ctrl+s saves in normal ... -map("i", "", ":wa", opts) -- ... and in insert mode returns to insert -map('n', 'w', ':w') -- Save with space+w -map('n', 'q', ':q') -- Quit with space+q -map("x", "p", "\"_dP", opts) -- preserve paste register when pasting over selection +map("n", "", ":w", opts) -- ctrl+s saves in normal ... +map("i", "", ":wa", opts) -- ... and in insert mode returns to insert +map('n', 'w', ':w') -- Save with space+w +map('n', 'q', ':q') -- Quit with space+q +map("x", "p", "\"_dP", opts) -- preserve paste register when pasting over selection -- Directory Navigation -map('n', 'cd', ':cd %:p:h:pwd') -- cd to dir of current file and show it -map('n', 'cdww', ':lcd %:p:h:pwd', opts) -- window-local cd to dir of current file and show it -map('n', 'cdr', function() -- cd to git root of current file (if in git repo) +map('n', 'cd', ':cd %:p:h:pwd') -- cd to dir of current file and show it +map('n', 'cdww', ':lcd %:p:h:pwd') -- window-local cd to dir of current file and show it +map('n', 'cdr', function() -- cd to git root of current file (if in git repo) local handle = io.popen('git rev-parse --is-inside-work-tree 2>/dev/null') if handle then local result = handle:read("*a") @@ -36,7 +36,7 @@ map('n', 'cdr', function() -- cd to git root of cu vim.notify("Not in a git repository", vim.log.levels.WARN) end end -end, opts) +end) map('n', 'cdwr', function() -- window-local cd to git root of current file (if in git repo) local handle = io.popen('git rev-parse --is-inside-work-tree 2>/dev/null') if handle then @@ -49,14 +49,28 @@ map('n', 'cdwr', function() -- window-local cd to git root of current fi vim.notify("Not in a git repository", vim.log.levels.WARN) end end -end, opts) +end) + +-- window navigation +-- to use ALT+{h,j,k,l} to navigate windows from any mode: +map("t", "", "h", opts) +map("t", "", "j", opts) +map("t", "", "k", opts) +map("t", "", "l", opts) +map("i", "", "h", opts) +map("i", "", "j", opts) +map("i", "", "k", opts) +map("i", "", "l", opts) +map("n", "", "h", opts) +map("n", "", "j", opts) +map("n", "", "k", opts) +map("n", "", "l", opts) --- terminal stuff +-- terminal stuff: http://neovim.io/doc/user/terminal.html#terminal map('n', 'tt', ':lcd %:p:h:terminal', opts) -- open terminal in dir of current file map('n', 'T', ':terminal', opts) -- open terminal in working directory map('t', '', '', opts) -- all other mappings didn't work --- vim.keymap.set('t', 'jk', '', { noremap = true }) map('n', 'tr', function() -- terminal in git root (if in git repo) local handle = io.popen('git rev-parse --is-inside-work-tree 2>/dev/null') if handle then