128 lines
3.7 KiB
Lua
128 lines
3.7 KiB
Lua
-- 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 }
|
|
|
|
-- Remap LazyVim
|
|
keymap("n", "<Leader>l", "<Nop>", opts)
|
|
keymap("n", "<Leader>lz", "<cmd>:Lazy<cr>", { desc = "Lazy" })
|
|
|
|
-- Navigate buffers
|
|
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
|
|
|
|
keymap("n", "<H>", "<Nop>", opts)
|
|
keymap("n", "<L>", "<Nop>", opts)
|
|
keymap("n", "<M-L>", ":BufferLineMoveNext<CR>", opts)
|
|
keymap("n", "<M-H>", ":BufferLineMovePrev<CR>", opts)
|
|
|
|
function go_to_buffer(buffer)
|
|
return function()
|
|
require("bufferline").go_to(buffer, true)
|
|
end
|
|
end
|
|
|
|
for _, mode in ipairs({ "n", "i", "v" }) do
|
|
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 })
|
|
end
|
|
|
|
-- Clear highlights
|
|
keymap("n", "<leader>h", "<cmd>nohlsearch<CR>", opts)
|
|
|
|
-- Close buffers
|
|
keymap("n", "<M-q>", "<cmd>Bdelete<CR>", opts)
|
|
keymap("n", "<M-Q>", "<cmd>Bdelete!<CR>", opts)
|
|
|
|
-- search with '-', for my LatinAmerican layout
|
|
keymap("n", "-", "/", opts)
|
|
keymap("x", "-", "/", opts)
|
|
|
|
-- 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)
|
|
|
|
local function clean_screen()
|
|
vim.o.number = not vim.o.number
|
|
if vim.o.number then
|
|
if vim.diagnostic.get_next() then
|
|
pcall(vim.diagnostic.show)
|
|
end
|
|
vim.opt.signcolumn = "yes"
|
|
vim.g.miniindentscope_disable = false
|
|
MiniIndentscope.draw()
|
|
vim.cmd("syntax on")
|
|
vim.cmd("IBLEnable")
|
|
else
|
|
MiniIndentscope.undraw()
|
|
vim.g.miniindentscope_disable = true
|
|
if vim.diagnostic.get_next() then
|
|
vim.diagnostic.hide()
|
|
end
|
|
vim.opt.signcolumn = "no"
|
|
vim.cmd("syntax off")
|
|
vim.cmd("IBLDisable")
|
|
end
|
|
end
|
|
|
|
keymap("n", "<leader>n", clean_screen, opts)
|
|
|
|
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("n", "<leader>ghl", "<cmd>RepoLink<CR>", opts)
|
|
keymap("x", "<leader>ghl", ":RepoLink<CR>", opts)
|
|
|
|
keymap("v", "<space>sw", function()
|
|
local tb = require("telescope.builtin")
|
|
local text = vim.getVisualSelection()
|
|
tb.live_grep({ default_text = text })
|
|
end, opts)
|
|
|
|
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")
|
|
|
|
keymap("n", "<leader>j", vim.diagnostic.goto_next, opts)
|
|
keymap("n", "<leader>k", vim.diagnostic.goto_prev, opts)
|
|
|
|
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>")
|
|
|
|
vim.keymap.set("n", "K", require("noice.lsp").hover, { noremap = true, silent = true })
|
|
|
|
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" })
|