131 lines
7.5 KiB
Lua
131 lines
7.5 KiB
Lua
--[[
|
||
|
||
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣷⣦⣄⡀
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡀
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡀
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠚⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠗⢀
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣄⡉⠓⠦⣌⡙⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⢋⣡⠴⠚⢉⣠⣤⣀
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⣶⣿⣿⣿⣿⣿⣷⣦⣄⡉⠓⠦⣌⡙⠻⢿⣿⣿⣿⣿⣿⣿⡿⠟⢋⣡⠴⠚⢉⣠⣴⣾⣿⣿⣿⣿⣿⣶⣤
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠐⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠓⠦⣌⡙⠻⠟⢋⣡⠴⠚⢉⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⠂
|
||
⠀⠀⠀⠀⢀⣠⣴⣆⡈⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠃⠘⢉⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢁⣰⣦⣄⡀
|
||
⠀⠀⠐⠾⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠷⠂
|
||
⠀⢸⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⡇
|
||
⠀⢸⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⡇
|
||
⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⡆⢰⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||
⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠃⠘⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⡇⢸⣿⣿⣿⣿⠿⠛⠉
|
||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⡇⢸⠿⠛⠉
|
||
|
||
__ _ _
|
||
/ _|___ ___| |_ __ _ ___| | __
|
||
| ||_ /____/ __| __/ _` |/ __| |/ /
|
||
| _/ /_____\__ \ || (_| | (__| <
|
||
|_|/___| |___/\__\__,_|\___|_|\_\
|
||
|
||
Neovim v0.12 configuration
|
||
(C) Frank Zechert 2026
|
||
]]
|
||
|
||
local map = vim.keymap.set
|
||
|
||
-- pressing ESC twices leaves terminal mode
|
||
map("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit Terminal Mode" })
|
||
|
||
-- pressing ESC removes search highlights
|
||
map("n", "<Esc>", "<Cmd>nohlsearch<CR>", { desc = "Remove search result highlights" })
|
||
|
||
-- Smart buffer switch
|
||
-- switch to the alternative buffer ("#"), if not available, switch to the
|
||
-- previous buffer, if not possible, switch to the next buffer
|
||
local function smart_buffer_switch(current)
|
||
local alternative = vim.fn.bufnr("#")
|
||
local buffers = vim.fn.getbufinfo({ buflisted = 1 })
|
||
local current_index = nil
|
||
for index, buffer in ipairs(buffers) do
|
||
if buffer.bufnr == current then
|
||
current_index = index
|
||
break
|
||
end
|
||
end
|
||
-- try to switch to alternate buffer
|
||
if alternative > 0 and vim.fn.buflisted(alternative) == 1 and alternative ~= current then
|
||
vim.api.nvim_set_current_buf(alternative)
|
||
-- try to switch to previous buffer
|
||
elseif current_index and current_index > 1 then
|
||
vim.api.nvim_set_current_buf(buffers[current_index - 1].bufnr)
|
||
-- try to switch to next buffer
|
||
elseif current_index and current_index < #buffers then
|
||
vim.api.nvim_set_current_buf(buffers[current_index + 1].bufnr)
|
||
end
|
||
end
|
||
|
||
local function smart_buffer_delete()
|
||
local current = vim.api.nvim_get_current_buf()
|
||
smart_buffer_switch(current)
|
||
vim.cmd(":confirm bdelete " .. current)
|
||
end
|
||
|
||
local function smart_buffer_wipeout()
|
||
local current = vim.api.nvim_get_current_buf()
|
||
smart_buffer_switch(current)
|
||
vim.cmd(":confirm bwipeout " .. current)
|
||
end
|
||
|
||
local function delete_other_buffers()
|
||
local current = vim.api.nvim_get_current_buf()
|
||
for _, buffer in ipairs(vim.api.nvim_list_buffers()) do
|
||
if buffer ~= current and vim.bo[buffer].buflisted and not vim.bo[buffer].modified then
|
||
vim.api.nvim_buf_delete(buffer, {})
|
||
end
|
||
end
|
||
end
|
||
|
||
local function wipeout_other_buffers()
|
||
local current = vim.api.nvim_get_current_buf()
|
||
for _, buffer in ipairs(vim.api.nvim_list_buffers()) do
|
||
if buffer ~= current and vim.bo[buffer].buflisted and not vim.bo[buffer].modified then
|
||
vim.cmd("bwipeout " .. buffer)
|
||
end
|
||
end
|
||
end
|
||
|
||
map("n", "<leader>bd", smart_buffer_delete, { desc = "Close Current Buffer" })
|
||
map("n", "<leader>bw", smart_buffer_wipeout, { desc = "Wipeout Current Buffer" })
|
||
map("n", "<leader>bD", delete_other_buffers, { desc = "Close All Other Buffers" })
|
||
map("n", "<leader>bW", wipeout_other_buffers, { desc = "Wipeout All Other Buffers" })
|
||
|
||
-- Trouble Keybinds
|
||
-- open diagnostics window
|
||
map("n", "<leader>xd", [[<Cmd>Trouble diagnostics toggle focus=false filter.buf=0<CR>]], { desc = "Toggle diagnostic message for current buffer" })
|
||
map("n", "<leader>xD", [[<Cmd>Trouble diagnostics toggle focus=false<CR>]], { desc = "Toggle diagnostic message for project" })
|
||
map("n", "grl", [[<Cmd>Trouble lsp toggle focus=false win.position=right win.relative=win pinned=true<CR>]], { desc = "Open LSP Info" })
|
||
map("n", "grt", [[<Cmd>Trouble symbols toggle focus=false<CR>]], { desc = "Open TreeSitter Symbols" })
|
||
map("n", "grs", [[<Cmd>Trouble lsp_document_symbols toggle focus=false<CR>]], { desc = "Open LSP Document Symbols", silent = true, noremap = true })
|
||
map("n", "grD", [[<Cmd>Trouble lsp_declarations toggle<CR>]], { desc = "Show LSP Declarations", silent = true, noremap = true })
|
||
map("n", "grd", [[<Cmd>Trouble lsp_definitions toggle<CR>]], { desc = "Show LSP Definitions", silent = true, noremap = true })
|
||
map("n", "gri", [[<Cmd>Trouble lsp_implementations toggle<CR>]], { desc = "Show LSP Implementations", silent = true, noremap = true })
|
||
map("n", "grc", [[<Cmd>Trouble lsp_incoming_calls toggle<CR>]], { desc = "Show LSP incoming calls", silent = true, noremap = true })
|
||
map("n", "grC", [[<Cmd>Trouble lsp_outgoing_calls toggle<CR>]], { desc = "Show LSP outgoing calls", silent = true, noremap = true })
|
||
map("n", "grr", [[<Cmd>Trouble lsp_references toggle<CR>]], { desc = "Show LSP references", silent = true, noremap = true })
|
||
map("n", "<leader>xq", [[<Cmd>Trouble qflist toggle focus=false<CR>]], { desc = "Show Quickfix List" })
|
||
map("n", "<leader>xl", [[<Cmd>Trouble loclist toggle focus=false<CR>]], { desc = "Show Location List" })
|
||
map("n", "grn", vim.lsp.buf.rename, { desc = "Rename", silent = true, noremap = true })
|
||
map({"n", "v"}, "gra", vim.lsp.buf.code_action, { desc = "Action", silent = true, noremap = true })
|
||
map("n", "gl", vim.diagnostic.open_float, { desc = "Open Diagnostic Float" })
|
||
map("n", "grx", vim.lsp.codelens.run, { desc = "Run Codelens Operation" })
|
||
|
||
-- Toggle Codelens
|
||
map("n", "<leader>tc", function()
|
||
vim.g.codelens_enabled = not vim.g.codelens_enabled
|
||
vim.lsp.codelens.enable(vim.g.codelens_enabled)
|
||
end, { desc = "Toggle Code Lens" })
|
||
|
||
-- Open Signature Help
|
||
map("i", "<C-s>", function()
|
||
vim.lsp.buf.signature_help()
|
||
end, { desc = "Show signature help" })
|