Skip to content

feat: Support using web ide in the language server

Description

It addresses almost all the blockers that prevent running the language server and streaming in the Web IDE. The only missing requirement is providing the authentication token to the language server.

What blockers are addressed by this Merge Request?

  • It fixes a bug where Position and Range objects are not serialized before sending them to the language server. Initially, I provided a solution that handled these objects in the language server gitlab-org/editor-extensions/gitlab-lsp!199 (closed). This approach is incorrect because I discovered that VSCode's Position and Range classes use computed properties for like line , character , etc. The correct solution is converting these class-based objects to plain javascript objects.
  • It sends a baseAssetsUrl to the language server. This URL is used to property load Treesitter WASM files.

This Merge Request depends on the language server merge request: gitlab-org/editor-extensions/gitlab-lsp!201 (merged)

Related Issues

Resolves #[issue_number]

How has this been tested?

  1. Check out gitlab-org/editor-extensions/gitlab-lsp!201 (merged) in the language server project.

  2. Run npm run bundle && npm link in the language server project.

  3. Check out this branch in the web-ide's gitlab-vscode-workflow submodule.

  4. Run npm link @gitlab-org/gitlab-lsp --save .

  5. Create a Personal Access Token in gitlab.com

  6. Apply the following patch in the submodule and set your PAT in the empty string

    diff --git a/src/common/language_server/language_client_wrapper.ts b/src/common/language_server/language_client_wrapper.ts
    index 45c8ac8c..8cf07e05 100644
    --- a/src/common/language_server/language_client_wrapper.ts
    +++ b/src/common/language_server/language_client_wrapper.ts
    @@ -71,7 +71,7 @@ export class LanguageClientWrapper {
    }
    const settings: IConfig = {
    baseUrl: platform.account.instanceUrl,
    -      token: platform.account.token,
    +      token: platform.account.token || '',
    telemetry: {
    actions: [{ action: TRACKING_EVENTS.ACCEPTED }],
    },
  7. Run yarn start:example

  8. Use the web ide in localhost:8000.

  9. Enable the following feature flags: languageServerWebIDE and streamCodeGenerations in the User Settings JSON in the Web IDE.

  10. Reload the page.

  11. Streaming and inline suggestions should work as demonstrated in the video below.

Screenshots (if appropriate):

The following video shows a demo of Streaming and Inline completions working in the Web IDE

language_server_in_web_ide_demo_compressed

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)
  • Test gap
Edited by Enrique Alcántara

Merge request reports