@sourcegraph/lsp-client

Library that connects Sourcegraph extensions to language servers

Usage no npm install needed!

<script type="module">
  import sourcegraphLspClient from 'https://cdn.skypack.dev/@sourcegraph/lsp-client';
</script>

README

@sourcegraph/lsp-client

npm downloads build codecov code style: prettier semantic-release

Library that connects Sourcegraph extensions to language servers

Install

npm install @sourcegraph/lsp-client
# or
yarn add @sourcegraph/lsp-client

Usage

import * as sourcegraph from 'sourcegraph'
import * as lspClient from '@sourcegraph/lsp-client'

export async function activate(ctx: sourcegraph.ExtensionContext): Promise<void> {
  const config = sourcegraph.configuration.get().value
  const client = await lspClient.register({
    sourcegraph,
    transport: lspClient.webSocketTransport({ serverUrl: config['myExtension.serverUrl'] }),
    documentSelector: [{ language: 'myLanguage' }],
    clientToServerURI: uri => ..., // optional
    serverToClientURI: uri => ..., // optional
  })
  ctx.subscriptions.add(client)
}

Contributing

Build

yarn
yarn build

Test

yarn test

Release

Releases are done automatically in CI when commits are merged into master by analyzing Conventional Commit Messages. After running yarn, commit messages will be linted automatically when committing though a git hook. The git hook can be circumvented for fixup commits with git's fixup! autosquash feature, or by passing --no-verify to git commit. You may have to rebase a branch before merging to ensure it has a proper commit history, or squash merge with a manually edited commit message that conforms to the convention.