1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2024-11-15 06:51:12 +00:00
dotfiles/.config/nvim/lua/core/keymaps.lua

106 lines
3.8 KiB
Lua
Raw Normal View History

2022-10-01 11:46:18 +00:00
-- Shorten function name
local keymap = vim.keymap.set
-- Silent keymap option
local opts = { silent = true }
--Remap space as leader key
keymap("", "<Space>", "<Nop>", opts)
vim.g.mapleader = " "
-- Modes
-- normal_mode = "n",
-- insert_mode = "i",
-- visual_mode = "v",
-- visual_block_mode = "x",
-- term_mode = "t",
-- command_mode = "c",
-- Kitty navigation
vim.g.kitty_navigator_no_mappings = 1
keymap("n", "<A-Left>", ":KittyNavigateLeft<cr>")
keymap("n", "<A-Down>", ":KittyNavigateDown<cr>")
keymap("n", "<A-Up>", ":KittyNavigateUp<cr>")
keymap("n", "<A-Right>", ":KittyNavigateRight<cr>")
2022-10-01 11:46:18 +00:00
-- Better window navigation
keymap("n", "<C-h>", "<C-w>h", opts)
keymap("n", "<C-j>", "<C-w>j", opts)
keymap("n", "<C-k>", "<C-w>k", opts)
keymap("n", "<C-l>", "<C-w>l", opts)
-- Resize with arrows
2023-03-26 10:43:25 +00:00
keymap("n", "<C-Up>", ":resize -2<cr>", opts)
keymap("n", "<C-Down>", ":resize +2<cr>", opts)
keymap("n", "<C-Left>", ":vertical resize -2<cr>", opts)
keymap("n", "<C-Right>", ":vertical resize +2<cr>", opts)
2022-10-01 11:46:18 +00:00
-- Navigate buffers
2023-03-26 10:43:25 +00:00
keymap("n", "<S-l>", ":bnext<cr>", opts)
keymap("n", "<C-PageDown>", ":bnext<cr>", opts)
keymap("n", "<S-h>", ":bprevious<cr>", opts)
keymap("n", "<C-PageUp>", ":bprevious<cr>", opts)
2022-10-01 11:46:18 +00:00
-- Clear highlights
2023-03-26 10:43:25 +00:00
keymap("n", "<leader>h", "<cmd>nohlsearch<cr>", opts)
2022-10-01 11:46:18 +00:00
-- Close buffers
2023-03-26 10:43:25 +00:00
keymap("n", "<S-q>", "<cmd>Bdelete!<cr>", opts)
2022-10-01 11:46:18 +00:00
2022-11-12 17:39:10 +00:00
-- LSP / Diagnostics
2022-10-01 11:46:18 +00:00
keymap("n", "<leader>xx", "<cmd>TroubleToggle<cr>", opts)
keymap("n", "<leader>xw", "<cmd>TroubleToggle workspace_diagnostics<cr>", opts)
keymap("n", "<leader>xd", "<cmd>TroubleToggle document_diagnostics<cr>", opts)
keymap("n", "<leader>xl", "<cmd>TroubleToggle loclist<cr>", opts)
keymap("n", "<leader>xq", "<cmd>TroubleToggle quickfix<cr>", opts)
2022-11-12 17:39:10 +00:00
keymap("n", "K", "<cmd>Lspsaga hover_doc<cr>", opts)
2023-03-11 15:29:00 +00:00
keymap("n", "E", "<cmd>Lspsaga show_line_diagnostics<cr>", opts)
2023-07-18 16:55:28 +00:00
keymap("n", "gd", "<cmd>Lspsaga finder<cr>", opts)
2023-07-19 15:57:14 +00:00
keymap("n", "<leader>ld", "<cmd>Lspsaga goto_definition<cr>", opts)
2022-11-12 17:39:10 +00:00
keymap("n", "<leader>la", "<cmd>Lspsaga code_action<cr>", opts)
keymap("n", "<leader>lj", "<cmd>Lspsaga diagnostic_jump_next<cr>", opts)
keymap("n", "<leader>lk", "<cmd>Lspsaga diagnostic_jump_prev<cr>", opts)
keymap("n", "<leader>lr", "<cmd>Lspsaga rename<cr>", opts)
keymap("n", "<leader>lp", "<cmd>Lspsaga peek_definition<cr>", opts)
2022-12-10 14:16:41 +00:00
keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.format{ async=true }<cr>", opts)
keymap("n", "<leader>ls", "<cmd>lua vim.lsp.buf.signature_help()<cr>", opts)
2022-10-01 11:46:18 +00:00
-- Better paste
keymap("v", "p", "P", opts)
2022-10-01 11:46:18 +00:00
-- Press jk fast to enter
keymap("i", "jk", "<ESC>", opts)
-- Stay in indent mode
keymap("v", "<", "<gv", opts)
keymap("v", ">", ">gv", opts)
-- NeoTree
2023-03-26 10:43:25 +00:00
keymap("n", "<leader>e", ":Neotree toggle<cr>", opts)
keymap("n", "<leader>gg", ":Neotree float git_status<cr>", opts)
2022-10-01 11:46:18 +00:00
-- Telescope
2023-03-26 10:43:25 +00:00
keymap("n", "<leader>ff", ":Telescope find_files<cr>", opts)
keymap("n", "<C-p>", ":Telescope find_files<cr>", opts)
keymap("n", "<leader>fg", ":Telescope live_grep<cr>", opts)
keymap("n", "<leader>fb", ":Telescope buffers<cr>", opts)
keymap("n", "<leader>fc", ":Telescope commands<cr>", opts)
2022-10-01 11:46:18 +00:00
-- Comment
2023-03-26 10:43:25 +00:00
keymap("n", "<leader>/", "<cmd>lua require'Comment.api'.toggle.linewise.current()<cr>", opts)
keymap("x", "<leader>/", "<esc><cmd>lua require'Comment.api'.toggle.linewise(vim.fn.visualmode())<cr>", opts)
-- Gitdiff
keymap("n", "<leader>df", ":DiffviewFileHistory %<cr>", opts)
keymap("n", "<leader>dc", ":DiffviewClose<cr>", opts)
2022-10-01 11:46:18 +00:00
-- Projects
keymap("n", "<leader>fp", ":Telescope neovim-project discover<cr>", opts)
2022-11-09 18:22:40 +00:00
-- Base64
keymap("v", "<leader>64e", ":<c-u>lua require'b64'.encode()<cr>", opts)
keymap("v", "<leader>64d", ":<c-u>lua require'b64'.decode()<cr>", opts)
2022-11-12 17:39:10 +00:00
-- Illuminate
keymap("n", "<a-n>", '<cmd>lua require"illuminate".next_reference{wrap=true}<cr>', { noremap = true })
keymap("n", "<a-p>", '<cmd>lua require"illuminate".next_reference{reverse=true,wrap=true}<cr>', { noremap = true })