Code intelligence

Code intelligence makes browsing code easier, by adding the following features to your code:

IDE-like hovers



These features are powered by language servers based on the open-source Language Server Protocol.

Code intelligence on Sourcegraph Server lets you browse code like you're in an IDE when viewing code search results. It also works on code review diffs on GitHub and Phabricator with our browser extensions.

Code intelligence is a paid feature of Sourcegraph Server. While code search works on all languages, code intelligence requires a language server for each language. So, you can add code intelligence based on your language needs.

Getting started

Code intelligence can be enabled on most Sourcegraph Servers by setting two configuration options. Refer to the documentation for your language for full instructions.

Note: Currently, code intelligence is only available for Sourcegraph Server deployed with Data Center. It will soon be available for the single-server Docker image deployment. Contact us for a preview of code intelligence for the single-server deployment.

What is the Language Server Protocol (LSP)?

The Language Server protocol is used between a tool (the client) and a language smartness provider (the server) to integrate features like auto complete, go to definition, find all references and alike into the tool

official Language Server Protocol specification

The LSP was created by Microsoft to define a common language for programming language analyzers to speak. Today, several companies have come together to support its growth, including Red Hat, GitHub, Facebook, and Sourcegraph, and the protocol is becoming supported by a rapidly growing list of editor and language communities.

As language servers are built and improved to production-quality by the community, Sourcegraph will inevitably support code intelligence for all languages. Visit for details on and links to current client and server implementations.

Supported languages

Currently, Sourcegraph has enhanced support for projects written in the following programming languages and using the following build tools out of the box. Companies with custom build systems can still get code intelligence: refer to the documentation for your language or contact [email protected] for more details.

Language Build/packaging tools Notes
Go * Packages using cgo aren't supported
Java Maven, Gradle, custom Maven plugins will not be executed (including the maven replacer plugin, which is often used to generate Java source files from templates). Gradle support is ad-hoc; use our Gradle plugin to generate a javaconfig.json file if our service can't handle your Gradle project.
TypeScript npm, yarn Use an optional tsconfig.json config file for explicit configuration
JavaScript npm, yarn Use an optional jsconfig.json config file for explicit configuration. Works best with ES6 modules ( import and export ).
PHP Composer In preview (set lsp.previewLanguages to true in User Settings to enable). Please report issues you see.
Python pip We don't run or pip install ; rather, when we encounter an import, we try to infer the package name and run pip download (and avoid running the downloaded package's ). This is expected to work as long as the name of the package on PyPI is the same as the name that's imported in the source code. In the future, we'll check for a requirements.txt file (standard, but not always used) in order to know for sure what the dependencies are.

As language servers are built and improved to production-quality by the community, Sourcegraph will inevitably support code intelligence for all languages.