Skip to content

new extension API for completion items

Warren Gifford requested to merge exp/completion into master

Created by: sqs

The new sourcegraph.languages.registerCompletionItemProvider API lets extensions register providers to suggest completions for a cursor position in an editor.

This is supported in code discussions comment input fields, GitHub issue edit/create fields, and on an experimental /snippets page on the web app.

It is feature-flagged off by default. See demo at https://sourcegraph.slack.com/archives/C89KCDK5J/p1554982303009400?thread_ts=1554799854.001300&cid=C89KCDK5J.

TODOs:

  • Factor out styling

Test plan

Also applies to #3316.

  1. Install one or more of these extensions: https://github.com/sourcegraph/sourcegraph-hubspot https://github.com/sourcegraph/sourcegraph-jira (you need to yarn run serve them, they aren't published yet)
  2. Use the following creds in your user settings to auth both of those extensions: https://sourcegraph.slack.com/files/U02FSM7DN/FHJJWGWNN/user_settings_for_trying_completion_link_preview (Sourcegraph internal link only)
  3. Run a dev server and a dev bext build
  4. In the dev bext build options menu, enable both of the new experimental feature flags

Now test one or both extensions on both GitHub and Sourcegraph:

  • To test on GitHub, go to any Markdown input box (like on an issue).

    • The first time you try to use any of these extensions, you should get a UI error message about the need to grant the bext access to the HubSpot/Jira API domains. Follow the on-screen instructions.
  • To test on Sourcegraph, go to http://localhost:3080/snippets?languageId=markdown.

    • You also need to run a cors-anywhere proxy right now to hit those APIs. git clone https://github.com/Rob--W/cors-anywhere && cd cors-anywhere && PORT=9018 node server.js and keep that running.
  • To test the HubSpot extension, try typing $ (wait for it to load all customers from HubSpot; takes up to 10-15 seconds, but is then cached) and then a customer name. Hit enter to complete the URL. When you view the Markdown, you'll see a link preview with the customer name and stats.

  • To test the Jira extension, try typing DEMO- and then either an issue number or part of an issue summary. Hit enter to complete the URL. When you view the Markdown, you'll see a link preview with the issue summary.

Note that this PR is not about those extensions per se. If you see issues on those extensions, file them on their own repositories (they are fairly WIP still).

Merge request reports

Loading