2023-03-08 13:06:56 -05:00
|
|
|
-- Keymaps are automatically loaded on the VeryLazy event
|
|
|
|
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
|
|
|
-- Add any additional keymaps here
|
|
|
|
--
|
|
|
|
-- Shorten function name
|
|
|
|
local keymap = vim.keymap.set
|
|
|
|
-- Silent keymap option
|
|
|
|
local opts = { silent = true }
|
|
|
|
|
2023-03-14 14:30:37 -04:00
|
|
|
-- Remap LazyVim
|
|
|
|
keymap("n", "<Leader>l", "<Nop>", opts)
|
|
|
|
keymap("n", "<Leader>lz", "<cmd>:Lazy<cr>", { desc = "Lazy" })
|
|
|
|
|
2023-03-08 13:06:56 -05:00
|
|
|
-- --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",
|
|
|
|
--
|
|
|
|
-- -- Normal --
|
|
|
|
-- -- 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
|
|
|
|
-- 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)
|
|
|
|
--
|
|
|
|
-- Navigate buffers
|
|
|
|
keymap("n", "<M-l>", ":BufferLineCycleNext<CR>", opts)
|
|
|
|
keymap("n", "<M-h>", ":BufferLineCyclePrev<CR>", opts)
|
2023-05-20 13:27:54 -04:00
|
|
|
keymap("i", "<M-l>", ":BufferLineCycleNext<CR>", opts)
|
|
|
|
keymap("i", "<M-h>", ":BufferLineCyclePrev<CR>", opts)
|
|
|
|
keymap("x", "<M-l>", ":BufferLineCycleNext<CR>", opts)
|
|
|
|
keymap("x", "<M-h>", ":BufferLineCyclePrev<CR>", opts)
|
|
|
|
|
2023-03-08 13:06:56 -05:00
|
|
|
keymap("n", "<H>", "<Nop>", opts)
|
|
|
|
keymap("n", "<L>", "<Nop>", opts)
|
|
|
|
keymap("n", "<M-L>", ":BufferLineMoveNext<CR>", opts)
|
|
|
|
keymap("n", "<M-H>", ":BufferLineMovePrev<CR>", opts)
|
|
|
|
for _, mode in ipairs({ "n", "i", "v" }) do
|
|
|
|
vim.keymap.set(mode, "<A-1>", "<Cmd>BufferLineGoToBuffer 1<CR>", { noremap = true, silent = true })
|
|
|
|
vim.keymap.set(mode, "<A-2>", "<Cmd>BufferLineGoToBuffer 2<CR>", { noremap = true, silent = true })
|
|
|
|
vim.keymap.set(mode, "<A-3>", "<Cmd>BufferLineGoToBuffer 3<CR>", { noremap = true, silent = true })
|
|
|
|
vim.keymap.set(mode, "<A-4>", "<Cmd>BufferLineGoToBuffer 4<CR>", { noremap = true, silent = true })
|
|
|
|
vim.keymap.set(mode, "<A-5>", "<Cmd>BufferLineGoToBuffer 5<CR>", { noremap = true, silent = true })
|
|
|
|
end
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- -- Clear highlights
|
|
|
|
-- keymap("n", "<leader>h", "<cmd>nohlsearch<CR>", opts)
|
|
|
|
--
|
2023-03-14 14:30:37 -04:00
|
|
|
-- Close buffers
|
|
|
|
keymap("n", "<M-q>", "<cmd>Bdelete<CR>", opts)
|
|
|
|
keymap("n", "<M-Q>", "<cmd>Bdelete!<CR>", opts)
|
2023-03-08 13:06:56 -05:00
|
|
|
--
|
|
|
|
-- -- Better paste
|
|
|
|
-- keymap("x", "p", '"_dP', opts)
|
|
|
|
--
|
|
|
|
-- -- Insert --
|
|
|
|
-- -- Press jk fast to enter
|
|
|
|
-- --keymap("i", "jk", "<ESC>", opts)
|
|
|
|
--
|
|
|
|
-- -- Visual --
|
|
|
|
-- -- Stay in indent mode
|
|
|
|
-- keymap("v", "<", "<gv", opts)
|
|
|
|
-- keymap("v", ">", ">gv", opts)
|
|
|
|
--
|
2023-05-20 13:27:54 -04:00
|
|
|
-- search with '-', for my LatinAmerican layout
|
2023-03-14 20:51:54 -04:00
|
|
|
keymap("n", "-", "/", opts)
|
|
|
|
keymap("x", "-", "/", opts)
|
2023-03-08 13:06:56 -05:00
|
|
|
--
|
|
|
|
-- -- Plugins --
|
|
|
|
--
|
2023-03-14 20:51:54 -04:00
|
|
|
-- NvimTree
|
2023-05-20 13:27:54 -04:00
|
|
|
-- keymap("n", "<leader>e", ":NvimTreeToggle<CR>", opts)
|
2023-03-08 13:06:56 -05:00
|
|
|
--
|
|
|
|
-- -- Telescope
|
|
|
|
-- keymap("n", "<leader>fa", ":Telescope find_files<CR>", opts)
|
|
|
|
-- keymap("n", "<leader>ff", ":Telescope git_files<CR>", opts)
|
|
|
|
-- keymap("n", "<leader>ft", ":Telescope live_grep<CR>", opts)
|
|
|
|
-- keymap("n", "<leader>fp", ":Telescope projects<CR>", opts)
|
|
|
|
-- keymap("n", "<leader>fb", ":Telescope buffers<CR>", opts)
|
|
|
|
-- keymap("n", "<leader>fs", ":Telescope grep_string<CR>", opts)
|
|
|
|
-- keymap("n", "<leader>fr", ":Telescope oldfiles<CR>", opts)
|
|
|
|
--
|
|
|
|
-- -- Git
|
|
|
|
-- --keymap("n", "<leader>gg", "<cmd>lua _LAZYGIT_TOGGLE()<CR>", opts)
|
|
|
|
--
|
|
|
|
-- -- Comment
|
|
|
|
-- keymap("n", "<leader>/", "<cmd>lua require('Comment.api').toggle_current_linewise()<cr>", opts)
|
|
|
|
-- keymap("x", "<leader>/", '<esc><cmd>lua require("Comment.api").toggle_linewise_op(vim.fn.visualmode())<cr>')
|
|
|
|
--
|
|
|
|
-- -- DAP
|
|
|
|
-- keymap("n", "<F9>", "<cmd>lua require'dap'.toggle_breakpoint()<cr>", opts)
|
|
|
|
-- keymap("n", "<F5>", "<cmd>lua require'dap'.continue()<cr>", opts)
|
|
|
|
-- keymap("n", "<F10>", "<cmd>lua require'dap'.step_over()<cr>", opts)
|
|
|
|
-- keymap("n", "<F11>", "<cmd>lua require'dap'.step_into()<cr>", opts)
|
|
|
|
-- keymap("n", "<F23>", "<cmd>lua require'dap'.step_out()<cr>", opts)
|
|
|
|
-- keymap("n", "<leader>dr", "<cmd>lua require'dap'.repl.toggle()<cr>", opts)
|
|
|
|
-- keymap("n", "<leader>dl", "<cmd>lua require'dap'.run_last()<cr>", opts)
|
|
|
|
-- keymap("n", "<leader>du", "<cmd>lua require'dapui'.toggle()<cr>", opts)
|
|
|
|
-- keymap("n", "<F17>", "<cmd>lua require'dap'.terminate()<cr>", opts) -- Shift+F5
|
|
|
|
--
|
|
|
|
-- ---- Vimspector
|
|
|
|
-- --keymap("n", "<F9>", "<Plug>VimspectorToggleBreakpoint", opts)
|
|
|
|
-- --keymap("n", "<F5>", "<plug>VimspectorContinue", opts)
|
|
|
|
-- --keymap("n", "<F10>", "<Plug>VimspectorStepOver", opts)
|
|
|
|
-- --keymap("n", "<F11>", "<Plug>VimspectorStepInto", opts)
|
|
|
|
-- --keymap("n", "<F23>", "<Plug>VimspectorStepOut", opts)
|
|
|
|
-- --keymap("n", "<F17>", "<cmd>VimspectorReset<cr>", opts) -- Shift+F5
|
|
|
|
-- --keymap("n", "<F41>", "<Plug>VimspectorRestart", opts) -- Ctrl+Shift+F5
|
|
|
|
-- --keymap("n", "<leader>di", "<Plug>VimspectorBalloonEval", opts)
|
|
|
|
--
|
|
|
|
-- -- move.nvim
|
|
|
|
-- keymap('n', '<M-J>', ':MoveLine(1)<cr>', opts)
|
|
|
|
-- keymap('n', '<M-K>', ':MoveLine(-1)<cr>', opts)
|
|
|
|
-- keymap('x', '<M-J>', ':MoveBlock(1)<cr>', opts)
|
|
|
|
-- keymap('x', '<M-K>', ':MoveBlock(-1)<cr>', opts)
|
|
|
|
--
|
2023-03-14 20:51:54 -04:00
|
|
|
-- disable arrow keys
|
|
|
|
keymap("n", "<Right>", "<Nop>", opts)
|
|
|
|
keymap("n", "<Left>", "<Nop>", opts)
|
|
|
|
keymap("n", "<Up>", "<Nop>", opts)
|
|
|
|
keymap("n", "<Down>", "<Nop>", opts)
|
|
|
|
keymap("i", "<Right>", "<Nop>", opts)
|
|
|
|
keymap("i", "<Left>", "<Nop>", opts)
|
|
|
|
keymap("i", "<Up>", "<Nop>", opts)
|
|
|
|
keymap("i", "<Down>", "<Nop>", opts)
|
2023-03-08 13:06:56 -05:00
|
|
|
--
|
|
|
|
-- -- move through wrapped lines
|
|
|
|
-- keymap("n", "j", "gj")
|
|
|
|
-- keymap("n", "k", "gk")
|
|
|
|
--
|
|
|
|
-- -- use Alt + ijkl to move in insert mode
|
|
|
|
-- keymap("i", "<M-l>", "<Right>", opts)
|
|
|
|
-- keymap("i", "<M-h>", "<Left>", opts)
|
|
|
|
-- keymap("i", "<M-j>", "<C-o>gj", opts)
|
|
|
|
-- keymap("i", "<M-k>", "<C-o>gk", opts)
|
|
|
|
--
|
|
|
|
-- local function clean_screen()
|
|
|
|
-- vim.o.number = not vim.o.number;
|
|
|
|
-- --if not vim.diagnostic.get_next() then return end
|
|
|
|
-- if vim.o.number then
|
|
|
|
-- vim.diagnostic.show()
|
|
|
|
-- vim.opt.signcolumn = "yes"
|
|
|
|
-- vim.cmd("syntax on")
|
|
|
|
-- else
|
|
|
|
-- vim.diagnostic.hide()
|
|
|
|
-- vim.opt.signcolumn = "no"
|
|
|
|
-- vim.cmd("syntax off")
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
--
|
|
|
|
-- keymap("n", "<leader>n", clean_screen, opts)
|
2023-06-09 08:10:32 -04:00
|
|
|
|
|
|
|
function vim.getVisualSelection()
|
|
|
|
vim.cmd('noau normal! "vy"')
|
|
|
|
local text = vim.fn.getreg('v')
|
|
|
|
vim.fn.setreg('v', {})
|
|
|
|
|
|
|
|
text = string.gsub(text, "\n", "")
|
|
|
|
if #text > 0 then
|
|
|
|
return text
|
|
|
|
else
|
|
|
|
return ''
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
keymap('v', '<space>sw', function()
|
|
|
|
local tb = require('telescope.builtin')
|
|
|
|
local text = vim.getVisualSelection()
|
|
|
|
tb.live_grep({ default_text = text })
|
|
|
|
end, opts)
|
|
|
|
|
2023-03-08 13:06:56 -05:00
|
|
|
--
|
|
|
|
-- local function otherkeymaps()
|
|
|
|
-- local ok
|
|
|
|
-- local wk
|
|
|
|
-- local gs
|
|
|
|
-- ok, wk = pcall(require, "which-key")
|
|
|
|
-- if not ok then
|
|
|
|
-- return
|
|
|
|
-- end
|
|
|
|
-- ok, gs = pcall(require, "gitsigns")
|
|
|
|
-- if not ok then
|
|
|
|
-- return
|
|
|
|
-- end
|
|
|
|
-- wk.register({
|
|
|
|
-- g = {
|
|
|
|
-- name = "gitsigns",
|
|
|
|
-- p = { "<cmd>Gitsigns preview_hunk<cr>", "Preview hunk" },
|
|
|
|
-- b = { function() gs.blame_line{full=false} end, "Blame line (short)" },
|
|
|
|
-- B = { function() gs.blame_line{full=true} end, "Blame line (full)" }
|
|
|
|
-- },
|
|
|
|
-- prefix = "<leader>"
|
|
|
|
-- })
|
|
|
|
-- end
|
2023-06-08 16:38:02 -04:00
|
|
|
-- keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.format()<cr>", opts)
|
|
|
|
-- keymap("v", "<leader>lf", "<esc><cmd>'<,'>lua vim.lsp.buf.format{ async = true }<cr>", opts)
|
|
|
|
-- keymap("x", "<leader>lf", "<esc><cmd>'<,'>lua vim.lsp.buf.format{ async = true }<cr>", opts)
|
2023-03-08 13:06:56 -05:00
|
|
|
--
|
|
|
|
-- otherkeymaps()
|