Code navigation
Quickly navigate your code with high precision.
Code navigation helps you quickly explore code, dependencies, and symbols within the Sourcegraph file view. Code navigation consists of a number of features that make it easier to move through your codebase without getting lost:
- Jump to definition
- Find references
- Find implementations
- Browse symbols defined in current document or folder
- Navigate dependencies
- See docstrings in hover tooltips
Code navigation has two different implementations which complement one another:
- Search-based code navigation works out of the box with all of the most popular programming languages, powered by Sourcegraph's code search. Our default search-based code navigation uses syntactic-level heuristics (no language-level semantic information) for fast, performant searches across large code bases.
- Precise code navigation uses compile-time information to provide users with an extremely precise and accurate cross-repository[^1] experience. This means you'll get an accurate view of all symbols and where they are used across your code base.
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 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 | lsif-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.
Setting up code navigation for your codebase
Sourcegraph provides search-based code navigation out-of-the-box. 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.
Explanations
- Introduction to code navigation
- Precise code navigation
- Search-based code navigation
- Code navigation features
- Beta Rockskip: Faster search-based code navigation
- Writing an indexer
- Auto-indexing
- Auto-indexing inference
How-to guides
-
General
-
Language-specific guides
-
Automate uploading code graph data
-
Best practices
- Guide to defining policies as it relates to resource usage
Reference
- Requirements
- Troubleshooting
- FAQ
- Sourcegraph-recommended indexers
- Environment variables
- Auto-indexing configuration
[^1]: Supported for any language with a SCIP indexer.