LSP support
To make the AI assistant more context-aware, allow it to use these Language Server Protocol (LSP) features:
- Diagnostics: Let the LLM see errors/warnings to self-correct its suggestions.
- Go-to-Definition: Allow the LLM to look up the source code of functions and variables.
- Find-References: Allow the LLM to see where code is being used.
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
Yeah that would be really good, especially the diagnostics part, since this is too specific for each editor, and we have integration with editors, each editor could add that as some kind of context?
Ex:
- in eca-emacs, we call
lsp-diagnostics(or eglot similar), get result and send to eca as context.
One problem is: should we send what file diagnostics? or maybe the whole project diagnostics?
Hum, that would work only when user sends the prompt, but when LLM runs a toolcall those diags would be outdated, which would be a problem
Another idea: Maybe just have a native ECA tool: eca_lsp_diagnostics:
- when LLM call this tool, we ask editor via a server request
editor/lspDiagnostics - we get those diags via each editor LSP (lsp-mode, eglot etc) and respond with those to eca server
- eca respond to LLM the diags found
With this idea, we would basically support all LSPs, but require a new request handling in each editor, but sounds good
The second idea sounds good. I'm throwing in other takes on this:
https://github.com/manzaltu/claude-code-ide.el/blob/main/claude-code-ide-diagnostics.el
https://github.com/sst/opencode/tree/dev/packages/opencode/src/lsp
Interesting, it seems claude uses a tool called getDiagnostics, so same idea indeed. Opencode on other hand seems to spawn the lsp server which is slower and probably not ideal
I will start work on that following my second idea
Ok, I added support for eca-emacs to return lsp-mode diagnostics, works smoothly
I'll mark this as done as diagnostics are probably the most critical data we should support, if we desire other LSP features we can create issues for those if requested
@ericdallo would be good to have goto definition, find references, and rename symbol. Should these all be separate issues?
Yes, but TBH I'm interested in knowing real cases of when this proves really useful