SilasMarvin / lsp-ai

LSP-AI is an open-source language server that serves as a backend for AI-powered functionality, designed to assist and empower software engineers, not replace them.
MIT License
1.82k stars 55 forks source link

crazy idea: enhance onhover for function #34

Open asukaminato0721 opened 4 days ago

asukaminato0721 commented 4 days ago

when coding with llm, we often ask llm what's one function/one part of code's functionality.

but traditional lsp could only show comment and function signatures.

so if onhover could also query the functionality, will be useful.

pros: more info from llm.

cons: increase the cost, the ai will generate different answers each time, the respond speed, etc.

McPatate commented 3 days ago

I like the idea!

cons: increase the cost, the ai will generate different answers each time, the respond speed, etc.

We could cache the responses to make it fast on second hover & keep the result consistent. We could provide a "clear cache" code action in the lsp to clear the generated text if it is unsatisfactory, either global or based on the cursor position to clear the llm-generated content. Could be regenerate rather than clear cache as well (the code action).

@SilasMarvin this would play well with what is stored in the memory backend & could add context to the function by fetching from the vector store.

asukaminato0721 commented 3 days ago

some other ideas:

hover action add test case for functions.

hover action refactor functions.

SilasMarvin commented 3 days ago

I like the idea!

cons: increase the cost, the ai will generate different answers each time, the respond speed, etc.

We could cache the responses to make it fast on second hover & keep the result consistent. We could provide a "clear cache" code action in the lsp to clear the generated text if it is unsatisfactory, either global or based on the cursor position to clear the llm-generated content. Could be regenerate rather than clear cache as well (the code action).

@SilasMarvin this would play well with what is stored in the memory backend & could add context to the function by fetching from the vector store.

Providing documentation is a really cool idea. I don't know how this plays with other language servers. If they have a language server that already provides documentation will the editor pull from both? If I understand correctly we would need to support the textDocument/hover capability unless we want to provide this as a custom function?

SilasMarvin commented 3 days ago

some other ideas:

hover action add test case for functions.

hover action refactor functions.

Code actions could be incredibly cool! I really love this. Its not the top priority on my list, but I will start looking into it. We should come up with a list of codeactions we want to provide, or we should come up with a way for users to be able to configure their own?