From 5656c2d385b1b91042fa0110cb22a91c4a154280 Mon Sep 17 00:00:00 2001 From: Samuel O'Neal Date: Sat, 6 Jun 2026 15:54:15 -0600 Subject: [PATCH] updated secrets baseline config --- .secrets.baseline | 15 +- README.md | 376 +++++++++++++++-------- lua/config/keymaps.lua | 10 + lua/overseer/template/user/zig_build.lua | 21 ++ lua/overseer/template/user/zig_run.lua | 20 ++ lua/overseer/template/user/zig_test.lua | 20 ++ lua/plugins/dap.lua | 64 +++- lua/plugins/editor.lua | 1 + lua/plugins/lspconfig.lua | 40 ++- lua/plugins/mason.lua | 1 + lua/plugins/neotest.lua | 12 +- lua/plugins/treesitter.lua | 3 + lua/plugins/zig.lua | 9 + 13 files changed, 451 insertions(+), 141 deletions(-) create mode 100644 lua/overseer/template/user/zig_build.lua create mode 100644 lua/overseer/template/user/zig_run.lua create mode 100644 lua/overseer/template/user/zig_test.lua diff --git a/.secrets.baseline b/.secrets.baseline index 3053c76..34032de 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -90,6 +90,10 @@ { "path": "detect_secrets.filters.allowlist.is_line_allowlisted" }, + { + "path": "detect_secrets.filters.common.is_baseline_file", + "filename": ".secrets.baseline" + }, { "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies", "min_level": 2 @@ -133,19 +137,12 @@ } ], "README.md": [ - { - "type": "Secret Keyword", - "filename": "README.md", - "hashed_secret": "6d9c68c603e465077bdd49c62347fe54717f83a3", - "is_verified": false, - "line_number": 55 - }, { "type": "Basic Auth Credentials", "filename": "README.md", "hashed_secret": "9d4e1e23bd5b727046a9e3b4b7db57bd8d6ee684", "is_verified": false, - "line_number": 68 + "line_number": 85 } ], "lazy-lock.json": [ @@ -585,5 +582,5 @@ } ] }, - "generated_at": "2026-05-09T17:04:51Z" + "generated_at": "2026-06-06T21:52:58Z" } diff --git a/README.md b/README.md index 1a6cf01..1ba90ea 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,28 @@ -# Neovim Configuration with LazyVim +# Neovim Configuration (LazyVim) -A comprehensive Neovim setup with LSP support, AI chat, database integration, and debugging. +A LazyVim-based setup focused on Go and Zig development, with LSP, debugging, +test running, task running, AI chat, database tooling, and a which-key cheat +sheet. Everything is lazy-loaded so plugins only activate for the filetype or +command that needs them. ## Prerequisites -- Neovim >= 0.9.0 (installed via Homebrew) -- Git -- A Nerd Font (for icons) -- Node.js (for some LSP servers and formatters) -- Go (for gopls and delve) +- **Neovim >= 0.11** (developed on 0.12.x; 0.11+ is required for the modern + `vim.lsp` / `root_markers` API used by some servers) +- **Git** +- **A Nerd Font** (icons in the explorer, statusline, dadbod UI, etc.) +- **Node.js** — TypeScript/JSON/YAML/web LSPs and `prettier` +- **Go** — `gopls`, `delve`, `gofumpt`, `goimports` +- **Zig** — the `zig` toolchain on `$PATH` (for LSP, build/run, tests, debug) +- **Python** _(optional)_ — `pyright` + `ruff` are configured if you use it + +Most language servers, linters, formatters, and DAP adapters install +automatically through Mason on first launch. ## Installation -1. **Backup existing configuration** (if any): +1. **Back up any existing config:** + ```bash mv ~/.config/nvim ~/.config/nvim.bak mv ~/.local/share/nvim ~/.local/share/nvim.bak @@ -20,161 +30,287 @@ A comprehensive Neovim setup with LSP support, AI chat, database integration, an mv ~/.cache/nvim ~/.cache/nvim.bak ``` -2. **Clone this configuration**: +2. **Clone:** + ```bash - git clone ~/.config/nvim + git clone https://git.samoneal.io/sam_oneal/nvim-config.git ~/.config/nvim ``` -3. **Start Neovim**: - ```bash - nvim - ``` - Lazy.nvim will automatically install all plugins on first launch. +3. **Launch Neovim.** lazy.nvim bootstraps itself and installs all plugins. -4. **Install LSP servers and tools**: - After plugins load, run: - ``` - :Mason - ``` - All required tools should install automatically. +4. **Install tooling** with `:Mason` (or `:MasonInstall `). Check health + with `:checkhealth` and LSP attachment with `:checkhealth lsp`. -## Features +## What's included -### Language Support (LSP + Treesitter) -- Go, Lua, TypeScript, JavaScript, HTML, CSS, JSON, YAML, Markdown, SQL, Makefile +**Base:** [LazyVim](https://www.lazyvim.org/) with leader = ``, +localleader = `\`, colorscheme `catppuccin-mocha`. -### AI Chat Integration -Supports multiple providers via [avante.nvim](https://github.com/yetone/avante.nvim): -- Anthropic Claude -- OpenAI GPT -- Google Gemini -- And more +**LazyVim extras enabled** (in `lua/config/lazy.lua`): `lang.go`, `lang.json`, +`lang.yaml`, `lang.markdown`, `lang.typescript`, `lang.tailwind`, +`dap.core`. -Set your API keys as environment variables: -```bash -export ANTHROPIC_API_KEY="your-key" -export OPENAI_API_KEY="your-key" -export GEMINI_API_KEY="your-key" -``` +**Languages (LSP + Treesitter):** Go, Zig, Lua, TypeScript/JavaScript, HTML, +CSS, JSON, YAML, Markdown, SQL, Dockerfile, Python. -Switch providers: `:AvanteProvider claude|openai|gemini` +| Concern | Plugin / tool | +| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| 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++) | +| Testing | neotest (Go, Python, Zig) with in-buffer pass/fail signs | +| Coverage | nvim-coverage (Go) | +| Task running | overseer.nvim (+ user templates) | +| AI chat | [opencode.nvim](https://github.com/nickjvandyke/opencode.nvim) (provider-agnostic) | +| Database | vim-dadbod + dadbod-ui + dadbod-completion | +| Git | Neogit + diffview, plus LazyVim's lazygit | +| Explorer/picker | snacks.nvim | +| Symbols | aerial.nvim | +| Diagnostics | trouble.nvim | +| Cheat sheet | which-key.nvim (hold ``) | -### Database Integration (vim-dadbod) -- `:DBUIToggle` - Open database UI -- `:DBUIAddConnection` - Add a new connection +### AI (opencode.nvim) + +AI is intentionally **environment-agnostic**: opencode.nvim drives the external +[`opencode`](https://opencode.ai) CLI, so the model/provider (Anthropic, +OpenAI, local models, etc.) is chosen in opencode's own config rather than here. +Install the `opencode` CLI separately and configure your provider there. + +### Database (vim-dadbod) + +Open the UI with `Du`. Add a connection with `Da`. Examples: -Connection string examples: ``` postgresql://user:pass@localhost:5432/dbname mysql://user:pass@localhost:3306/dbname sqlite:path/to/db.sqlite ``` -### Go Debugging (DAP + Delve) -Full debugging support with breakpoints, stepping, variable inspection. +SQL completion is provided via dadbod inside SQL buffers, and SQL +autoformat-on-save is intentionally disabled (format manually with +`cf`). -## Key Bindings +## Key bindings -### Terminal +Hold `` (Space) to pop up the **which-key** menu — it lists every group +below as a live cheat sheet. Mouse is enabled (`mouse=a`), and the explorer, +dadbod UI, Neogit, DAP UI, trouble, aerial, and Overseer pickers are all +clickable. + +> Note the deliberate capitalization: **`T*`** is Terminal (lowercase +> `t*` is the Test group), and **`D*`** is Database (lowercase +> `d*` is Debug). + +### AI (`a`) + +| Key | Action | +| --------------------- | ---------------------------------- | +| `aa` | Ask AI about current context (n/v) | +| `ax` | Ask AI about selection | +| `at` | Toggle AI panel | +| `go` | Operator: add range to AI chat | +| `goo` | Add current line to AI chat | +| `` / `` | Scroll AI chat up/down | + +### Code › Go (`cg`) + +| Key | Action | +| -------------- | ------------------------------------- | +| `cgb` | Run benchmarks (`-bench=. -benchmem`) | +| `cgpc` | CPU profile | +| `cgpm` | Memory profile | +| `cgpt` | Trace profile | + +### Code › Zig (`cz`) + +| Key | Action | +| ------------- | ---------------- | +| `czb` | `zig build` | +| `czr` | `zig build run` | +| `czt` | `zig build test` | + +### Tests (neotest, `t`) + +Works in Go, Python, and Zig buffers; results show as signs in the gutter. | Key | Action | |-----|--------| -| `th` | Open terminal (horizontal split) | -| `tv` | Open terminal (vertical split) | -| `` | Toggle floating terminal | -| `` | Exit terminal mode | +| `tt` | Run nearest test | +| `tf` | Run test file | +| `ts` | Toggle test summary | +| `to` | Open test output | +| `tc` | Show coverage (Go) | -### File Explorer (Snacks explorer) -| Key | Action | -|-----|--------| -| `` | Toggle explorer | -| `` or `` | Open file in vertical split | -| `` or `` | Open file in horizontal split | -| `e` | Focus explorer (LazyVim default) | +### Debugging (DAP, `d`) -### AI Chat -| Key | Action | -|-----|--------| -| `aa` | Ask AI (with selection in visual mode) | -| `ac` | Open AI chat | -| `at` | Toggle AI sidebar | - -### Database -| Key | Action | -|-----|--------| -| `db` | Toggle database UI | -| `da` | Add database connection | - -### Debugging +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). | Key | Action | |-----|--------| | `db` | Toggle breakpoint | -| `dB` | Breakpoint with condition | -| `dc` | Continue | +| `dB` | Conditional breakpoint | +| `dc` | Continue / start | +| `dC` | Run to cursor | | `di` | Step into | -| `do` | Step out | | `dO` | Step over | +| `do` | Step out | +| `dj` / `dk` | Stack down / up | +| `dr` | Toggle REPL | +| `ds` | Session | +| `dt` | Terminate | +| `dw` | Inspect widget (hover) | | `du` | Toggle DAP UI | +| `de` | Eval (n/v) | | `dT` | Debug Go test | -| `dt` | Terminate debug session | +| `dL` | Debug last Go test | -### Formatting -| Key | Action | -|-----|--------| -| `cf` | Format buffer | -| `:FormatToggle` | Toggle auto-format on save | -| `:FormatDisable` | Disable auto-format | -| `:FormatEnable` | Enable auto-format | +### Tasks (Overseer, `o`) -### General -| Key | Action | -|-----|--------| -| `` | Save file | -| `` / `` | Previous/Next buffer | -| `` | Navigate windows | -| `` / `` | Move line down/up | +| Key | Action | +| ------------ | --------------------------------------------------------- | +| `or` | Run a task (picker — includes `go:` and `zig:` templates) | +| `ot` | Toggle task list | -## File Structure +### Database (`D`) + +| Key | Action | +| ------------ | -------------- | +| `Du` | Toggle DB UI | +| `Da` | Add connection | +| `Df` | Find DB buffer | + +### Git (`g`) + +| Key | Action | +| ------------ | ------------------------- | +| `gg` | Lazygit (LazyVim default) | +| `gn` | Neogit | +| `gl` | Lazygit log | +| `gf` | Lazygit file history | + +### Search / Symbols (`s`) + +| Key | Action | +| ------------ | ------------------------ | +| `so` | Symbols outline (aerial) | +| `sh` | Incoming calls | +| `sc` | Outgoing calls | + +### Diagnostics (Trouble, `x`) + +| Key | Action | +| ------------ | --------------------- | +| `xx` | Diagnostics | +| `xw` | Workspace diagnostics | +| `xt` | TODOs | + +### Terminal (`T`) + +| Key | Action | +| ------------ | --------------------------- | +| `Th` | Terminal (horizontal split) | +| `Tv` | Terminal (vertical split) | +| `` | Exit terminal mode | + +### Explorer & windows + +| Key | Action | +| ------------------------ | ----------------------------- | +| `` | Toggle explorer (snacks) | +| `` / `` | Open file in vertical split | +| `` / `` | Open file in horizontal split | +| `` | Navigate windows | +| `` | Resize window | + +### Formatting (LazyVim pipeline) + +| Key / Command | Action | +| ------------- | -------------------------- | +| `cf` | Format buffer | +| `uf` | Toggle autoformat (buffer) | +| `uF` | Toggle autoformat (global) | +| `:LazyFormat` | Format now | + +### General editing + +| Key | Action | +| ------------------ | --------------------------- | +| `` | Save file | +| `` / `` | Prev / next buffer | +| `` | Clear search highlight | +| `` / `` | Move line/selection down/up | +| `<` / `>` (visual) | Indent, keep selection | + +## Formatters by file type + +| File type | Formatter | +| --------------- | ---------------------------------------- | +| Go | gofumpt, goimports (`-local github.com`) | +| Lua | stylua (2-space) | +| JS/TS/JSX/TSX | prettier (2-space, single quotes) | +| HTML/CSS/SCSS | prettier | +| JSON/JSONC/YAML | prettier | +| Markdown | prettier | +| SQL | sql-formatter (postgresql; manual only) | + +## File structure ``` ~/.config/nvim/ -├── init.lua # Entry point +├── init.lua # Entry point → require("config.lazy") ├── lua/ │ ├── config/ -│ │ ├── lazy.lua # Lazy.nvim bootstrap & LazyVim setup -│ │ ├── options.lua # General Neovim options -│ │ ├── keymaps.lua # Custom key bindings -│ │ └── autocmds.lua # Auto commands -│ └── plugins/ -│ ├── lsp.lua # LSP & Treesitter configuration -│ ├── ai.lua # AI chat integration (avante.nvim) -│ ├── dadbod.lua # Database integration -│ ├── dap.lua # Debugging configuration -│ ├── formatting.lua # Auto-formatting (conform.nvim) -│ └── editor.lua # Editor enhancements (snacks explorer, etc.) +│ │ ├── lazy.lua # lazy.nvim bootstrap, LazyVim + extras +│ │ ├── options.lua # Neovim options +│ │ ├── keymaps.lua # Custom keymaps +│ │ └── autocmds.lua # Autocommands (yank hl, ft tweaks, SQL no-autoformat…) +│ ├── plugins/ +│ │ ├── mason.lua # Tooling installs (LSP/linters/formatters/DAP) +│ │ ├── lspconfig.lua # Per-server LSP config (gopls, zls, …) +│ │ ├── treesitter.lua # Parsers +│ │ ├── formatting.lua # conform.nvim +│ │ ├── dap.lua # Debugging (Go via delve, Zig via codelldb) +│ │ ├── neotest.lua # Test runner (go/python/zig) +│ │ ├── go-coverage.lua # Go coverage signs +│ │ ├── overseer.lua # Task runner +│ │ ├── ai.lua # opencode.nvim +│ │ ├── dadbod.lua # Database +│ │ ├── git.lua # Neogit + diffview +│ │ ├── editor.lua # snacks tweaks + which-key groups +│ │ ├── symbols.lua # aerial +│ │ ├── dashboard.lua # trouble opts +│ │ ├── devcontainer.lua # nvim-remote-containers +│ │ ├── 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 ``` -## Formatters by File Type +## Zig notes -| File Type | Formatter | -|-----------|-----------| -| Go | gofumpt, goimports | -| Lua | stylua | -| JS/TS/JSX/TSX | prettier | -| HTML/CSS | prettier | -| JSON/YAML | prettier | -| Markdown | prettier | -| SQL | sql-formatter | +- LSP is `zls` (`lua/plugins/lspconfig.lua`), root markers `build.zig` / + `build.zig.zon`, with build-on-save and inlay hints. +- `zig build test` and project-wide neotest runs require a standard `test` step + in your `build.zig`; individual `.zig` files also work. +- Debugging needs `codelldb` (`:MasonInstall codelldb` if it doesn't + auto-install). Builds use `-O Debug` so symbols are present. ## Troubleshooting -### LSP not working -Run `:LspInfo` to check status. Run `:Mason` to verify tools are installed. +- **LSP not attaching:** `:checkhealth lsp` — confirm the server appears and is + attached (not just installed in Mason). If `root_dir`/`root_markers` look off, + the server may not find your project root. +- **Formatting:** `:ConformInfo`. +- **Tests not detected:** ensure the Treesitter parser for the language is + installed (`:TSInstall `); Zig needs a `test` step in `build.zig`. +- **Ctrl+Shift keys not firing:** some terminals don't transmit them; use the + plain-Ctrl fallbacks (`` / `` in the explorer). +- **Nerd Font icons missing:** install a Nerd Font and set it in your terminal. -### Formatting not working -Run `:ConformInfo` to check formatter status. +## Known issues (in current repo) -### Icons not displaying -Install a Nerd Font and configure your terminal to use it. - -### Ctrl+Shift keybindings not working -Some terminals don't properly send Ctrl+Shift combinations. Use the alternative mappings (`` and `` in snacks explorer). +Two unrelated typos exist in `lua/config/keymaps.lua`'s opencode block (present +before these docs): the scroll-up command string reads `sesion.half.page.up` +(should be `session.…`), and `at` is mapped in `t` (terminal) mode where +`n`/`x` is likely intended. Documented here for accuracy; fix when convenient. diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 05b7542..c573a3f 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -128,6 +128,16 @@ map("n", "cgpt", function() vim.cmd("!go test -run=^$ -bench=. -trace trace.out ./...") end, { desc = "Go trace profile" }) +-- ───────────────────────────────────────────────────────────────────────────── +-- Zig: build / run / test +-- ───────────────────────────────────────────────────────────────────────────── +-- Mirrors the Go cg* layout: cz* (Code > Zig). +-- These are quick one-shot runs; for the mouse-driven task picker use or (OverseerRun), +-- which lists the zig: build/run/test templates from lua/overseer/template/user +map("n", "czb", "!zig build", { desc = "Zig build" }) +map("n", "czr", "!zig build run", { desc = "Zig build run" }) +map("n", "czt", "!zig build test", { desc = "Zig build test" }) + -- ───────────────────────────────────────────────────────────────────────────── -- Overseer -- ───────────────────────────────────────────────────────────────────────────── diff --git a/lua/overseer/template/user/zig_build.lua b/lua/overseer/template/user/zig_build.lua new file mode 100644 index 0000000..77f2de7 --- /dev/null +++ b/lua/overseer/template/user/zig_build.lua @@ -0,0 +1,21 @@ +return { + name = "zig: build", + desc = "Build the project (zig build)", + -- Only offered as a task when a build.zig is present in the project root. + condition = { + callback = function() + return vim.fn.filereadable(vim.fn.getcwd() .. "/build.zig") == 1 + end, + }, + builder = function() + return { + cmd = { "zig" }, + args = { "build" }, + components = { + "default", + "on_output_quickfix", + { "on_complete_notify", statuses = { "SUCCESS", "FAILURE" } }, + }, + } + end, +} diff --git a/lua/overseer/template/user/zig_run.lua b/lua/overseer/template/user/zig_run.lua new file mode 100644 index 0000000..8202aef --- /dev/null +++ b/lua/overseer/template/user/zig_run.lua @@ -0,0 +1,20 @@ +return { + name = "zig: run", + desc = "Build and run (zig build run)", + condition = { + callback = function() + return vim.fn.filereadable(vim.fn.getcwd() .. "/build.zig") == 1 + end, + }, + builder = function() + return { + cmd = { "zig" }, + args = { "build", "run" }, + components = { + "default", + "on_output_quickfix", + { "on_complete_notify", statuses = { "SUCCESS", "FAILURE" } }, + }, + } + end, +} diff --git a/lua/overseer/template/user/zig_test.lua b/lua/overseer/template/user/zig_test.lua new file mode 100644 index 0000000..2212489 --- /dev/null +++ b/lua/overseer/template/user/zig_test.lua @@ -0,0 +1,20 @@ +return { + name = "zig: test", + desc = "Run the test step (zig build test)", + condition = { + callback = function() + return vim.fn.filereadable(vim.fn.getcwd() .. "/build.zig") == 1 + end, + }, + builder = function() + return { + cmd = { "zig" }, + args = { "build", "test" }, + components = { + "default", + "on_output_quickfix", + { "on_complete_notify", statuses = { "SUCCESS", "FAILURE" } }, + }, + } + end, +} diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index 0955dee..6563a87 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -167,6 +167,68 @@ return { }, }, + -- ------------------------------------------------------------------------- + -- Zig (+ C/C++) debugging via codelldb + -- ------------------------------------------------------------------------- + { + "mfussenegger/nvim-dap", + ft = { "zig" }, + 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}" }, + }, + } + + dap.configurations.zig = { + { + -- Project build (build.zig). Runs `zig build` first so a fresh + -- debug binary exists, then asks which exec under zig-out/bin to run. + name = "Launch (zig build)", + type = "codelldb", + request = "launch", + program = function() + vim.fn.system({ "zig", "build", "--summary", "none" }) + return vim.fn.input("Executable: ", vim.fn.getcwd() .. "/zig-out/bin/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = {}, + }, + { + -- Single file. Compiles the current .zig with debug info next to it, + -- then launches that binary. + name = "Launch (current file)", + type = "codelldb", + request = "launch", + program = function() + local src = vim.fn.expand("%:p") + local out = vim.fn.expand("%:p:r") + vim.fn.system({ "zig", "build-exe", src, "-O", "Debug", "-femit-bin=" .. out }) + return out + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = {}, + }, + } + + -- Reuse the same configs for C/C++ buffers - codelldb handles them too + dap.configurations.c = dap.configurations.zig + dap.configurations.cpp = dap.configurations.zig + end, + }, -- ───────────────────────────────────────────────────────────────────────── -- DAP UI keymaps + auto open/close (the spec itself is loaded as a dep above) -- ───────────────────────────────────────────────────────────────────────── @@ -239,7 +301,7 @@ return { { "jay-babu/mason-nvim-dap.nvim", opts = { - ensure_installed = { "python", "delve", "js" }, + ensure_installed = { "python", "delve", "js", "codelldb" }, }, }, diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index a72886d..7392c8f 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -77,6 +77,7 @@ return { { "c", group = "Code" }, { "cg", group = "Go" }, { "cgp", group = "Profile" }, + { "cz", group = "Zig" }, { "d", group = "Debug" }, { "D", group = "Database" }, { "f", group = "Find" }, diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index d0d0146..955dd73 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -11,9 +11,9 @@ return { "neovim/nvim-lspconfig", opts = { servers = { - -- ───────────────────────────────────────────────────────────────── + -- ----------------------------------------------------------------- -- Go - -- ───────────────────────────────────────────────────────────────── + -- ----------------------------------------------------------------- gopls = { root_markers = { "go.work", "go.mod", ".git" }, settings = { @@ -60,9 +60,29 @@ return { }, }, - -- ───────────────────────────────────────────────────────────────── + -- ----------------------------------------------------------------- + -- Zig + -- ----------------------------------------------------------------- + zig = { + root_markers = { "build.zig", "build.zig.zon" }, + settings = { + zls = { + enable_build_on_save = true, + -- "watch" or specify a step name your build.zig defines + build_on_save_step = "install", + semantic_tokens = "full", + enable_inlay_hints = true, + inlay_hints_show_parameter_name = true, + inlay_hints_show_builtin = true, + inlay_hints_show_variable_type_hints = true, + warn_style = true, + }, + }, + }, + + -- ----------------------------------------------------------------- -- Lua - -- ───────────────────────────────────────────────────────────────── + -- ----------------------------------------------------------------- lua_ls = { root_markers = { ".luarc.json", @@ -83,9 +103,9 @@ return { }, }, - -- ───────────────────────────────────────────────────────────────── + -- ----------------------------------------------------------------- -- TypeScript / JavaScript - -- ───────────────────────────────────────────────────────────────── + -- ----------------------------------------------------------------- ts_ls = { root_markers = { "tsconfig.json", "jsconfig.json", "package.json", ".git" }, settings = { @@ -114,9 +134,9 @@ return { }, }, - -- ───────────────────────────────────────────────────────────────── + -- ----------------------------------------------------------------- -- Web (HTML / CSS / JSON / YAML) - -- ───────────────────────────────────────────────────────────────── + -- ----------------------------------------------------------------- html = { root_markers = { "package.json", ".git" }, filetypes = { "html", "templ" }, @@ -143,9 +163,9 @@ return { }, }, - -- ───────────────────────────────────────────────────────────────── + -- ----------------------------------------------------------------- -- Markdown / SQL / Docker - -- ───────────────────────────────────────────────────────────────── + -- ----------------------------------------------------------------- marksman = { root_markers = { ".marksman.toml", ".git" }, }, diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index 834139b..7cc7721 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -37,6 +37,7 @@ return { -- DAP adapters "delve", "js-debug-adapter", + "codelldb", }, }, }, diff --git a/lua/plugins/neotest.lua b/lua/plugins/neotest.lua index 37a1ca3..2e04c94 100644 --- a/lua/plugins/neotest.lua +++ b/lua/plugins/neotest.lua @@ -7,15 +7,17 @@ return { { "nvim-neotest/neotest", lazy = true, - ft = { "go", "ptyhon" }, + ft = { "go", "ptyhon", "zig" }, dependencies = { "nvim-neotest/nvim-nio", "nvim-lua/plenary.nvim", "antoinemadec/FixCursorHold.nvim", + "nvim-treesitter/nvim-treesitter", -- noetest-zig parses tests via treesitter -- Adapters "nvim-neotest/neotest-go", "nvim-neotest/neotest-python", + "lawrence-laz/neotest-zig", }, config = function() require("neotest").setup({ @@ -39,6 +41,14 @@ return { dap = { justMyCode = false }, args = { "--disable-warnings", "-q" }, }), + + -- Zig: requires a standard `test` step in build.zig for project-wide runs; + -- individual .zig files also work. + -- dap.adapter must match the adapter named registered in dap.lua (codelldb) so dT-style + -- debug-test works from the summary too + require("neotest-zig")({ + dap = { adapter = "codelldb" }, + }), }, }) end, diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 0b59800..9d22ae9 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -36,6 +36,9 @@ return { "markdown", "markdown_inline", + -- Zig + "zig", + -- Build / config "ninja", "sql", diff --git a/lua/plugins/zig.lua b/lua/plugins/zig.lua index a3cb7d9..e3499ff 100644 --- a/lua/plugins/zig.lua +++ b/lua/plugins/zig.lua @@ -1,5 +1,14 @@ -- Zig language support via the official Codeberg-hosted plugin. -- Loads only on zig files. +-- +-- The rest of the Zig toolchain is wired in alongside the other languages so +-- it benefits from the same lazy-loading and config: +-- * LSP (zls) ........... lspconfig.lua (servers.zls) + mason.lua +-- * Treesitter parser ... treesitter.lua ("zig") +-- * Tests in-buffer ..... neotest.lua (neotest-zig adapter, ft=zig) +-- * Debug (codelldb) .... dap.lua (dap.configurations.zig) + mason +-- * Run/build tasks ..... overseer/template/user/zig_{build,run,test}.lua +-- * Quick keymaps ....... keymaps.lua (cz*) + which-key group return { { -- 2.49.1