From b548abcf80a4c99573aaa8323bdadfd6fb764069 Mon Sep 17 00:00:00 2001 From: Samuel O'Neal Date: Mon, 7 Sep 2026 19:52:06 -0600 Subject: [PATCH] added odin to overseer --- README.md | 26 ++++++++++--- lua/plugins/dap.lua | 93 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1ba90ea..6065499 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ CSS, JSON, YAML, Markdown, SQL, Dockerfile, Python. | LSP | nvim-lspconfig + Mason (`gopls`, `zls`, `lua_ls`, `ts_ls`, `html`, `cssls`, `jsonls`, `yamlls`, `marksman`, `sqlls`, `dockerls`, `pyright`/`ruff`) | | Completion | blink.cmp (LazyVim default; SQL routed to dadbod) | | Formatting | conform.nvim via LazyVim's format pipeline | -| Debugging | nvim-dap + delve (Go), codelldb (Zig/C/C++) | +| Debugging | nvim-dap + delve (Go), codelldb (Zig/C/C++/Odin) | | Testing | neotest (Go, Python, Zig) with in-buffer pass/fail signs | | Coverage | nvim-coverage (Go) | | Task running | overseer.nvim (+ user templates) | @@ -143,9 +143,13 @@ Works in Go, Python, and Zig buffers; results show as signs in the gutter. ### Debugging (DAP, `d`) -Go uses delve; Zig/C/C++ use codelldb. Zig launch configs build with debug -symbols first, then run (`Launch (zig build)` prompts for the exe under -`zig-out/bin`; `Launch (current file)` compiles the open file). +Go uses delve; Zig/C/C++/Odin use codelldb. Zig launch configs build with +debug symbols first, then run (`Launch (zig build)` prompts for the exe under +`zig-out/bin`; `Launch (current file)` compiles the open file). Odin offers +`Launch (make build-debug)` (desi_explorer-style monorepo — runs +`make -C gui build-debug` and points at `bin/desi_explorer` with the repo's +`GUI_ENV_FILE`), `Launch (odin build .)` (plain debug `odin build`), and +`Launch (current file)`. | Key | Action | |-----|--------| | `db` | Toggle breakpoint | @@ -270,7 +274,7 @@ symbols first, then run (`Launch (zig build)` prompts for the exe under │ │ ├── lspconfig.lua # Per-server LSP config (gopls, zls, …) │ │ ├── treesitter.lua # Parsers │ │ ├── formatting.lua # conform.nvim -│ │ ├── dap.lua # Debugging (Go via delve, Zig via codelldb) +│ │ ├── dap.lua # Debugging (Go via delve, Zig/C/C++/Odin via codelldb) │ │ ├── neotest.lua # Test runner (go/python/zig) │ │ ├── go-coverage.lua # Go coverage signs │ │ ├── overseer.lua # Task runner @@ -284,7 +288,7 @@ symbols first, then run (`Launch (zig build)` prompts for the exe under │ │ ├── performance.lua # treesitter large-file guard │ │ ├── theme.lua # catppuccin │ │ └── zig.lua # Zig ft plugin (toolchain wired across files) -│ └── overseer/template/user/ # go_*, zig_{build,run,test} task templates +│ └── overseer/template/user/ # go_*, odin_{build,run,test}, zig_{build,run,test} task templates ``` ## Zig notes @@ -296,6 +300,16 @@ symbols first, then run (`Launch (zig build)` prompts for the exe under - Debugging needs `codelldb` (`:MasonInstall codelldb` if it doesn't auto-install). Builds use `-O Debug` so symbols are present. +## Odin notes + +- LSP is `ols` (Mason + `lua/plugins/lspconfig.lua`); formatting is `odinfmt`. +- Debugging uses **codelldb** with `-o:none -debug` builds, so real breakpoints, + locals/variables, and REPL evaluation work against Odin DWARF. The monorepo + launch config sets `GUI_ENV_FILE` for you, matching `make run`. +- In desi_explorer, `make -C gui build-debug` must finish before + `Launch (make build-debug)` — the config builds first, so breakpoints set in + `gui/src/*.odin` before launching are hit reliably. + ## Troubleshooting - **LSP not attaching:** `:checkhealth lsp` — confirm the server appears and is diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index 6563a87..a0f9948 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -229,6 +229,99 @@ return { dap.configurations.cpp = dap.configurations.zig end, }, + + -- ------------------------------------------------------------------------- + -- Odin debugging via codelldb (same adapter as Zig/C/C++) + -- ------------------------------------------------------------------------- + { + "mfussenegger/nvim-dap", + ft = { "odin" }, + config = function() + local dap = require("dap") + + -- Prefer codelldb on $PATH, fall back to Mason's install location + local codelldb = vim.fn.exepath("codelldb") + if codelldb == "" then + codelldb = vim.fn.stdpath("data") .. "/mason/bin/codelldb" + end + + dap.adapters.codelldb = { + type = "server", + port = "${port}", + executable = { + command = codelldb, + args = { "--port", "${port}" }, + }, + } + + local root = vim.fn.getcwd() + + -- Detect the repo's GUI env file so the app bootstraps its config the + -- same way `make run` does (GUI_ENV_FILE -> dotenv in config.odin). + local env_file + for _, candidate in ipairs({ "resources/dev/gui.env", ".env" }) do + local p = root .. "/" .. candidate + if vim.fn.filereadable(p) == 1 then + env_file = p + break + end + end + local env = {} + if env_file then + env.GUI_ENV_FILE = env_file + end + + dap.configurations.odin = { + { + -- desi_explorer-style monorepo: `make -C gui build-debug` (-o:none + -- -debug), then launch bin/desi_explorer with the GUI env file. + name = "Launch (make build-debug)", + type = "codelldb", + request = "launch", + program = function() + if vim.fn.glob(root .. "/gui/Makefile") ~= "" then + vim.fn.system({ "make", "-C", root .. "/gui", "build-debug" }) + return root .. "/bin/desi_explorer" + end + vim.fn.system({ "odin", "build", ".", "-o:none", "-debug", "-out:.debug_out" }) + return root .. "/.debug_out" + end, + cwd = root, + stopOnEntry = false, + args = {}, + env = env, + }, + { + -- Any standalone Odin project: plain `odin build .` with debug info. + name = "Launch (odin build .)", + type = "codelldb", + request = "launch", + program = function() + vim.fn.system({ "odin", "build", ".", "-o:none", "-debug", "-out:.debug_out" }) + return root .. "/.debug_out" + end, + cwd = root, + stopOnEntry = false, + args = {}, + }, + { + -- Single-file Odin programs (hello.odin, small scripts) + name = "Launch (current file)", + type = "codelldb", + request = "launch", + program = function() + local src = vim.fn.expand("%:p") + local out = vim.fn.expand("%:p:r") .. "_debug" + vim.fn.system({ "odin", "build", src, "-o:none", "-debug", "-out:" .. out }) + return out + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = {}, + }, + } + end, + }, -- ───────────────────────────────────────────────────────────────────────── -- DAP UI keymaps + auto open/close (the spec itself is loaded as a dep above) -- ───────────────────────────────────────────────────────────────────────── -- 2.52.0