huggingface / llm-ls

LSP server leveraging LLMs for code completion (and more?)
Apache License 2.0
553 stars 43 forks source link

Add support for properly interpreting `context.selectedCompletionInfo` #66

Closed spew closed 6 months ago

spew commented 6 months ago

When vscode shows a popup Completion item (i.e. what they used to call intellisense: a regular language syntax or function that vscode knows about), any inline completion is supposed to start with the Completion item. That is to say, the completion item should be added to the end of the prefix. Take the following python example:

file_path = '/tmp/my-file'
with open(file_path, "r") as handle:
   # imagine the developer is in the middle of typing the period below
   obj = json.
   if obj.myField:
       print('my field is present')

So imagine the developer is typing the . in the line obj = json., vscode will pop up possible completions for json, and likely the method loads will be the top completion. The prefix that is sent to the LLM should use a value of obj = json.loads for that line. The suffix that comes after should also be included as normal.

The range that should be returned for the vscode.InlineCompletionItem should be properly adjusted for this as well. However, this portion is probably not related to this project.

McPatate commented 6 months ago

Hi @spew, you should open an issue in https://github.com/huggingface/llm-vscode, we'll deal with it there.

Thanks for reporting!

spew commented 6 months ago

I don't think llm-vscode can properly handle it without some help from this project.

spew commented 6 months ago

Created https://github.com/huggingface/llm-vscode/issues/127