This repository contains the code for the Sourcegraph extensions that provide code intelligence. These extensions provide precise code intelligence via LSIF and Language Servers, and provides fuzzy code intelligence using a combination of ctags and search.
src/extensions/go
The Go extension (supports LSP)src/extensions/typescript
The TypeScript extension (supports LSP)src/extensions/template
Template for all other languages (does not support LSP)shared/language-specs
Language definitions, which are fed into the template to instantiate many language extensions
-
Run
yarn
-
Run
yarn --cwd extensions/{go,typescript,template} run serve
(pick one,template
includes all others) -
Open up your Sourcegraph settings https://sourcegraph.com/users/you/settings and disable the language extensions you're developing:
{ ... "extensions": { "sourcegraph/cpp": false, ... } }
-
Sideload the extension (hit OK on the alert to accept the default URL http://localhost:1234) on your Sourcegraph instance and refresh the page. Make sure you don't see two of the same language extension in the Ext menu.
- Add an entry to the
shared/language-specs
directory. For languages with a trivial configuration add a new entry (in alphabetical order) tolanguages.ts
. Otherwise, add additional files following the existing examples. - (optional, to enable jump to definition) Ensure the language is present in the command line arguments to universal-ctags https://github.com/sourcegraph/sourcegraph/blob/21efc6844838e773b9a8f4a7ba1d5628e8076984/cmd/symbols/internal/pkg/ctags/parser.go#L71
- Make sure there is a mapping entry for the
languageID
in https://github.com/sourcegraph/sourcegraph/blob/master/shared/src/languages.ts#L40 - Generate and publish the extension as described below.
Typically you do not need to explicitly generate and publish extensions. By default, extensions are generated and published in BuildKite from the master branch.
If you need to manually generate/publish extensions, do so as follows:
Generate:
- Specific template extensions:
yarn run generate --languages=foo,bar
- All known template extensions:
yarn run generate
Publish:
- Ensure the
src
command-line tool is installed on your PATH, and environment variables are set:SRC_ENDPOINT
should be the URL of your instance.SRC_ACCESS_TOKEN
should contain an access token for your instance.
- Publish:
- Specific template extensions:
yarn run publish --languages=foo,bar
- All the template extensions:
yarn run publish
- Go:
yarn run publish:go
- TypeScript:
yarn run publish:typescript
- Specific template extensions: