Skip to content

feat: Add optional Neovim diagnostics to context#15

Merged
pablopunk merged 1 commit into
pablopunk:mainfrom
ibeex:context_diagnostic
May 14, 2026
Merged

feat: Add optional Neovim diagnostics to context#15
pablopunk merged 1 commit into
pablopunk:mainfrom
ibeex:context_diagnostic

Conversation

@ibeex

@ibeex ibeex commented May 12, 2026

Copy link
Copy Markdown
Contributor
  • Enable sending LSP/linter diagnostics via config
  • Filter diagnostics to selection for PiAskSelection
  • Add validation and documentation for new option
  • created with pi

Summary by CodeRabbit

  • New Features

    • Optional Neovim diagnostics support: include diagnostics in AI context for full buffer or visual selection (disabled by default).
  • Documentation

    • Updated docs showing the new diagnostics option and how to enable it.
  • Bug Fixes / Validation

    • Configuration now validates the diagnostics option to ensure correct types.
  • Tests

    • Added tests verifying diagnostic inclusion behavior for buffer, selection, and default-disabled cases.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c968d5cb-2a77-4d5b-b709-2fa8d288ae18

📥 Commits

Reviewing files that changed from the base of the PR and between 1f3a78d and 4bc3814.

📒 Files selected for processing (4)
  • README.md
  • lua/pi/config.lua
  • lua/pi/context.lua
  • tests/test_pi_commands.lua
✅ Files skipped from review due to trivial changes (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • lua/pi/context.lua

Walkthrough

This PR adds optional Neovim diagnostics support to pi.nvim's context handling. A new context.diagnostics.enabled configuration option (default false) controls whether diagnostics are included in generated prompts. The implementation defines diagnostic utilities to label severity levels, detect range overlaps, and format diagnostics blocks. Integration into buffer and visual context functions conditionally appends diagnostics, with visual context filtering diagnostics to the selection line range. Tests verify diagnostics behavior when enabled, disabled, and with selection boundaries. Documentation updates describe the feature across setup examples, configuration properties, and behavioral notes.

Sequence Diagram(s)

sequenceDiagram
  participant EditorCmd as :PiAsk / :PiAskSelection
  participant get_context as M.get_buffer_context / M.get_visual_context
  participant diagnostics_block as diagnostics_block
  participant vim_diagnostic as vim.diagnostic
  participant parts as prompt_parts
  EditorCmd->>get_context: request context (bufnr, selection?)
  get_context->>diagnostics_block: call with bufnr, config (and range if visual)
  diagnostics_block->>vim_diagnostic: fetch diagnostics for bufnr
  diagnostics_block->>diagnostics_block: filter by range, map severity, format block
  diagnostics_block->>parts: append diagnostics block (if enabled & non-empty)
  get_context->>EditorCmd: return assembled prompt context
Loading

Possibly related issues

  • Add diagnostic to context #16 — Matches same objective: adding optional Neovim diagnostics to generated context and configuration via context.diagnostics.enabled.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: adding optional Neovim diagnostics to the context system, which is precisely what the changeset implements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ibeex ibeex mentioned this pull request May 12, 2026
- Enable sending LSP/linter diagnostics via config
- Filter diagnostics to selection for PiAskSelection
- Add validation and documentation for new option
@ibeex ibeex force-pushed the context_diagnostic branch from 1f3a78d to 4bc3814 Compare May 12, 2026 18:19
@pablopunk

Copy link
Copy Markdown
Owner

great idea! I might introduce a context.diagnostics.max_bytes in the future since this feature is not caring about context.max_bytes, but it's fine for now

@pablopunk pablopunk merged commit 7c7f6e3 into pablopunk:main May 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants