97 lines
3.2 KiB
Lua
97 lines
3.2 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
|
|
keymap("n", "<M-l>", ":BufferLineCycleNext<CR>", opts)
|
|
keymap("n", "<M-h>", ":BufferLineCyclePrev<CR>", opts)
|
|
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)
|
|
|
|
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)
|
|
|
|
-- 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 not vim.diagnostic.get_next() then return end
|
|
if vim.o.number then
|
|
vim.diagnostic.show()
|
|
vim.opt.signcolumn = "yes"
|
|
vim.cmd("syntax on")
|
|
vim.cmd("IndentBlanklineEnable")
|
|
else
|
|
vim.diagnostic.hide()
|
|
vim.opt.signcolumn = "no"
|
|
vim.cmd("syntax off")
|
|
vim.cmd("IndentBlanklineDisable")
|
|
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("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")
|