diff options
Diffstat (limited to '.config/nvim/lua/core/keymaps.lua')
| -rw-r--r-- | .config/nvim/lua/core/keymaps.lua | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua index b63156d..95e5fcd 100644 --- a/.config/nvim/lua/core/keymaps.lua +++ b/.config/nvim/lua/core/keymaps.lua | |||
| @@ -12,12 +12,11 @@ map("c", "w!!", 'execute "silent! write !sudo tee % >/dev/null" <bar> edit!<CR>' | |||
| 12 | map("n", "Q", "gq", "format lines") | 12 | map("n", "Q", "gq", "format lines") |
| 13 | 13 | ||
| 14 | -- set formatprg to sentences, for prose | 14 | -- set formatprg to sentences, for prose |
| 15 | -- TODO: can we do this with vim.o.formatprg? | 15 | map("n", "<Leader>fp", ":set formatprg=~/.local/bin/sentences<CR>", "switch to sentences formatprg", { silent = false }) |
| 16 | map("n", "<Leader>fp", "<cmd>set formatprg=~/.local/bin/sentences<CR>", "switch to sentences view", { silent = false }) | ||
| 17 | 16 | ||
| 18 | -- replace all is aliased to S. | 17 | -- replace all is aliased to S. |
| 19 | map("n", "S", ":s//g<Left><Left>", "replace all", { silent = false }) | 18 | map("n", "<leader>S", ":%s//g<Left><Left>", "replace all", { silent = false }) |
| 20 | map("v", "S", ":s//g<Left><Left>", "replace all selection", { silent = false }) | 19 | map("v", "<leader>S", ":s//g<Left><Left>", "replace all", { silent = false }) |
| 21 | 20 | ||
| 22 | -- jump to buffer | 21 | -- jump to buffer |
| 23 | map("n", "<Leader>b", "<cmd>ls<cr>:b<space>", "jump to buffer") | 22 | map("n", "<Leader>b", "<cmd>ls<cr>:b<space>", "jump to buffer") |
| @@ -42,16 +41,16 @@ map("n", "<Leader>cd", "<cmd>lcd %:p:h<CR>:pwd<CR>", "cd to current buffer's pwd | |||
| 42 | 41 | ||
| 43 | -- call CreatePaper on word below cursor | 42 | -- call CreatePaper on word below cursor |
| 44 | map("n", "<leader>np", 'gewi[[/papers/<ESC>Ea]]<ESC>bb:call CreatePaper(expand("<cword>"))<CR>', | 43 | map("n", "<leader>np", 'gewi[[/papers/<ESC>Ea]]<ESC>bb:call CreatePaper(expand("<cword>"))<CR>', |
| 45 | "vimwiki new paper on word under cursor") | 44 | "vimwiki: new paper on word under cursor") |
| 46 | 45 | ||
| 47 | -- link paper | 46 | -- link paper |
| 48 | map("n", "<leader>lp", "gewi[[/papers/<ESC>Ea]]<ESC>", "vimwiki link wrap word under cursor") | 47 | map("n", "<leader>lp", "gewi[[/papers/<ESC>Ea]]<ESC>", "vimwiki: link wrap word under cursor") |
| 49 | 48 | ||
| 50 | -- call CreateReference on word below cursor | 49 | -- call CreateReference on word below cursor |
| 51 | map("n", "<leader>nr", '<cmd>call CreateReference(expand("<cword>"))<CR>', "vimwiki new reference word under cursor") | 50 | map("n", "<leader>nr", '<cmd>call CreateReference(expand("<cword>"))<CR>', "vimwiki: new reference word under cursor") |
| 52 | 51 | ||
| 53 | -- create a new note | 52 | -- create a new note |
| 54 | map("n", "<leader>nn", "<cmd>call CreateNote()<CR>", "vimwiki new note for slipbox") | 53 | map("n", "<leader>nn", "<cmd>call CreateNote()<CR>", "vimwiki: new note for slipbox") |
| 55 | 54 | ||
| 56 | -- :%% to get current file path | 55 | -- :%% to get current file path |
| 57 | map('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", "get current file path", { expr = true, silent = false }) | 56 | map('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", "get current file path", { expr = true, silent = false }) |
| @@ -67,6 +66,10 @@ map('v', 'Y', 'myY`y') | |||
| 67 | -- ` is more useful than ' | 66 | -- ` is more useful than ' |
| 68 | map('n', "'", '`') | 67 | map('n', "'", '`') |
| 69 | 68 | ||
| 69 | -- keep cursor in the middle while doing search | ||
| 70 | map("n", "n", "nzzzv") | ||
| 71 | map("n", "N", "Nzzzv") | ||
| 72 | |||
| 70 | -- switch between light and dark modes | 73 | -- switch between light and dark modes |
| 71 | map("n", "<leader>ut", function() | 74 | map("n", "<leader>ut", function() |
| 72 | if vim.o.background == "dark" then | 75 | if vim.o.background == "dark" then |
