nvim-context

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Neovim context provider

Neovim上下文提供器

Purpose

用途

Provides live context from the user's Neovim editor session to help answer context-aware questions about code.
从用户的Neovim编辑器会话中提供实时上下文,帮助回答与代码相关的上下文感知类问题。

How it works

工作原理

  1. Executes the
    nvim-context
    tool to get the current editor state.
  2. Returns JSON data including cursor position, open file, visual selection and diagnostics.
  3. Use this information to understand references like "this line", "the selection", "current file", etc.
  1. 执行
    nvim-context
    工具获取当前编辑器状态。
  2. 返回包含光标位置、打开的文件、可视选区和诊断信息的JSON数据。
  3. 利用这些信息理解诸如“这一行”“该选区”“当前文件”等指代内容。

Usage examples

使用示例

  • "What's wrong with this line?" → Check diagnostics at cursor
  • "Explain the selected code" → Analyze visual selection
  • "What file am I in?" → Return current file path
  • "Show me all errors" → List all LSP diagnostics
  • “这一行有什么问题?” → 检查光标位置的诊断信息
  • “解释选中的代码” → 分析可视选区内容
  • “我当前在哪个文件里?” → 返回当前文件路径
  • “显示所有错误” → 列出所有LSP诊断信息

Technical details

技术细节

To use this skill, execute the
nvim-context
CLI command which outputs JSON:
json
{
  "cursor": {
    "line": 43,
    "col": 3
  },
  "file": "/path/to/current/file.rb",
  "selection": null,
  "diagnostics": []
}
要使用该技能,需执行
nvim-context
CLI命令,其输出为JSON格式:
json
{
  "cursor": {
    "line": 43,
    "col": 3
  },
  "file": "/path/to/current/file.rb",
  "selection": null,
  "diagnostics": []
}

Implementation

实现方式

When this skill is loaded, execute
nvim-context
via Bash and parse the JSON output to understand the current editor state. Use the returned data to answer user questions about their code.
加载该技能后,通过Bash执行
nvim-context
并解析JSON输出,以了解当前编辑器状态。利用返回的数据回答用户关于其代码的问题。