1
0

add changes from work workstation

This commit is contained in:
2026-04-13 19:29:57 +02:00
parent 298e81add0
commit 7cc34cbda4
13 changed files with 319 additions and 51 deletions

View File

@@ -95,6 +95,25 @@ Linting runs automatically on `BufEnter`, `BufWritePost`, and `InsertLeave`.
| ------------ | ------------- | --------------------------------- |
| `<leader>mp` | Normal/Visual | Format file or range |
## Debugging (nvim-dap)
Supports C, C++, Rust (via gdb/rust-gdb) and Go (via delve).
| Keybind | Mode | Description |
| ------------- | ------------- | --------------------------------- |
| `<leader>gdc` | Normal | Continue / Launch |
| `<leader>gdb` | Normal | Toggle breakpoint |
| `<leader>gdB` | Normal | Set conditional breakpoint |
| `<leader>gds` | Normal | Step over |
| `<leader>gdi` | Normal | Step into |
| `<leader>gdo` | Normal | Step out |
| `<leader>gdh` | Normal/Visual | Hover variable under cursor |
| `<leader>gdS` | Normal | Show scopes (all variables) |
| `<leader>gdF` | Normal | Show call stack frames |
| `<leader>gdr` | Normal | Open REPL |
| `<leader>gdl` | Normal | Re-run last debug session |
| `<leader>gdt` | Normal | Terminate session |
## AI (CodeCompanion)
| Keybind | Mode | Description |

View File

@@ -7,7 +7,7 @@ vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entere
vim.wo.number = true
vim.opt.relativenumber = true
vim.w.signcolumn = "yes" -- Keep signcolumn on by default
vim.wo.signcolumn = "yes" -- Keep signcolumn on by default
vim.opt.swapfile = false -- creates a swapfile
vim.opt.undofile = true -- Save undo history
@@ -39,10 +39,8 @@ vim.o.completeopt = "menuone,noinsert,popup,fuzzy"
vim.opt.wildmode = "longest:full,full"
vim.opt.wildoptions = { "pum", "fuzzy" } -- Use a popup menu for cmdline with fuzzy matching
-- vim.keymap.set("i", "<C-Space>", "<C-x><C-o>", { desc = "Trigger LSP completion" })
-- Toggle signature help natively with <C-s> in insert mode (Neovim 0.11+ default)
vim.opt.cursorline = true
vim.opt.termguicolors = true
vim.opt.splitbelow = true -- open new vertical split bottom
vim.opt.splitright = true -- open new horizontal splits right
@@ -86,7 +84,7 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
--
-- Set a keymap to toggle the 'wrap' option
vim.keymap.set("n", "<leader>w", function()
vim.opt.wrap:toggle()
vim.opt.wrap = not vim.opt.wrap:get()
end, { desc = "Toggle line wrapping" })
local uv = vim.uv

View File

@@ -22,7 +22,7 @@ map("n", "N", "Nzzzv", { desc = "Find previous occurence of search" })
map("n", "<Tab>", ":bnext<CR>", { desc = "Switch to next buffer" })
map("n", "<S-Tab>", ":bprev<CR>", { desc = "Switch to previous buffer" })
map("n", "<leader>x", ":bdelete!<CR>", { desc = "Close buffer" })
map("n", "<leader>xb", ":bdelete!<CR>", { desc = "Close buffer" })
map("n", "<leader>b", "<cmd> enew <CR>", { desc = "Open new buffer" })
map("n", "<leader>v", "<C-w>v", { desc = "Split vertical" })

View File

