eca icon indicating copy to clipboard operation
eca copied to clipboard

LSP support

Open zikajk opened this issue 1 year ago • 9 comments

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.

zikajk avatar Aug 16 '25 19:08 zikajk

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

ericdallo avatar Aug 16 '25 23:08 ericdallo

Another idea: Maybe just have a native ECA tool: eca_lsp_diagnostics:

  1. when LLM call this tool, we ask editor via a server request editor/lspDiagnostics
  2. we get those diags via each editor LSP (lsp-mode, eglot etc) and respond with those to eca server
  3. 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

ericdallo avatar Aug 16 '25 23:08 ericdallo

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

zikajk avatar Aug 17 '25 08:08 zikajk

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

ericdallo avatar Aug 17 '25 14:08 ericdallo

I will start work on that following my second idea

ericdallo avatar Aug 17 '25 14:08 ericdallo

Ok, I added support for eca-emacs to return lsp-mode diagnostics, works smoothly

Image

ericdallo avatar Aug 18 '25 01:08 ericdallo

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 avatar Aug 18 '25 12:08 ericdallo

@ericdallo would be good to have goto definition, find references, and rename symbol. Should these all be separate issues?

noctuid avatar Feb 25 '26 22:02 noctuid

Yes, but TBH I'm interested in knowing real cases of when this proves really useful

ericdallo avatar Feb 25 '26 23:02 ericdallo