Neovim context for coding agents.
Exposes a minimal, token-aware context from your active Neovim session to coding agents. The Claude Code integration works the same way the VS Code extension does, giving Claude awareness of your open file, cursor, selection, and diagnostics without any extra setup beyond installing the plugin.
Requires Go for building the CLI.
vim.pack (Neovim 0.12+):
vim.pack.add({
"git@github.com:terkelg/nvim-context.git",
})
require("nvim-context").setup()Then build the CLI:
:NvimContextInstallThis builds the Go binary and links nvim-context into ~/.local/bin. You only need to do this once. To rebuild automatically on future updates, add this hook:
vim.api.nvim_create_autocmd("PackChanged", {
callback = function(args)
local data = args.data or {}
local spec = data.spec or {}
if spec.name ~= "nvim-context" then
return
end
if data.kind == "install" or data.kind == "update" then
vim.cmd.NvimContextInstall()
end
end,
})lazy.nvim:
{
"git@github.com:terkelg/nvim-context.git",
build = ":NvimContextInstall",
config = function()
require("nvim-context").setup()
end,
}You can also install the CLI directly with Go:
go install github.com/terkelg/nvim-context/cmd/nvim-context@latestClaude support is enabled by default. The plugin starts the Go CLI in Claude mode, writing lockfiles under ~/.claude/ide and serving the native WebSocket bridge.
- Install the plugin in Neovim.
- Run
:NvimContextInstall. - Open Neovim in the project you want Claude to see.
- Start Claude from the same project root:
claude --ideThe --ide flag is not required if IDE integration is already enabled in your Claude settings.
Claude should show In <file> once it attaches to the current Neovim buffer.
To disable the Claude bridge:
require("nvim-context").setup({
claude = { enable = false },
})Register the stdio server for Codex or other MCP-capable agents:
codex mcp add nvim -- nvim-context mcpOr add it directly to ~/.codex/config.toml:
[mcp_servers.nvim]
command = "nvim-context"
args = ["mcp"]The MCP surface is one tool: nvim_get_active_context. It returns the current file path, cursor position, current and latest tracked selection, diagnostics, workspace folders, cwd, and root.
If you disabled the Claude bridge, the MCP server still works independently through nvim-context mcp.
The CLI can also be called directly, which makes it useful in skills or any script that needs editor context:
nvim-context active-context
nvim-context statuslocal s = require("nvim-context").status()
-- s.claude true when Claude Code is connected
-- s.mcp true when an MCP client is connectedExample statusline component:
local function ai_status()
local s = require("nvim-context").status()
if s.claude or s.mcp then
return ""
end
return ""
end:NvimContextInfo- show manifest information:NvimContextStatus- show bridge status:NvimContextInstall- build the Go CLI from the plugin source
