58 lines
2.6 KiB
Lua
58 lines
2.6 KiB
Lua
-- Plugin-independent maps. Plugin maps live in their spec's `keys`.
|
|
local map = vim.keymap.set
|
|
|
|
map({ "n", "x" }, "<leader>y", '"+y', { desc = "Yank to system clipboard" })
|
|
map({ "n", "x" }, "<leader>p", '"+p', { desc = "Paste from system clipboard" })
|
|
|
|
-- Diagnostic jumps without [ and ] (QWERTZ). The default [d / ]d still work.
|
|
map("n", "<leader>n", function()
|
|
vim.diagnostic.jump({ count = vim.v.count1, float = true })
|
|
end, { desc = "Next diagnostic" })
|
|
map("n", "<leader>N", function()
|
|
vim.diagnostic.jump({ count = -vim.v.count1, float = true })
|
|
end, { desc = "Previous diagnostic" })
|
|
|
|
-- Buffer and window navigation
|
|
map("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
|
|
map("n", "<S-l>", "<cmd>bnext<cr>", { desc = "Next buffer" })
|
|
for _, dir in ipairs({ "h", "j", "k", "l" }) do
|
|
map("n", "<C-" .. dir .. ">", "<C-w>" .. dir, { desc = "Window " .. dir })
|
|
map("t", "<C-" .. dir .. ">", "<C-\\><C-n><C-w>" .. dir, { desc = "Window " .. dir })
|
|
end
|
|
map("n", "<C-Up>", "<cmd>resize +2<cr>", { desc = "Window taller" })
|
|
map("n", "<C-Down>", "<cmd>resize -2<cr>", { desc = "Window shorter" })
|
|
map("n", "<C-Left>", "<cmd>vertical resize -2<cr>", { desc = "Window narrower" })
|
|
map("n", "<C-Right>", "<cmd>vertical resize +2<cr>", { desc = "Window wider" })
|
|
|
|
-- Editing helpers
|
|
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" })
|
|
map("n", "<C-d>", "<C-d>zz", { desc = "Half page down" })
|
|
map("n", "<C-u>", "<C-u>zz", { desc = "Half page up" })
|
|
map("x", "J", ":m '>+1<cr>gv=gv", { desc = "Move selection down" })
|
|
map("x", "K", ":m '<-2<cr>gv=gv", { desc = "Move selection up" })
|
|
map("x", "<", "<gv", { desc = "Indent left" })
|
|
map("x", ">", ">gv", { desc = "Indent right" })
|
|
map("x", "<leader>P", '"_dP', { desc = "Paste keep register" })
|
|
|
|
-- Selection by treesitter node, LSP selection range as fallback
|
|
map({ "n", "x", "o" }, "<A-o>", function()
|
|
if vim.treesitter.get_parser(nil, nil, { error = false }) then
|
|
require("vim.treesitter._select").select_parent(vim.v.count1)
|
|
else
|
|
vim.lsp.buf.selection_range(vim.v.count1)
|
|
end
|
|
end, { desc = "Select parent node" })
|
|
map({ "n", "x", "o" }, "<A-i>", function()
|
|
if vim.treesitter.get_parser(nil, nil, { error = false }) then
|
|
require("vim.treesitter._select").select_child(vim.v.count1)
|
|
else
|
|
vim.lsp.buf.selection_range(-vim.v.count1)
|
|
end
|
|
end, { desc = "Select child node" })
|
|
|
|
map("n", "<leader>fl", function()
|
|
local value = vim.fn.fnamemodify(vim.fn.expand("%"), ":~:.") .. ":" .. vim.fn.line(".")
|
|
vim.fn.setreg("+", value)
|
|
vim.notify("Copied " .. value)
|
|
end, { desc = "Copy path:line" })
|