|
| 1 | +# dotagent.nvim |
| 2 | + |
| 3 | +`dotagent.nvim` provides `$`-prefixed completion for local agent commands and skills inside Neovim. |
| 4 | + |
| 5 | +It is intentionally conservative by default. The plugin stays off in normal editing buffers unless you explicitly attach it or launch Neovim through an external-editor flow marked with `DOTAGENT_EDITOR_PROMPT=1`. |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +- Neovim 0.10+ |
| 10 | +- `saghen/blink.cmp` |
| 11 | + |
| 12 | +## Release Status |
| 13 | + |
| 14 | +The current recommended first public tag is `v0.1.0`. |
| 15 | + |
| 16 | +The plugin uses git tags for releases. There is no separate version file in the repo. |
| 17 | + |
| 18 | +## Features |
| 19 | + |
| 20 | +- Scans local command markdown files and skill directories |
| 21 | +- Provides a Blink source for `$command` and `$skill` completion |
| 22 | +- Auto-attaches only when the editor session is launched with `DOTAGENT_EDITOR_PROMPT=1` |
| 23 | +- Supports manual `:DotagentAttach` and `:DotagentDetach` |
| 24 | +- Includes `:DotagentRefresh`, `:DotagentBrowse`, and `:DotagentHealth` |
| 25 | + |
| 26 | +## Install |
| 27 | + |
| 28 | +Lazy example: |
| 29 | + |
| 30 | +```lua |
| 31 | +{ |
| 32 | + "0xble/dotagent.nvim", |
| 33 | + config = function() |
| 34 | + require("dotagent").setup({ |
| 35 | + sources = { |
| 36 | + { |
| 37 | + type = "commands", |
| 38 | + path = vim.fn.expand("~/dotfiles/dot_agent/commands"), |
| 39 | + }, |
| 40 | + { |
| 41 | + type = "skills", |
| 42 | + path = vim.fn.expand("~/dotfiles/dot_agent/skills"), |
| 43 | + }, |
| 44 | + }, |
| 45 | + }) |
| 46 | + end, |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +Blink setup: |
| 51 | + |
| 52 | +```lua |
| 53 | +{ |
| 54 | + "saghen/blink.cmp", |
| 55 | + opts = function(_, opts) |
| 56 | + opts.sources = opts.sources or {} |
| 57 | + opts.sources.default = function() |
| 58 | + local sources = { "lsp", "path", "snippets" } |
| 59 | + if require("dotagent").is_buffer_enabled(0) then |
| 60 | + table.insert(sources, 1, "dotagent") |
| 61 | + elseif vim.bo.filetype ~= "" and vim.bo.filetype ~= "markdown" and vim.bo.filetype ~= "text" and vim.bo.filetype ~= "gitcommit" then |
| 62 | + table.insert(sources, "buffer") |
| 63 | + end |
| 64 | + return sources |
| 65 | + end |
| 66 | + |
| 67 | + opts.sources.providers = opts.sources.providers or {} |
| 68 | + opts.sources.providers.dotagent = require("dotagent.completion.blink").provider() |
| 69 | + end, |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +## Recommended Integration |
| 74 | + |
| 75 | +The best integration is an external-editor flow where Claude Code or a Codex launcher opens Neovim for prompt composition. |
| 76 | + |
| 77 | +Use one shared launcher for those flows: |
| 78 | + |
| 79 | +```sh |
| 80 | +#!/bin/sh |
| 81 | +export DOTAGENT_EDITOR_PROMPT=1 |
| 82 | +exec nvim "$@" |
| 83 | +``` |
| 84 | + |
| 85 | +Then point your agent surface at that launcher: |
| 86 | + |
| 87 | +- Claude Code: configure its external editor, then use `Ctrl+G` |
| 88 | +- Codex or an editor-backed wrapper like `ai`: set `EDITOR` to the same launcher |
| 89 | + |
| 90 | +When Neovim starts with `DOTAGENT_EDITOR_PROMPT=1`, `dotagent.nvim` attaches only to the initial prompt buffer. Additional buffers opened later in that session stay unaffected. |
| 91 | + |
| 92 | +## Default Behavior |
| 93 | + |
| 94 | +Without `DOTAGENT_EDITOR_PROMPT=1`, the plugin does not auto-attach in regular buffers. |
| 95 | + |
| 96 | +The fallback path is manual: |
| 97 | + |
| 98 | +- `:DotagentAttach` |
| 99 | +- `:DotagentDetach` |
| 100 | + |
| 101 | +That keeps `$` completion out of normal code editing by default. |
| 102 | + |
| 103 | +## Commands |
| 104 | + |
| 105 | +- `:DotagentAttach [bufnr]` |
| 106 | +- `:DotagentDetach [bufnr]` |
| 107 | +- `:DotagentRefresh` |
| 108 | +- `:DotagentBrowse` |
| 109 | +- `:DotagentHealth` |
| 110 | + |
| 111 | +## Configuration |
| 112 | + |
| 113 | +```lua |
| 114 | +require("dotagent").setup({ |
| 115 | + prefixes = { "$" }, |
| 116 | + activation = { |
| 117 | + mode = "contextual", |
| 118 | + env_var = "DOTAGENT_EDITOR_PROMPT", |
| 119 | + }, |
| 120 | + sources = { |
| 121 | + { |
| 122 | + type = "commands", |
| 123 | + path = vim.fn.expand("~/dotfiles/dot_agent/commands"), |
| 124 | + }, |
| 125 | + { |
| 126 | + type = "skills", |
| 127 | + path = vim.fn.expand("~/dotfiles/dot_agent/skills"), |
| 128 | + }, |
| 129 | + { |
| 130 | + type = "items", |
| 131 | + items = { |
| 132 | + { |
| 133 | + name = "ship", |
| 134 | + kind = "command", |
| 135 | + description = "Example Lua-defined item", |
| 136 | + }, |
| 137 | + }, |
| 138 | + }, |
| 139 | + }, |
| 140 | +}) |
| 141 | +``` |
| 142 | + |
| 143 | +`activation.mode` values: |
| 144 | + |
| 145 | +- `"contextual"`: attach only when launched with the editor prompt env marker |
| 146 | +- `"manual"`: never auto-attach |
| 147 | +- `"global"`: enable in every non-terminal buffer |
0 commit comments