Public Access
rewrite and additions
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
local map = vim.keymap.set
|
||||
local silent = { silent = true }
|
||||
|
||||
-- Visual line navigation
|
||||
for _, mode in ipairs({ "n", "v" }) do
|
||||
map(mode, "j", "gj", silent)
|
||||
map(mode, "k", "gk", silent)
|
||||
end
|
||||
|
||||
-- Hover: diagnostics on current line if any, else LSP hover
|
||||
map("n", "K", function()
|
||||
local line = vim.api.nvim_win_get_cursor(0)[1] - 1
|
||||
if #vim.diagnostic.get(0, { lnum = line }) > 0 then
|
||||
vim.diagnostic.open_float()
|
||||
else
|
||||
vim.lsp.buf.hover()
|
||||
end
|
||||
end, { desc = "Hover (diagnostic or LSP)" })
|
||||
|
||||
-- LSP
|
||||
map("n", "<leader>gf",
|
||||
function() require("conform").format({ lsp_format = "fallback" }) end,
|
||||
{ desc = "Format buffer" })
|
||||
map("n", "<leader>gd", vim.lsp.buf.definition)
|
||||
map("n", "<leader>gD", vim.lsp.buf.declaration)
|
||||
map("n", "<leader>ca", vim.lsp.buf.code_action, { desc = "Code Action" })
|
||||
map("n", "<leader>rn", vim.lsp.buf.rename, { desc = "Rename symbol" })
|
||||
|
||||
-- Trouble
|
||||
map("n", "<leader>xx", "<cmd>Trouble diagnostics toggle focus=true<cr>",
|
||||
{ desc = "Diagnostics (Trouble)" })
|
||||
map("n", "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0 focus=true<cr>",
|
||||
{ desc = "Buffer Diagnostics (Trouble)" })
|
||||
map("n", "<leader>xt", "<cmd>Trouble todo toggle<cr>", { desc = "Todo (Trouble)" })
|
||||
|
||||
-- Flash
|
||||
map({ "n", "x", "o" }, "s", function() require("flash").jump() end, { desc = "Flash" })
|
||||
map({ "n", "x", "o" }, "S", function() require("flash").treesitter() end, { desc = "Flash Treesitter" })
|
||||
map("o", "r", function() require("flash").remote() end, { desc = "Remote Flash" })
|
||||
|
||||
-- Pickers / files
|
||||
map("n", "<C-f>", "<cmd>Pick files<cr>")
|
||||
map("n", "<C-g>", "<cmd>Pick grep_live<cr>")
|
||||
map("n", "<C-h>", "<cmd>Pick help<cr>")
|
||||
map("n", "<C-e>", "<cmd>Oil<cr>")
|
||||
|
||||
-- DAP
|
||||
map("n", "<leader>duo", function() require("dapui").open() end)
|
||||
map("n", "<leader>duc", function() require("dapui").close() end)
|
||||
map("n", "<leader>dbp", function() require("dap").toggle_breakpoint() end)
|
||||
map("n", "<leader>drc", function() require("dap").run_to_cursor() end)
|
||||
|
||||
-- Barbar
|
||||
local bk = vim.fn.has("macunix") == 1 and "M" or "A"
|
||||
local bar = {
|
||||
[","] = "BufferPrevious", ["."] = "BufferNext",
|
||||
["<"] = "BufferMovePrevious", [">"] = "BufferMoveNext",
|
||||
["p"] = "BufferPin", ["w"] = "BufferClose",
|
||||
["0"] = "BufferLast",
|
||||
}
|
||||
for k, cmd in pairs(bar) do
|
||||
map("n", ("<%s-%s>"):format(bk, k), ("<cmd>%s<cr>"):format(cmd), silent)
|
||||
end
|
||||
for i = 1, 9 do
|
||||
map("n", ("<%s-%d>"):format(bk, i), ("<cmd>BufferGoto %d<cr>"):format(i), silent)
|
||||
end
|
||||
map("n", "<C-p>", "<cmd>BufferPick<cr>", silent)
|
||||
map("n", "<C-s-p>", "<cmd>BufferPickDelete<cr>", silent)
|
||||
|
||||
-- Spell
|
||||
map("n", "<leader>sc", function()
|
||||
vim.wo.spell = not vim.wo.spell
|
||||
vim.notify("Spell: " .. (vim.wo.spell and "ON" or "OFF"))
|
||||
end, { desc = "Toggle spell" })
|
||||
|
||||
map("n", "<leader>sl", function()
|
||||
local cur = vim.opt.spelllang:get()[1] or ""
|
||||
local new = cur == "en" and "de" or "en"
|
||||
vim.opt.spelllang = new
|
||||
vim.notify("Spell lang: " .. new)
|
||||
end, { desc = "Switch spell language" })
|
||||
Reference in New Issue
Block a user