Skip to content

Please document CompletionItem.Kind more #1765

Open

Description

@KalleOlaviNiemitalo

I was implementing a CompletionDelegate in my command-line application. That returns IEnumerable<CompletionItem> so my completion method needs to call the CompletionItem constructor. This constructor takes a string kind = "Value" parameter but it is not clear how to decide whether the default value "Value" is correct or the caller should pass in something else. The documentation of this parameter is just "The kind of completion item." and the documentation of the CompletionItem.Kind property is the same.

From the source code, I found the internal class CompletionItemKind, which defines "Keyword" and "Value". However, that does not document their meanings either and instead references https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#textDocument_completion, and that page no longer exists.

Please expand the documentation of the parameter and the property to list the completion item kinds that have been defined, or to point to other documentation that provides this information.

Activity

  1. KalleOlaviNiemitalo commented on Jun 15, 2022

    @KalleOlaviNiemitalo
    Author
  2. baronfel commented on Jun 15, 2022

    @baronfel
    Member

    From an LSP perspective, that field is used to sort/classify completions to implicitly filter them based on the context that the user requested completions in. For example take this F# for loops - for x of y|, where | is the completion trigger point. A LSP server may know that the completion position is in an 'identifier' space, and so keyword completions should be filtered out.

    The thought here was that similar logic might be useful, but it's not currently being used. This was a bit of a forward-thinking API.

  3. KalleOlaviNiemitalo commented on Jun 17, 2022

    @KalleOlaviNiemitalo
    Author

    Would be useful in #1220, I suppose. But this would need a new directive, as SuggestDirectiveResult only outputs CompletionItem.Label (not even CompletionItem.InsertText). So a completion delegate that enumerates CompletionItem instances has currently no advantages over one that enumerates plain strings.

    var completions = completionParseResult.GetCompletions(_position);
    context.Console.Out.WriteLine(
    string.Join(
    Environment.NewLine,
    completions));

    public override string ToString() => Label;

  4. baronfel commented on Jun 17, 2022

    @baronfel
    Member

    You're exactly correct - the existing suggest needs to be updated to use the new API shapes more effectively. That's something we want to do, it just hasn't come to fruition yet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions