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
|
|
|
-- Navigate buffers
|
2023-07-17 11:08:44 -04:00
|
|
|
for _, mode in ipairs({ "n", "i", "x" }) do
|
|
|
|
keymap(mode, "<M-l>", "<cmd>BufferLineCycleNext<CR>", opts)
|
|
|
|
keymap(mode, "<M-h>", "<cmd>BufferLineCyclePrev<CR>", opts)
|
|
|
|
end
|
2023-05-20 13:27:54 -04:00
|
|
|
|
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)
|
2024-09-23 15:37:07 -04:00
|
|
|
|
|
|
|
function go_to_buffer(buffer)
|
|
|
|
return function()
|
|
|
|
require("bufferline").go_to(buffer, true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-03-08 13:06:56 -05:00
|
|
|
for _, mode in ipairs({ "n", "i", "v" }) do
|
2024-09-23 15:37:07 -04:00
|
|
|
for i = 1, 8 do
|
|
|
|
vim.keymap.set(mode, "<A-" .. i .. ">", go_to_buffer(i), { noremap = true, silent = true })
|
|
|
|
end
|
|
|
|
vim.keymap.set(mode, "<A-9>", go_to_buffer(-1), { noremap = true, silent = true })
|
2023-03-08 13:06:56 -05:00
|
|
|
end
|
2023-06-09 20:53:37 -04:00
|
|
|
|
|
|
|
-- 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-06-09 20:53:37 -04:00
|
|
|
|
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-06-09 20:53:37 -04:00
|
|
|
|
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-06-09 20:53:37 -04:00
|
|
|
|
|
|
|
local function clean_screen()
|
|
|
|
vim.o.number = not vim.o.number
|
|
|
|
if vim.o.number then
|
2024-06-19 16:44:47 -04:00
|
|
|
if vim.diagnostic.get_next() then
|
2023-11-22 20:10:00 -05:00
|
|
|
pcall(vim.diagnostic.show)
|
|
|
|
end
|
2023-06-09 20:53:37 -04:00
|
|
|
vim.opt.signcolumn = "yes"
|
2023-06-12 16:41:51 -04:00
|
|
|
vim.g.miniindentscope_disable = false
|
|
|
|
MiniIndentscope.draw()
|
2023-06-09 20:53:37 -04:00
|
|
|
vim.cmd("syntax on")
|
2023-11-22 20:10:00 -05:00
|
|
|
vim.cmd("IBLEnable")
|
2023-06-09 20:53:37 -04:00
|
|
|
else
|
2023-06-12 16:41:51 -04:00
|
|
|
MiniIndentscope.undraw()
|
|
|
|
vim.g.miniindentscope_disable = true
|
2024-06-19 16:44:47 -04:00
|
|
|
if vim.diagnostic.get_next() then
|
2023-11-22 20:10:00 -05:00
|
|
|
vim.diagnostic.hide()
|
|
|
|
end
|
2023-06-09 20:53:37 -04:00
|
|
|
vim.opt.signcolumn = "no"
|
|
|
|
vim.cmd("syntax off")
|
2023-11-22 20:10:00 -05:00
|
|
|
vim.cmd("IBLDisable")
|
2023-06-09 20:53:37 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
keymap("n", "<leader>n", clean_screen, opts)
|
2023-06-09 08:10:32 -04:00
|
|
|
|
|
|
|
function vim.getVisualSelection()
|
2023-06-09 20:53:37 -04:00
|
|
|
vim.cmd('noau normal! "vy"')
|
|
|
|
local text = vim.fn.getreg("v")
|
|
|
|
vim.fn.setreg("v", {})
|
2023-06-09 08:10:32 -04:00
|
|
|
|
2023-06-09 20:53:37 -04:00
|
|
|
text = string.gsub(text, "\n", "")
|
|
|
|
if #text > 0 then
|
|
|
|
return text
|
|
|
|
else
|
|
|
|
return ""
|
|
|
|
end
|
2023-06-09 08:10:32 -04:00
|
|
|
end
|
|
|
|
|
2024-06-19 16:45:33 -04:00
|
|
|
keymap("n", "<leader>ghl", "<cmd>RepoLink<CR>", opts)
|
|
|
|
keymap("x", "<leader>ghl", ":RepoLink<CR>", opts)
|
|
|
|
|
2023-06-09 20:53:37 -04:00
|
|
|
keymap("v", "<space>sw", function()
|
|
|
|
local tb = require("telescope.builtin")
|
|
|
|
local text = vim.getVisualSelection()
|
|
|
|
tb.live_grep({ default_text = text })
|
2023-06-09 08:10:32 -04:00
|
|
|
end, opts)
|
2023-06-12 09:07:22 -04:00
|
|
|
|
|
|
|
keymap("n", "<S-ScrollWheelDown>", "5zl")
|
|
|
|
keymap("n", "<S-ScrollWheelUp>", "5zh")
|
|
|
|
keymap("i", "<S-ScrollWheelDown>", "5zl")
|
|
|
|
keymap("i", "<S-ScrollWheelUp>", "5zh")
|
|
|
|
keymap("x", "<S-ScrollWheelDown>", "5zl")
|
|
|
|
keymap("x", "<S-ScrollWheelUp>", "5zh")
|
2023-11-22 20:10:00 -05:00
|
|
|
|
|
|
|
keymap("n", "<leader>j", vim.diagnostic.goto_next, opts)
|
|
|
|
keymap("n", "<leader>k", vim.diagnostic.goto_prev, opts)
|
2024-06-19 16:46:33 -04:00
|
|
|
|
|
|
|
keymap("n", "<F9>", "<cmd>DapToggleBreakpoint<CR>")
|
|
|
|
keymap("n", "<F5>", "<cmd>DapContinue<CR>")
|
|
|
|
keymap("n", "<F10>", "<cmd>DapStepOver<CR>")
|
|
|
|
keymap("n", "<F11>", "<cmd>DapStepInto<CR>")
|
|
|
|
keymap("n", "<S-F11>", "<cmd>DapStepOut<CR>")
|
2024-07-07 16:31:55 -04:00
|
|
|
|
|
|
|
vim.keymap.set("n", "K", require("noice.lsp").hover, { noremap = true, silent = true })
|
2024-09-23 15:59:13 -04:00
|
|
|
|
2024-11-08 17:02:52 -05:00
|
|
|
-- local function dismiss_notifications()
|
|
|
|
-- require("notify").dismiss({ silent = true, pending = true })
|
|
|
|
-- vim.cmd("noh")
|
|
|
|
-- end
|
|
|
|
-- vim.keymap.set("n", "<Esc>", dismiss_notifications, { desc = "Dismiss notifications" })
|