Precise Code Navigation
Learn and understand about Precise Code Navigation.
Precise Code Navigation is an opt-in feature that is enabled from your admin settings and requires you to upload indexes for each repository to your Sourcegraph instance. Once setup is complete on Sourcegraph, precise code navigation is available for use across popular development tools:
- On the Sourcegraph web UI
- On code files on your code host, via integrations
- On diffs in your code review tool, via integrations
- Via the Sourcegraph API
Sourcegraph automatically uses Precise Code Navigation whenever available, and Search-based Code Navigation is used as a fallback when precise navigation is not available.
Precise code navigation relies on the open source SCIP Code Intelligence Protocol, which is a language-agnostic protocol for indexing source code.
Setting up code navigation for your codebase
There are several options for setting up precise code navigation:
-
Manual indexing. Index a repository and upload it to your Sourcegraph instance:
-
Automate indexing via CI: Add indexing and uploading to your CI setup.
-
Auto-indexing: Sourcegraph will automatically index your repositories and enable precise code navigation for them.
-
Set up auto-dependency indexing to navigate and search through the dependencies your code uses:
- Go: Enable auto-indexing and Sourcegraph will start indexing your dependencies.
- JavaScript, TypeScript: Enable auto-indexing and set up an npm dependencies code host.
- Java, Scala, Kotlin: Enable auto-indexing and set up a JVM dependencies code host.
Supported languages and indexers
Precise Code Navigation requires language-specific indexes to be generated and uploaded to your Sourcegraph instance. We currently have precise code navigation support for the languages below. See the indexers page for a detailed breakdown of each indexer's status.
Language | Indexer | Status |
---|---|---|
Go | scip-go | π’ Generally available |
TypeScript, JavaScript | scip-typescript | π’ Generally available |
C, C++ | scip-clang | π‘ Partially available |
Java, Kotlin, Scala | scip-java | π’ Generally available |
Rust | rust-analyzer | π’ Generally available |
Python | scip-python | π’ Generally available |
Ruby | scip-ruby | π’ Generally available |
C#, Visual Basic | scip-dotnet | π‘ Partially available |
The easiest way to configure precise code navigation is with auto-indexing. This feature uses Sourcegraph executors to automatically create indexes for the code, keeping precise code navigation available and up-to-date.
Precise navigation examples
The following repositories have precise code navigation enabled:
Programming Language | Repos |
---|---|
Go | - kubernetes/kubernetes - gohugoio/hugo - gin-gonic/gin |
Java | - netflix/hystrix - jkd@v11 |
Scala | - scalameta/metals |
Kotlin | - fwcd/kotlin-language-server |
Python | - django/django - pre-commit/pre-commit |
TypeScript | - vuejs/vue - angular/angular - nestjs/nest - puppeteer/puppeteer |
Ruby | - Shopify/shopify-api-ruby - Homebrew/brew |
Rust | - rust-lang/cargo - rust-lang/rustlings |
More resources
Writing a SCIP indexer
Learn how you can write an indexer to emit SCIP with Sourcegraph.
Adding precise code navigation to CI/CD workflows
Learn how to add precise code navigation to CI/CD workflows to Sourcegraph.