Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lsp): improve registry completion suggestions #13023

Merged
merged 4 commits into from
Dec 13, 2021

Conversation

kitsonk
Copy link
Contributor

@kitsonk kitsonk commented Dec 8, 2021

Resolves #10051

Still need to do all the tests, but it works. If folks want to take if for a road test, you can enable a prototype registry server by setting the following in your editor configuration:

{
  "deno.enable": true,
  "deno.suggest.imports.hosts": {
    "https://regv2.deno.dev": true
  }
}

The server "proxies" the information from deno.land/x/. Things registry servers can now implement with v2 are:

  • Ability to return partial result sets. This is done in a backwards compatible fashion, where a server can either return a string[] or an JSON object like:

    interface VariableItemsList {
      items: string[];
      isIncomplete?: boolean;
      preselect?: string;
    }

    Where if isIncomplete is true, it indicates that not all the results have been returned and subsequent queries to the "url" field can be sent by the client to narrow down the result set.

  • Ability to preselect particular selections, by setting the "preselect" value in the variable list response. This allow a registry, for example, to tell the client to choose mod.ts as the default selection when completing an import (or whatever the server determines is the appropriate preselection.

  • Ability to provide additional documentation for a suggestion/completion item by providing a "documentation" endpoint as part of the deno-import-intellisense.json. When the client displays a particular item, it will request the server to resolve the completion item, and if the "documentation" endpoint is set, a request will be made to that completion endpoint. The endpoint should response with a documentation object:

     interface Documentation {
      kind: "markdown" | "plaintext";
      value: string;
    }

Technically, all these changes are non-breaking with v1, and the language server will simply adjust based on the runtime behaviour of the registry. The only real change is that v2 will cause the language server to validate the deno-import-intellisense.json in against the v2 specification.

@kitsonk kitsonk marked this pull request as ready for review December 10, 2021 01:30
@kitsonk kitsonk requested a review from lucacasonato December 10, 2021 01:31
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I don't have any comments to the code, but I will let Luca or David approve.

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kitsonk kitsonk merged commit a54fc7a into denoland:main Dec 13, 2021
@kitsonk kitsonk deleted the kitsonk/issue10051 branch December 13, 2021 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lsp: Proposal for module registry information v2
3 participants