From a5e8bbeb9d79d905a193e95a39acd29bc37e6c66 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Wed, 16 Sep 2026 08:47:13 +0200 Subject: Updated dotfiles --- neovim/.config/nvim/lua/config/autocmds.lua | 43 +++++ neovim/.config/nvim/lua/config/dap_node.lua | 88 +++++++++++ neovim/.config/nvim/lua/config/keymaps.lua | 12 ++ neovim/.config/nvim/lua/config/options.lua | 6 + neovim/.config/nvim/lua/config/project_run.lua | 151 ++++++++++++++++++ neovim/.config/nvim/lua/plugins/claude-code.lua | 1 + neovim/.config/nvim/lua/plugins/colorscheme.lua | 8 + neovim/.config/nvim/lua/plugins/dap-python.lua | 71 +++++++++ neovim/.config/nvim/lua/plugins/dap.lua | 181 ++++++++++++++++++++++ neovim/.config/nvim/lua/plugins/editing.lua | 10 -- neovim/.config/nvim/lua/plugins/fuzzyfinder.lua | 36 ++++- neovim/.config/nvim/lua/plugins/git.lua | 5 +- neovim/.config/nvim/lua/plugins/indent-detect.lua | 8 + neovim/.config/nvim/lua/plugins/langs.lua | 14 -- neovim/.config/nvim/lua/plugins/overseer.lua | 57 +++++++ neovim/.config/nvim/lua/plugins/statusline.lua | 24 +-- neovim/.config/nvim/lua/plugins/toggleterm.lua | 18 +++ neovim/.config/nvim/lua/plugins/which-key.lua | 17 ++ 18 files changed, 697 insertions(+), 53 deletions(-) create mode 100644 neovim/.config/nvim/lua/config/dap_node.lua create mode 100644 neovim/.config/nvim/lua/config/project_run.lua create mode 100644 neovim/.config/nvim/lua/plugins/dap-python.lua create mode 100644 neovim/.config/nvim/lua/plugins/dap.lua create mode 100644 neovim/.config/nvim/lua/plugins/indent-detect.lua delete mode 100644 neovim/.config/nvim/lua/plugins/langs.lua create mode 100644 neovim/.config/nvim/lua/plugins/overseer.lua create mode 100644 neovim/.config/nvim/lua/plugins/toggleterm.lua create mode 100644 neovim/.config/nvim/lua/plugins/which-key.lua (limited to 'neovim/.config/nvim/lua') diff --git a/neovim/.config/nvim/lua/config/autocmds.lua b/neovim/.config/nvim/lua/config/autocmds.lua index 7bc4f6b..e9ebe04 100644 --- a/neovim/.config/nvim/lua/config/autocmds.lua +++ b/neovim/.config/nvim/lua/config/autocmds.lua @@ -13,6 +13,49 @@ vim.api.nvim_create_autocmd("BufWritePre", { callback = strip_trailing_whitespace, }) +-- Project-local config: search upward from cwd for a .nvim.lua, the same +-- nearest-ancestor pattern LSP root-dir detection uses, so it's found +-- regardless of exactly which subdirectory Neovim's cwd is or how you got +-- there (:cd, opening a file, session restore, ...) - unlike core 'exrc' +-- (deliberately left off in options.lua), which only ever checks the +-- literal cwd once at startup. +local sourced_project_configs = {} + +local function source_project_config() + local found = vim.fs.find(".nvim.lua", { + upward = true, + path = vim.fn.getcwd(), + stop = vim.env.HOME, + })[1] + if not found or sourced_project_configs[found] then + return + end + + -- vim.secure.read is the same trust mechanism 'exrc' itself uses: prompts + -- on first encounter, honors ~/.local/state/nvim/trust, :trust still + -- manages the allowlist unchanged. Returns nil (no prompt shown again) + -- for a file previously denied. + local content = vim.secure.read(found) + if not content then + return + end + sourced_project_configs[found] = true + + local chunk, load_err = load(content, "@" .. found) + if not chunk then + vim.notify("Error loading " .. found .. ":\n" .. load_err, vim.log.levels.ERROR) + return + end + local ok, run_err = pcall(chunk) + if not ok then + vim.notify("Error running " .. found .. ":\n" .. run_err, vim.log.levels.ERROR) + end +end + +vim.api.nvim_create_autocmd({ "VimEnter", "DirChanged" }, { + callback = source_project_config, +}) + -- Note: the colorscheme (with its "desert" fallback) is applied from -- lua/plugins/colorscheme.lua's own `config` function, not here — under -- lazy.nvim that's the natural place to react to "the plugin is now loaded". diff --git a/neovim/.config/nvim/lua/config/dap_node.lua b/neovim/.config/nvim/lua/config/dap_node.lua new file mode 100644 index 0000000..0fb6890 --- /dev/null +++ b/neovim/.config/nvim/lua/config/dap_node.lua @@ -0,0 +1,88 @@ +-- JavaScript/TypeScript launch configs, wired to the js-debug-adapter +-- (Microsoft's vscode-js-debug, bundled by Mason as a standalone +-- multi-session DAP server) that dap.lua's mason-nvim-dap ensure_installed +-- installs. +-- +-- There's no nvim-dap-python equivalent for this: the one community plugin +-- for it (mxsdev/nvim-dap-vscode-js) hardcodes the older +-- `out/src/vsDebugServer.js` vscode-js-debug build layout, which doesn't +-- match what Mason's js-debug-adapter package actually installs +-- (`js-debug/src/dapDebugServer.js`) - so this resolves the Mason path +-- directly instead, same approach as dap-python.lua's debugpy_path. +-- +-- Lives under lua/config/ rather than lua/plugins/ (and is required +-- eagerly from dap.lua's config()) because it isn't an installable plugin +-- itself, just adapter/config wiring - same reason project_run.lua lives +-- here instead of there. +-- +-- js-debug-adapter is a multi-session server: debugging a script that +-- spawns a worker thread arrives as a `startDebugging` reverse request +-- rather than a second top-level session. nvim-dap's core (dap/session.lua) +-- already handles that natively, so no extra plugin is needed for it either. +local M = {} + +local function configurations() + return { + { + type = "pwa-node", + request = "launch", + name = "Launch file", + program = "${file}", + cwd = "${workspaceFolder}", + }, + { + type = "pwa-node", + request = "attach", + name = "Attach to process", + processId = require("dap.utils").pick_process, + cwd = "${workspaceFolder}", + }, + } +end + +function M.setup() + local registry = require("mason-registry") + local pkg = registry.get_package("js-debug-adapter") + + local function register() + local entrypoint = pkg:get_install_path() .. "/js-debug/src/dapDebugServer.js" + + require("dap").adapters["pwa-node"] = { + type = "server", + host = "localhost", + port = "${port}", + executable = { + command = "node", + args = { entrypoint, "${port}" }, + }, + } + + local dap = require("dap") + for _, filetype in ipairs({ "javascript", "typescript", "javascriptreact", "typescriptreact" }) do + dap.configurations[filetype] = configurations() + end + end + + if pkg:is_installed() then + register() + else + -- Same reasoning as dap-python.lua: dap.lua's mason-nvim-dap + -- ensure_installed triggers the install, but that's async - on a fresh + -- machine (or before it finishes) the entrypoint doesn't exist on disk + -- yet, so wire up the adapter once the install actually completes + -- instead of pointing it at a path that isn't there yet. + vim.notify( + "js-debug-adapter not installed yet - dap.lua's ensure_installed should be" + .. " installing it now (check :Mason); run :MasonInstall js-debug-adapter" + .. " if it doesn't show up there. Debugging will work once it's done.", + vim.log.levels.WARN + ) + registry:on("package:install:success", function(installed_pkg) + if installed_pkg.name == "js-debug-adapter" then + register() + end + end) + end +end + +return M diff --git a/neovim/.config/nvim/lua/config/keymaps.lua b/neovim/.config/nvim/lua/config/keymaps.lua index 66e97a0..65e3236 100644 --- a/neovim/.config/nvim/lua/config/keymaps.lua +++ b/neovim/.config/nvim/lua/config/keymaps.lua @@ -14,6 +14,18 @@ map("t", "", [[k]]) map("t", "", [[h]]) map("t", "", [[l]]) +-- Copy to clipboard +map("v", "y", '"+y') +map("n", "Y", '"+yg_') +map("n", "y", '"+y') +map("n", "yy", '"+yy') + +-- Paste from clipboard +map("n", "p", '"+p') +map("n", "P", '"+P') +map("v", "p", '"+p') +map("v", "P", '"+P') + -- Never use the arrow keys for _, key in ipairs({ "", "", "", "" }) do map({ "n", "i" }, key, "") diff --git a/neovim/.config/nvim/lua/config/options.lua b/neovim/.config/nvim/lua/config/options.lua index be614e1..1282850 100644 --- a/neovim/.config/nvim/lua/config/options.lua +++ b/neovim/.config/nvim/lua/config/options.lua @@ -34,3 +34,9 @@ opt.hlsearch = true opt.incsearch = true opt.ignorecase = true opt.smartcase = true + +-- Project-local config (.nvim.lua) is handled by a custom autocmd in +-- autocmds.lua instead of the core 'exrc' option: 'exrc' only checks the +-- literal cwd at startup, once, so it misses a project's .nvim.lua whenever +-- Neovim didn't start with cwd exactly there. Leave 'exrc' off to avoid +-- double-sourcing the same file via both mechanisms. diff --git a/neovim/.config/nvim/lua/config/project_run.lua b/neovim/.config/nvim/lua/config/project_run.lua new file mode 100644 index 0000000..40c1795 --- /dev/null +++ b/neovim/.config/nvim/lua/config/project_run.lua @@ -0,0 +1,151 @@ +-- Single-source-of-truth helper for project-local run/debug configs, meant +-- to be called once per config from a project's `.nvim.lua` (requires +-- `opt.exrc` - see options.lua - and trusting the file once via +-- `:help :trust`). One call registers both an overseer run task and a +-- matching nvim-dap debug config, so a project states its command once +-- instead of repeating it across a separate run-file and debug-file. +-- +-- Example .nvim.lua (script invocation): +-- require("config.project_run").python({ +-- name = "Run app", +-- program = vim.fn.getcwd() .. "/main.py", +-- args = { "--flag" }, -- optional, shared by both run and debug +-- }) +-- +-- Example .nvim.lua (module invocation, `python -m `): +-- require("config.project_run").python({ +-- name = "Run app", +-- module = "fastapi", +-- args = { "dev", "app" }, +-- }) +-- +-- This shows "Run app" in the rr picker (plain execution) and in +-- the dc picker (same script/module, under debugpy, breakpoints +-- included). If /.venv exists, both get VIRTUAL_ENV/PATH pointed at +-- it, same as `uv run` (or `source .venv/bin/activate`) would - and the +-- debug config additionally gets pythonPath set to that venv's interpreter, +-- since debugpy runs the script with the literal interpreter it's told +-- rather than resolving `python3` via PATH. +-- +-- Example .nvim.lua (Node, script invocation): +-- require("config.project_run").node({ +-- name = "Run app", +-- program = vim.fn.getcwd() .. "/index.js", +-- args = { "--flag" }, -- optional, shared by both run and debug +-- }) +-- +-- Example .nvim.lua (Node, `npm run