stow/shared/.claude/skills/neovim/SKILL.md
Interact with the user's running Neovim instance via RPC. Use this skill when you need to execute Lua or Vimscript inside Neovim, query buffer state, send commands, or interact with the Neovim runtime in any way. Triggers when the user asks about their current Neovim session, wants to run something inside Neovim, or when you need to inspect Neovim state (buffers, windows, options, LSP, etc.). Also use when running inside a Neovim terminal and needing to communicate with the parent editor.
npx skillsauth add fredrikaverpil/dotfiles neovimInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
When Claude Code runs inside a Neovim terminal, the $NVIM environment variable
points to the parent Neovim's Unix socket. This gives full access to Neovim's
msgpack-RPC API without any plugins or HTTP servers.
Before sending any commands, verify the socket is available:
echo "$NVIM"
If $NVIM is empty, you are not running inside a Neovim terminal and cannot
communicate with a Neovim instance.
Important: When NVIM_APPNAME is set, all nvim --server commands emit a
Warning: Using NVIM_APPNAME=... message on stdout (not stderr). This
corrupts parsed output (especially JSON). To suppress it, capture the output
first, then filter:
result=$(nvim --server "$NVIM" --remote-expr 'EXPR') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
Note: Piping nvim directly (e.g. nvim --server "$NVIM" ... | grep ...)
can fail because $NVIM may not expand correctly in pipe contexts. Always use
command substitution ($(...)) as shown above.
All examples below use the command substitution pattern from Prerequisites to
filter the NVIM_APPNAME warning. The shorthand nvimx EXPR means:
result=$(nvim --server "$NVIM" --remote-expr 'EXPR') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
Use --remote-expr to evaluate a Vimscript expression and get the result back:
result=$(nvim --server "$NVIM" --remote-expr 'v:version') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
For Lua expressions, wrap them in luaeval():
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.api.nvim_buf_get_name(0)")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
For multi-statement Lua that returns a value, use an IIFE:
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("(function() local x = vim.api.nvim_get_current_win(); return vim.api.nvim_win_get_number(x) end)()")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
luaeval() returns Lua tables as Vimscript values. For complex data, encode as
JSON:
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.json.encode(vim.api.nvim_list_bufs())")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
Use --remote-send to send keystrokes (as if the user typed them):
nvim --server "$NVIM" --remote-send ':echo "hello"<CR>'
Note: --remote-send does not return output and does not need the warning
filter. Use --remote-expr when you need a return value.
Use --remote to open files in the running Neovim instance:
nvim --server "$NVIM" --remote file.txt
Use --remote-tab to open files in new tabs:
nvim --server "$NVIM" --remote-tab file1.txt file2.txt
To run Lua that performs side effects (no return value needed):
result=$(nvim --server "$NVIM" --remote-expr 'execute("lua vim.notify(\"Hello from Claude\")")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
The execute() Vimscript function runs an Ex command and returns its output as a
string (empty if the command produces no output).
# Current buffer path
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.api.nvim_buf_get_name(0)")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
# List all buffer paths (JSON)
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.json.encode(vim.tbl_map(function(b) return vim.api.nvim_buf_get_name(b) end, vim.api.nvim_list_bufs()))")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
# Current working directory
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.fn.getcwd()")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
# Current cursor position [row, col] (1-indexed row)
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.json.encode(vim.api.nvim_win_get_cursor(0))")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
# Get a Neovim option value
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.o.filetype")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
# Check if an LSP client is attached
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.json.encode(vim.tbl_map(function(c) return c.name end, vim.lsp.get_clients({bufnr = 0})))")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
Do not use execute("help ...") — that opens help inside the editor as a
side effect instead of returning content.
First, get the key paths via RPC (do this once per session):
# Neovim data directory (plugin install root is <data>/lazy/ for lazy.nvim)
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.fn.stdpath(\"data\")")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
# Built-in Neovim docs
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.fn.expand(\"$VIMRUNTIME\")")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
Then use standard tools (fd, rg, Glob, Grep) to search and Read to
view the files. Search <data>/lazy/*/doc/ for plugin docs and
<runtime>/doc/ for built-in docs.
Search help tags (equivalent to :h query<Tab> completion):
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.json.encode(vim.fn.getcompletion(\"MiniDiff\", \"help\"))")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
Search runtime files (searches all runtime paths including user config,
plugins, and pack/*/start/*):
# Find Lua source files matching a keyword (e.g. "codediff", "neotest")
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.json.encode(vim.api.nvim_get_runtime_file(\"lua/**/neotest*\", true))")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
# Find any runtime file by pattern (plugin/, autoload/, syntax/, etc.)
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.json.encode(vim.api.nvim_get_runtime_file(\"**/neotest*\", true))")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
Note: nvim_get_runtime_file only searches active runtime paths.
Lazy-loaded plugins that haven't been loaded yet won't appear. See the
lazy.nvim section below for how to find those.
Then use Read, Glob, or Grep to explore the returned paths.
The plugin manager lazy.nvim uses its own
directory layout, separate from Neovim's built-in pack/ structure.
Plugins are installed under stdpath("data")/lazy/ (e.g.
~/.local/share/nvim-fredrik/lazy/<plugin-name>/). This path is not part
of the standard Neovim packpath.
The lazy.nvim API knows about all plugins regardless of whether they are loaded:
# Get a specific plugin's directory
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("require(\"lazy.core.config\").plugins[\"neotest\"].dir")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
# List all plugins with their paths (JSON)
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.json.encode(vim.tbl_map(function(p) return {name = p.name, dir = p.dir, dev = p.dev or false} end, vim.tbl_values(require(\"lazy.core.config\").plugins)))")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
You can also search the install directory directly with fd/Glob using the
stdpath("data")/lazy/ path.
dev = true)Plugins with dev = true in their spec are loaded from a local development
path instead of the install directory.
# Get the dev path from lazy.nvim config
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("require(\"lazy.core.config\").options.dev.path")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
# Check if a specific plugin is using dev mode
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("require(\"lazy.core.config\").plugins[\"codediff.nvim\"].dev")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
A dev plugin's source lives at <dev.path>/<plugin-name> (e.g. if dev.path is
~/code/public, then codediff.nvim with dev = true loads from
~/code/public/codediff.nvim). The plugin's .dir field in the lazy API
already reflects this.
Plugin specifications (the Lua files that configure which plugins to load) live in the Neovim config directory, not in the install directory. Search there when you need to find how a plugin is configured:
# Find plugin spec files
result=$(nvim --server "$NVIM" --remote-expr 'luaeval("vim.fn.stdpath(\"config\")")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
# Then use Glob/Grep to search the returned config path
When files are edited externally (e.g. by Claude Code tools), Neovim's LSP diagnostics can become stale — showing warnings for old line numbers or already-fixed issues. To refresh:
result=$(nvim --server "$NVIM" --remote-expr 'execute("lua vim.api.nvim_buf_call(BUFNR, function() vim.cmd(\"edit! | write\") end)")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
result=$(nvim --server "$NVIM" --remote-expr 'execute("LspRestart")') && echo "$result" | grep -v '^Warning: Using NVIM_APPNAME='
After restarting, wait ~10 seconds for the LSP server to re-index before querying diagnostics again.
golangci-lint run ./... for Go).:q, :qa, :bdelete, or other destructive commands without
explicit user confirmation.--remote-expr (read-only queries) over --remote-send (simulates
typing) whenever possible.grep -v to suppress the NVIM_APPNAME
warning (see Prerequisites).For common Neovim workflows (LSP interaction, debugging, plugin management),
see the references/ directory.
development
Google API Improvement Proposals (AIP) reference. Use BEFORE designing or reviewing APIs, protobuf definitions, or any work involving Google API design standards. Fetches relevant AIP rules from https://google.aip.dev for the task at hand.
tools
Guide for writing Neovim plugins in Lua following official Neovim conventions (https://neovim.io/doc/user/lua-plugin/). Use this skill whenever the user is creating, modifying, or reviewing a Neovim plugin — including when they mention plugin structure, ftplugin, health checks, keymaps, setup() functions, vimdoc, LuaCATS annotations, or lazy loading in the context of Neovim plugin development. Also trigger when the user is working in a directory that looks like a Neovim plugin (contains plugin/, lua/, ftplugin/ subdirectories).
tools
Native Neovim config idioms and conventions — use whenever writing, reviewing, or modifying any Neovim configuration that uses Neovim's built-in conventions WITHOUT a plugin manager framework (no lazy.nvim, packer, etc.). Covers directory structure, vim.pack plugin management, lsp/ auto-discovery, plugin/ loading order, keymaps, and standard paths. Trigger on any task involving init.lua, plugin/*.lua, lsp/*.lua, vim.pack.add(), vim.lsp.enable(), or "native neovim config" — even if the user just says "add a plugin" or "configure LSP" in a native-style config.
development
Analyze a git repo's history to surface high-churn files, ownership risks, bug hotspots, momentum trends, and firefighting patterns. Use this skill whenever the user wants to understand a codebase, assess repo health, or orient themselves before reading code — even if they don't explicitly say "audit".