LSP-copilot icon indicating copy to clipboard operation
LSP-copilot copied to clipboard

Does it Use Open Tabs? Needs documentation

Open pha3z opened this issue 1 year ago • 6 comments

One of the big R&D points over the past couple of years on the use of Copilot is how to make Copilot better at understanding the context of your local repo. Its critical to using it as efficiently as possible.

In VS Code and Visual Studio, out-of-the-box, the Copilot extensions give high priority on Open Tabs as input for context. LSP-copilot does not mention whether Open Tabs --or even your local folders-- have an impact on context.

It would be nice if this were documented. Can we at least get an answer on this post?

pha3z avatar Oct 05 '24 20:10 pha3z

Some facts...

  • We are using the LSP server from Copilot.vim.
  • The LSP server is not open sourced and it has no doc (literally none). @TerminalFi did some reverse engineering to make it work here.

jfcherng avatar Oct 05 '24 21:10 jfcherng

Ahh.. I had to go do some reading to get educated on language servers. I see now why this is non-trivial.

Just out of curiosity, have you seen this project? I discovered it from digging around on language servers. https://github.com/SilasMarvin/lsp-ai

pha3z avatar Oct 05 '24 21:10 pha3z

I found this https://stackoverflow.com/a/77659136/1402498 and this https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/

These shed light on the fact that Copilot's awareness is dependent on the didOpen, didClose, and didChange invocations to the LSP. This is how, as the IDE/editor client, you would notify the LSP about open tabs.

pha3z avatar Oct 05 '24 22:10 pha3z

Theoretically, when a project is open, the language server instance will be initiated. It will know the project path. So theoretically, it can do what it want to do with the whole project without didXxx notification from the client. It can depend on didXxx too for sure.

But since it's not open sourced and there is no doc, we can only either guess by its behaviors (can it provide good suggestion without other files in the project being opened?) or reverse engineer it.

jfcherng avatar Oct 05 '24 22:10 jfcherng

Just out of curiosity, have you seen this project? I discovered it from digging around on language servers. SilasMarvin/lsp-ai

Yes it was posted on ST Discord server before. But I think the real issue is ST's APIs can only provide quite limited UX.

jfcherng avatar Oct 05 '24 22:10 jfcherng

@pha3z Copilot gets all of the regular LSP notifications. Its context is also driven by References that are included on every "turn" message you send to Copilot. We have a very simple implementation, that mirrors the majority of Copilot in VSCode for what we can emulate,

https://github.com/TerminalFi/LSP-copilot/blob/1aaad34e241cf0cc87dae08002d696628b944910/plugin/helpers.py#L230-L247

There is definitely improvements that can be made. However this is very much a hobby of @jfcherng and myself. @timfjord contributed initially as well however his time is also focused else where for the most part.

I am currently more focus on projects which may generate revenue at this point.

However, I have spoken to the VP over the Copilot team a few months...6-9 months now I guess and Github/M$ does plan on releasing a SDK / Documentation. However, when / if that happens has yet to be seen.

Until then, I encourage the community to reverse the current implementations out there and contribute back to this plugin if they indeed want to see it become more feature complete.

TerminalFi avatar Oct 06 '24 00:10 TerminalFi