@@ -1,3 +1,36 @@
local git_root_cache = {}
local function get_git_root(path)
local dir = vim.fn.fnamemodify(path, ":h")
if git_root_cache[dir] then
return git_root_cache[dir]
end
local root = vim.fn.systemlist("git -C " .. vim.fn.shellescape(dir) .. " rev-parse --show-toplevel 2>/dev/null")[1]
if vim.v.shell_error ~= 0 or not root or root == "" then
root = false
end
git_root_cache[dir] = root
return root
end
local function git_relative_path(abs_path)
if abs_path == "" then
return "[No Name]"
end
local root = get_git_root(abs_path)
if root then
local rel = abs_path:sub(#root + 2) -- strip root + trailing /
return rel ~= "" and rel or abs_path
end
return abs_path
end
vim.api.nvim_create_autocmd("DirChanged", {
callback = function()
git_root_cache = {}
end,
})
local mru_bufs = {}
-- Initialize with currently listed buffers
@@ -61,10 +94,7 @@ function _G.TabLine()
for _, bufnr in ipairs(valid_bufs) do
local is_current = (bufnr == current_buf)
local name = vim.api.nvim_buf_get_name(bufnr)
if name == "" then
name = "[No Name]"
end
local name = git_relative_path(vim.api.nvim_buf_get_name(bufnr))
local hl = is_current and "%#WildMenu#" or "%#TabLine#"

View File

@@ -17,9 +17,38 @@ require("oil").setup({
view_options = {
show_hidden = true,
},
preview = {
max_width = 0.9,
min_width = { 40, 0.4 },
max_height = 0.9,
min_height = { 5, 0.1 },
},
float = {
max_width = math.floor(vim.o.columns * 0.66),
max_height = math.floor(vim.o.lines * 0.66),
},
keymaps = {
["<Esc><Esc>"] = { "actions.close", mode = "n" },
},
})
vim.keymap.set("n", "<leader>pv", "<cmd>Oil<cr>", { desc = "Open current directory" })
vim.api.nvim_create_autocmd("User", {
pattern = "OilEnter",
callback = vim.schedule_wrap(function(args)
local oil = require("oil")
if vim.api.nvim_get_current_buf() == args.data.buf and oil.get_current_dir() then
require("oil.actions").preview.callback()
end
end),
})
vim.keymap.set("n", "<leader>pv", function()
if vim.o.lines >= 40 and vim.o.columns >= 120 then
require("oil").open_float()
else
require("oil").open()
end
end, { desc = "Open file explorer" })
vim.keymap.set({ "n", "x", "o" }, "<leader>f", require("jump").start, {})
local function get_project_root()

View File

@@ -0,0 +1,158 @@
vim.pack.add({
{ src = "https://codeberg.org/mfussenegger/nvim-dap" },
})
local dap = require("dap")
-- GDB adapter for C/C++ (requires gdb 14.0+)
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "--interpreter=dap", "--eval-command", "set print pretty on" },
}
-- Rust-specific adapter using rust-gdb for pretty-printing Rust types
dap.adapters["rust-gdb"] = {
type = "executable",
command = "rust-gdb",
args = { "--interpreter=dap", "--eval-command", "set print pretty on" },
}
-- Delve adapter for Go (uses delve's built-in DAP mode)
dap.adapters.delve = function(callback, config)
if config.mode == "remote" and config.request == "attach" then
callback({
type = "server",
host = config.host or "127.0.0.1",
port = config.port or "38697",
})
else
callback({
type = "server",
port = "${port}",
executable = {
command = "dlv",
args = { "dap", "-l", "127.0.0.1:${port}", "--log", "--log-output=dap" },
detached = vim.fn.has("win32") == 0,
},
})
end
end
-- C configurations
dap.configurations.c = {
{
name = "Launch",
type = "gdb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
args = function()
local input = vim.fn.input("Arguments: ")
return vim.split(input, " ", { trimempty = true })
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
{
name = "Attach to process",
type = "gdb",
request = "attach",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
pid = function()
local name = vim.fn.input("Executable name (filter): ")
return require("dap.utils").pick_process({ filter = name })
end,
cwd = "${workspaceFolder}",
},
}
dap.configurations.cpp = dap.configurations.c
-- Rust configurations (using rust-gdb for pretty-printed types)
dap.configurations.rust = {
{
name = "Launch",
type = "rust-gdb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file")
end,
args = function()
local input = vim.fn.input("Arguments: ")
return vim.split(input, " ", { trimempty = true })
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
{
name = "Attach to process",
type = "rust-gdb",
request = "attach",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file")
end,
pid = function()
local name = vim.fn.input("Executable name (filter): ")
return require("dap.utils").pick_process({ filter = name })
end,
cwd = "${workspaceFolder}",
},
}
-- Go configurations (using delve)
dap.configurations.go = {
{
type = "delve",
name = "Debug",
request = "launch",
program = "${file}",
},
{
type = "delve",
name = "Debug test",
request = "launch",
mode = "test",
program = "${file}",
},
{
type = "delve",
name = "Debug test (go.mod)",
request = "launch",
mode = "test",
program = "./${relativeFileDirname}",
},
}
-- Breakpoint signs
vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DapBreakpoint", linehl = "", numhl = "" })
vim.fn.sign_define("DapBreakpointCondition", { text = "", texthl = "DapBreakpoint", linehl = "", numhl = "" })
vim.fn.sign_define("DapStopped", { text = "", texthl = "DapStopped", linehl = "DapStopped", numhl = "" })
-- Keybindings
vim.keymap.set("n", "<leader>gdb", dap.toggle_breakpoint, { desc = "Toggle breakpoint" })
vim.keymap.set("n", "<leader>gdB", function()
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
end, { desc = "Conditional breakpoint" })
vim.keymap.set("n", "<leader>gdc", dap.continue, { desc = "Continue / Launch" })
vim.keymap.set("n", "<leader>gds", dap.step_over, { desc = "Step over" })
vim.keymap.set("n", "<leader>gdi", dap.step_into, { desc = "Step into" })
vim.keymap.set("n", "<leader>gdo", dap.step_out, { desc = "Step out" })
vim.keymap.set("n", "<leader>gdr", dap.repl.open, { desc = "Open REPL" })
vim.keymap.set("n", "<leader>gdl", dap.run_last, { desc = "Run last" })
vim.keymap.set("n", "<leader>gdt", dap.terminate, { desc = "Terminate" })
vim.keymap.set("n", "<leader>gdh", function()
require("dap.ui.widgets").hover()
end, { desc = "Hover variable" })
vim.keymap.set("v", "<leader>gdh", function()
require("dap.ui.widgets").hover()
end, { desc = "Hover selection" })
vim.keymap.set("n", "<leader>gdF", function()
require("dap.ui.widgets").centered_float(require("dap.ui.widgets").frames)
end, { desc = "Show frames" })
vim.keymap.set("n", "<leader>gdS", function()
require("dap.ui.widgets").centered_float(require("dap.ui.widgets").scopes)
end, { desc = "Show scopes" })

View File

@@ -3,4 +3,5 @@ require("plugins.tmux")
require("plugins.ui")
require("plugins.formatting")
require("plugins.linting")
require("plugins.debugging")
require("plugins.ai")

View File

@@ -6,24 +6,59 @@ vim.opt.cmdheight = 2 -- more space in the neovim command line for displaying me
vim.pack.add({
{ src = "https://github.com/rose-pine/neovim" },
{ src = "https://github.com/zaldih/themery.nvim" },
{ src = "https://github.com/brenoprata10/nvim-highlight-colors" },
})
require("themery").setup({
-- add the config here
themes = { "rose-pine-dawn", "rose-pine-main" }, -- Your list of installed colorschemes.
livePreview = true, -- Apply theme while picking. Default to true.
})
-- Sync background with tmux rose-pine variant
if vim.env.TMUX then
local variant = vim.fn.system("tmux show-option -gqv @rose_pine_variant"):gsub("%s+", "")
vim.o.background = variant == "dawn" and "light" or "dark"
else
vim.o.background = "dark"
end
vim.cmd.colorscheme("rose-pine")
vim.keymap.set("n", "<leader>tt", function()
local themery = require("themery")
local currentTheme = themery.getCurrentTheme()
if currentTheme and currentTheme.name == "rose-pine-dawn" then
themery.setThemeByName("rose-pine-main", true)
vim.o.background = vim.o.background == "dark" and "light" or "dark"
end, { desc = "Alternate between light and dark mode" })
-- Insert-mode cursor: extmark overlay for full fg+bg control (terminal ignores fg on cursor hl groups)
local function set_icursor_hl()
if vim.o.background == "light" then
vim.api.nvim_set_hl(0, "iCursorChar", { fg = "#fffaf3", bg = "#b4637a" }) -- dawn: surface / love
else
themery.setThemeByName("rose-pine-dawn", true)
vim.api.nvim_set_hl(0, "iCursorChar", { fg = "#1f1d2e", bg = "#eb6f92" }) -- main: surface / love
end
end, { noremap = true, desc = "Alternate between light and dark mode" })
end
set_icursor_hl()
vim.api.nvim_create_autocmd({ "ColorScheme", "OptionSet" }, {
pattern = { "*", "background" },
callback = set_icursor_hl,
})
local icursor_ns = vim.api.nvim_create_namespace("icursor")
local function update_icursor()
vim.api.nvim_buf_clear_namespace(0, icursor_ns, 0, -1)
local r, c = unpack(vim.api.nvim_win_get_cursor(0))
local line = vim.api.nvim_get_current_line()
local char = c < #line and line:sub(c + 1, c + 1) or " "
vim.api.nvim_buf_set_extmark(0, icursor_ns, r - 1, c, {
virt_text = { { char, "iCursorChar" } },
virt_text_pos = "overlay",
})
end
vim.api.nvim_create_autocmd("ModeChanged", { pattern = "*:i*", callback = update_icursor })
vim.api.nvim_create_autocmd("CursorMovedI", { callback = update_icursor })
vim.api.nvim_create_autocmd("ModeChanged", {
pattern = "i*:*",
callback = function()
vim.api.nvim_buf_clear_namespace(0, icursor_ns, 0, -1)
end,
})
require("nvim-highlight-colors").setup()

View File

@@ -50,6 +50,10 @@
"rev": "cf2a288696b03d0934da713d66c6d71557b5c997",
"src": "https://github.com/rose-pine/neovim"
},
"nvim-dap": {
"rev": "45a69eba683a2c448dd9ecfc4de89511f0646b5f",
"src": "https://codeberg.org/mfussenegger/nvim-dap"
},
"nvim-highlight-colors": {
"rev": "e2cb22089cc2358b2b995c09578224f142de6039",
"src": "https://github.com/brenoprata10/nvim-highlight-colors"