Skip to content

terkelg/nvim-context

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nvim-context

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.

Install

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:

:NvimContextInstall

This 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@latest

Claude Code

Claude 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.

  1. Install the plugin in Neovim.
  2. Run :NvimContextInstall.
  3. Open Neovim in the project you want Claude to see.
  4. Start Claude from the same project root:
claude --ide

The --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 },
})

MCP

Register the stdio server for Codex or other MCP-capable agents:

codex mcp add nvim -- nvim-context mcp

Or 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.

CLI

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 status

Status

local s = require("nvim-context").status()
-- s.claude  true when Claude Code is connected
-- s.mcp     true when an MCP client is connected

Example statusline component:

local function ai_status()
  local s = require("nvim-context").status()
  if s.claude or s.mcp then
    return "󰚩"
  end
  return ""
end

statusline

Commands

  • :NvimContextInfo - show manifest information
  • :NvimContextStatus - show bridge status
  • :NvimContextInstall - build the Go CLI from the plugin source

About

Expose live Neovim context to Codex, Claude, and other coding agents.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors