Replies: 2 comments
-
|
You can provide that with #{buffer} |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your quick response! Inclusion of the code is essential to a very common workflow I regularly utilized, so I added a workflow to my configuration and am leaving my approach here in case others have the issue. (Claude helped me summarize my approach below:) ProblemThe built-in "Explain LSP Diagnostics" action uses ${lsp.diagnostics} which only sends metadata (line numbers, severity, messages) to the LLM—not the actual source code. This makes explanations less useful since the AI can't see what's causing the error. SolutionCreate a custom workflow using the prompt_library = {
["Diagnose errors"] = {
strategy = "workflow",
description = "Explain LSP diagnostics with source code context",
opts = { index = 1, is_default = true, short_name = "lspx" },
prompts = {
{
{ role = "system", content = function(context)
return string.format("You are an expert coder...The programming language is %s.", context.filetype)
end, opts = { visible = false } },
{ role = "user", content = "Please explain the following LSP diagnostics and suggest fixes:\n\n#{lsp}",
opts = { auto_submit = true } },
},
},
},
},Note: Overriding the built-in by using the same name doesn't work—both appear. Using a unique name like "Diagnose errors" allows single-keystroke search ("d") to preserve speed in a common workflow. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-submission checklist
Neovim version (nvim -v)
0.11.5
Operating system/version
macOS 26.2
Adapter and model
anthropic
Describe the bug
When using the "Explain LSP Diagnostics" action from the action palette, the chat receives diagnostic metadata (line number, buffer ID, severity, message) but not the actual source code where the diagnostics occur.
This makes the AI response unhelpful since it can't see what code is causing the issue.
Steps to reproduce
Steps to Reproduce:
I used a file called test_lsp.lua and had the Lua LSP installed locally:
I then ran: nvim --clean -u minimal.lua test_lsp.lua, highlighted the error, hit leader a, a, enter and observed the settings
Expected behavior
Chat should include both the diagnostic info AND the relevant source code lines.
Actual:
Only diagnostic metadata is included. Example:
Line: 5, Buffer: 1, Severity: Error, Message: "undefined variable"
Missing: the actual code on line 5.
Screenshots or recordings (optional)
No response
minimal.lua file
Log output (optional)
No response
Minimal reproduction confirmation
minimal.luafile that reproduces the issueBeta Was this translation helpful? Give feedback.
All reactions