Skip to content

Instantly share code, notes, and snippets.

@S1M0N38
Created November 12, 2026 10:24
Show Gist options
  • Select an option

  • Save S1M0N38/1963facaf2add03d52edfd3fdbccba91 to your computer and use it in GitHub Desktop.

Select an option

Save S1M0N38/1963facaf2add03d52edfd3fdbccba91 to your computer and use it in GitHub Desktop.
Neovim and MiniMax skills

Sometimes I want to serach what's the way to sometime in my editor (Neovim + MiniMax), so I simply as to the coding agent directing it to relevant documentation. In order to do so, I've wrote some simple gloabal skills. Here is the skill's stucture.

skills/
├── mvim-docs
│   ├── scripts
│   │   └── mvdoc
│   └── SKILL.md
└── nvim-docs
    ├── scripts
    │   └── nvdoc
    └── SKILL.md
skills/mvim-docs/

SKILL.md

---
name: mvim-docs
description: Look up MiniMax (Neovim distribution) docs and config.
disable-model-invocation: true
---

# MiniMax docs

MiniMax is a Neovim distribution: `mvim` = `NVIM_APPNAME=nvim-minimax nvim`.

```bash
PLUG=~/.local/share/nvim-minimax/site/pack/core/opt
DOC=$(nvim --clean --headless -c 'lua io.stdout:write(vim.env.VIMRUNTIME.."/doc\n")' -c 'qa!')
scripts/mvdoc 'MiniSurround'       # resolve a subject -> mini-surround.txt:6
scripts/mvdoc 'Conform' 40         # ...or print the entry, 40 lines from the anchor
```

`scripts/mvdoc` puts every `vim.pack` plugin on `runtimepath` (lazy loading may not have run), then uses Neovim's own help matching.

1. **The config is the distribution.** Read `~/.config/nvim-minimax` in order: `init.lua`, then `plugin/10_options.lua`, `20_keymaps.lua`, `30_mini.lua` (all `mini.*` setup), `40_plugins.lua`, then `after/`. Grep it for options/keymaps before guessing.

2. **Docs in three roots.** `$DOC` (built-ins), `$PLUG/mini.nvim/doc/mini-*.txt` (per module; list: `scripts/mvdoc mini.nvim-module-list`), `$PLUG/*/doc/*.txt` (other plugins). Shipped `tags` files work without `:helptags`.

3. **Notation is literal.** Quote options (`'sw'`), commands `:sort`, API `nvim_create_buf()`, Lua `vim.api`, events `BufWritePost`, keys `i_CTRL-R`, module tags `MiniSurround`. On E149, stop guessing and search.

4. **Search in two steps.** Start with the tags index, built-ins and plugins separately:
   ```bash
   rg -N '^.*extmark' "$DOC/tags"
   rg -N '^.*surround' "$PLUG"/*/doc/tags
   ```
   Then search one distinctive word, never a phrase (text wraps at 78 cols): `rg -n 'virt_text' "$DOC"/*.txt`. `$PLUG/nvim-lspconfig/doc/configs.txt` is huge — use its tags.

5. **Read entries, not files.** `*tag*` = anchor, `|tag|` = link, `>`…`<` = code block, `====` = section; an entry ends at the next right-aligned `*tag*`. Read anchored windows with `scripts/mvdoc tag N`. Trust these docs over memory; they ship with the installed plugins.

scripts/mvdoc

#!/bin/sh
# mvdoc SUBJECT [LINES] — resolve a MiniMax help subject to file:line, or print its entry.
NVSUBJ="$1" NVWIN="${2:-0}" exec env NVIM_APPNAME=nvim-minimax nvim --clean --headless -c 'lua (function()
  -- Put every vim.pack plugin on runtimepath (without running the config),
  -- so their help tags resolve even when lazy-loading has not happened yet.
  local data = vim.fn.stdpath("data")
  for _, d in ipairs(vim.fn.glob(data .. "/site/pack/*/opt/*", false, true)) do
    vim.opt.rtp:append(d)
  end
  local s = os.getenv("NVSUBJ")
  local n = tonumber(os.getenv("NVWIN")) or 0
  local ok = pcall(vim.cmd, "help " .. s)
  local name = vim.api.nvim_buf_get_name(0)
  if not ok or name == "" then
    io.stdout:write("E149: no help for " .. s .. "\n")
    os.exit(1)
  end
  local l = vim.fn.line(".")
  io.stdout:write(vim.fn.fnamemodify(name, ":t") .. ":" .. l .. "\n")
  if n > 0 then
    io.stdout:write(table.concat(vim.api.nvim_buf_get_lines(0, l - 1, l + n - 1, false), "\n") .. "\n")
  end
end)()' -c 'qa!'
skills/nvim-docs/

SKILL.md

---
name: nvim-docs
description: Look up Neovim help files.
disable-model-invocation: true
---

# Neovim docs

```bash
DOC=$(nvim --clean --headless -c 'lua io.stdout:write(vim.env.VIMRUNTIME.."/doc\n")' -c 'qa!')
scripts/nvdoc 'shiftwidth'       # resolve a subject -> options.txt:5722
scripts/nvdoc 'BufWritePost' 40  # ...or print the entry, 40 lines from the anchor
```

`scripts/nvdoc` uses Neovim's own help matching, so it handles abbreviations and tag priority.

1. **Read the ToC when the topic is vague.** `scripts/nvdoc help.txt 160` is the whole topic table of contents: every subject mapped to a file. Also `index.txt` (all commands), `quickref.txt` (option list), `api.txt`, `vimfn.txt`, `lua.txt` (API), `lua-guide.txt` (config recipes).

2. **Notation is literal.** Quote options (`'sw'`; bare `sw` is the function), commands `:sort`, API `nvim_create_buf()`, Lua `vim.api`, events `BufWritePost`, keys `i_CTRL-R`, errors `E5108`. On E149, stop guessing and search.

3. **Search in two steps.** Start with the tags index, where every tag sits next to its file and anchor:
   ```bash
   rg -N '^.*extmark' "$DOC/tags"
   ```
   Then search one distinctive word, never a phrase (text wraps at 78 cols, splitting it): `rg -n 'virt_text' "$DOC"/*.txt`. `:helpgrep word` adds plugin docs.

4. **Read entries, not files.** `*tag*` = anchor, `|tag|` = link, `>`…`<` = code block, `====` = section; an entry ends at the next right-aligned `*tag*`. Files reach 12k lines — always read an anchored window.

5. **Trust these docs over memory.** They match the installed version. Note headless `print` goes to stderr; use `io.stdout:write` in `$(...)`.

scripts/nvdoc

#!/bin/sh
# nvdoc SUBJECT [LINES] — resolve a help subject to file:line, or print its entry.
NVSUBJ="$1" NVWIN="${2:-0}" exec nvim --clean --headless -c 'lua (function()
  local s = os.getenv("NVSUBJ")
  local n = tonumber(os.getenv("NVWIN")) or 0
  local ok = pcall(vim.cmd, "help " .. s)
  local name = vim.api.nvim_buf_get_name(0)
  if not ok or name == "" then
    io.stdout:write("E149: no help for " .. s .. "\n")
    os.exit(1)
  end
  local l = vim.fn.line(".")
  io.stdout:write(vim.fn.fnamemodify(name, ":t") .. ":" .. l .. "\n")
  if n > 0 then
    io.stdout:write(table.concat(vim.api.nvim_buf_get_lines(0, l - 1, l + n - 1, false), "\n") .. "\n")
  end
end)()' -c 'qa!'

A couple of remarks:

  • nvim-docs serach in Neovim (vanilla) docs while mvim-docs serach in MiniMax docs and config.
  • I don't need these skills all the time, so the disable-model-invocation: true avoid to load them in the context and they are a loaed only when the user explitly call them (e.g. /skill:nvim-docs).
  • Think of them as "Search Engine" for the editor to learn stuff (e.g. "How can I ...?") not for editing Neovim/MiniMax config.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment