2023-08-29 20:07:23 +02:00
|
|
|
vim.api.nvim_set_keymap("n", "<leader>j", "<cmd>bprev<cr>", { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap("n", "<leader>k", "<cmd>bnext<cr>", { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap("x", "<C-p>", '"_dP', { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap("n", "<leader>/", "gcc", { noremap = false, silent = true })
|
|
|
|
vim.api.nvim_set_keymap(
|
|
|
|
"v",
|
|
|
|
"<leader>/",
|
|
|
|
"<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>",
|
|
|
|
{ noremap = true, silent = true }
|
|
|
|
)
|
|
|
|
|
|
|
|
-- Move to window using the <ctrl> hjkl keys
|
|
|
|
vim.keymap.set("n", "<C-h>", "<C-w>h", { desc = "Go to left window", remap = true })
|
|
|
|
vim.keymap.set("n", "<C-j>", "<C-w>j", { desc = "Go to lower window", remap = true })
|
|
|
|
vim.keymap.set("n", "<C-k>", "<C-w>k", { desc = "Go to upper window", remap = true })
|
|
|
|
vim.keymap.set("n", "<C-l>", "<C-w>l", { desc = "Go to right window", remap = true })
|
|
|
|
|
|
|
|
-- Resize window using <ctrl> arrow keys
|
|
|
|
vim.keymap.set("n", "<C-Up>", "<cmd>resize +2<cr>", { desc = "Increase window height" })
|
|
|
|
vim.keymap.set("n", "<C-Down>", "<cmd>resize -2<cr>", { desc = "Decrease window height" })
|
|
|
|
vim.keymap.set("n", "<C-Left>", "<cmd>vertical resize -2<cr>", { desc = "Decrease window width" })
|
|
|
|
vim.keymap.set("n", "<C-Right>", "<cmd>vertical resize +2<cr>", { desc = "Increase window width" })
|
|
|
|
|
|
|
|
-- Clear search with <esc>
|
|
|
|
vim.keymap.set({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" })
|
|
|
|
|
|
|
|
-- Clear search, diff update and redraw
|
|
|
|
-- taken from runtime/lua/_editor.lua
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"<leader>ur",
|
|
|
|
"<Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR>",
|
|
|
|
{ desc = "Redraw / clear hlsearch / diff update" }
|
|
|
|
)
|
|
|
|
|
|
|
|
vim.keymap.set({ "n", "x" }, "gw", "*N", { desc = "Search word under cursor" })
|
|
|
|
|
|
|
|
-- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n
|
|
|
|
vim.keymap.set("n", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
|
|
|
|
vim.keymap.set("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
|
|
|
|
vim.keymap.set("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
|
|
|
|
vim.keymap.set("n", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
|
|
|
|
vim.keymap.set("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
|
|
|
|
vim.keymap.set("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
|
|
|
|
|
|
|
|
--keywordprg
|
|
|
|
vim.keymap.set("n", "<leader>K", "<cmd>norm! K<cr>", { desc = "Keywordprg" })
|
|
|
|
|
|
|
|
-- lazy
|
|
|
|
vim.keymap.set("n", "<leader>l", "<cmd>Lazy<cr>", { desc = "Lazy" })
|
|
|
|
|
|
|
|
-- new file
|
2023-08-29 22:06:35 +02:00
|
|
|
vim.keymap.set("n", "<leader>n", "<cmd>enew<cr>", { desc = "New File" })
|
2023-08-29 20:07:23 +02:00
|
|
|
|
|
|
|
vim.keymap.set("n", "<leader>xl", "<cmd>lopen<cr>", { desc = "Location List" })
|
|
|
|
vim.keymap.set("n", "<leader>xq", "<cmd>copen<cr>", { desc = "Quickfix List" })
|
|
|
|
|
|
|
|
vim.keymap.set("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" })
|
|
|
|
|
|
|
|
-- highlights under cursor
|
|
|
|
if vim.fn.has("nvim-0.9.0") == 1 then
|
|
|
|
vim.keymap.set("n", "<leader>ui", vim.show_pos, { desc = "Inspect Pos" })
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Terminal vim.keymap.setpings
|
|
|
|
vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>", { desc = "Enter Normal Mode" })
|
|
|
|
vim.keymap.set("t", "<C-h>", "<cmd>wincmd h<cr>", { desc = "Go to left window" })
|
|
|
|
vim.keymap.set("t", "<C-j>", "<cmd>wincmd j<cr>", { desc = "Go to lower window" })
|
|
|
|
vim.keymap.set("t", "<C-k>", "<cmd>wincmd k<cr>", { desc = "Go to upper window" })
|
|
|
|
vim.keymap.set("t", "<C-l>", "<cmd>wincmd l<cr>", { desc = "Go to right window" })
|
2023-08-29 22:06:35 +02:00
|
|
|
vim.keymap.set("t", "<C-w>", "<cmd>close<cr>", { desc = "Hide Terminal" })
|
2023-08-29 20:07:23 +02:00
|
|
|
|
|
|
|
-- lsp
|
|
|
|
vim.keymap.set("n", "gd", "<cmd>lua vim.lsp.buf.definition()<cr>", { desc = "Goto Definition" })
|
|
|
|
vim.keymap.set("n", "gs", "<cmd>vsplit | lua vim.lsp.buf.definition()<cr>", { desc = "Goto Definition in vertical split" })
|
|
|
|
vim.keymap.set("n", "gS", "<cmd>belowright | lua vim.lsp.buf.definition()<cr>", { desc = "Goto Definition in horizontal split" })
|
|
|
|
vim.keymap.set("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<cr>", { desc = "Goto Declaration" })
|
|
|
|
vim.keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<cr>", { desc = "Goto Implementation" })
|
|
|
|
vim.keymap.set("n", "gr", "<cmd>lua vim.lsp.buf.references()<cr>", { desc = "Goto References" })
|
|
|
|
vim.keymap.set("n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>", { desc = "Hover" })
|
|
|
|
|
|
|
|
vim.keymap.set("n", "<leader>ld", vim.diagnostic.open_float, { desc = "Line Diagnostics" })
|
|
|
|
vim.keymap.set("n", "<leader>ll", "<cmd>LspInfo<cr>", { desc = "Lsp Info" })
|
|
|
|
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, { desc = "Format document" })
|
|
|
|
vim.keymap.set("n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<CR>", { desc = "Code actions" })
|
|
|
|
vim.keymap.set("n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<CR>", { desc = "Rename" })
|
|
|
|
|
|
|
|
-- colorizer
|
|
|
|
vim.keymap.set("n", "<leader>cs", "<cmd>ColorizerToggle<CR>", { desc = "Toggle show colors" })
|
2023-08-29 22:06:35 +02:00
|
|
|
|
|
|
|
-- undo tree
|
|
|
|
vim.keymap.set('n', '<leader>uu', vim.cmd.UndotreeToggle, { desc = "Toggle undo tree" })
|
|
|
|
|
|
|
|
-- harpoon
|
|
|
|
vim.keymap.set("n", "<leader>hh", "<cmd>lua require('harpoon.ui').toggle_quick_menu()<cr>", { desc = "Harpoon Menu" })
|
|
|
|
vim.keymap.set("n", "<leader>ha", "<cmd>lua require('harpoon.mark').add_file()<cr>", { desc = "Harpoon Add File" })
|