Skip to main content
Code Navigation gives you fast, accurate ways to move through your codebase directly in the Sourcegraph web UI and in supported editor extensions. Instead of manually searching for where a function is defined or which files call a particular method, you can navigate with a single click — even across repository boundaries.

What Code Navigation provides

Go to definition

Click any symbol to jump directly to where it is defined, even if the definition lives in a different repository or an external dependency.

Find references

See every location that uses a symbol across all indexed repositories, including both precise and search-based results, in a panel at the bottom of the page.

Hover documentation

Hover over any symbol to see its type signature and inline documentation without leaving the current file.

Find implementations

At an interface definition, see every concrete implementation across repositories. At a struct or class, jump to the interfaces it implements.
In addition to navigation, Code Navigation surfaces actions when you are browsing a file:
  • Open in Editor — open the current file in your configured local editor
  • View History — see the full commit history for the file
  • Blame — show inline blame annotations for every line
  • Open in code host — jump to the file on GitHub, GitLab, or Bitbucket
  • Permalink — copy a link to the exact line range you are viewing

Precise vs search-based navigation

Sourcegraph supports two navigation modes. Both are available simultaneously — precise results are shown first when available, and search-based results fill in the rest.
Precise Code Navigation uses compile-time information generated by a SCIP indexer to produce compiler-accurate results. It understands the actual semantics of the code, not just text patterns.Benefits:
  • Correct results even when symbols share a name
  • Cross-repository navigation follows actual import graphs
  • Tracks references into and out of external package dependencies
  • No false positives from coincidental text matches
Precise navigation requires uploading a SCIP index for each repository. This can be done manually or automatically with auto-indexing.
When a precise index exists for a repository, Sourcegraph automatically uses precise navigation and supplements it with search-based results for any symbols not covered by the index.

Supported languages for precise navigation

Precise Code Navigation is available for the following languages via official SCIP indexers:
LanguageIndexerCross-repo support
Goscip-goYes
TypeScript / JavaScriptscip-typescriptYes
Pythonscip-pythonYes
Javascip-javaYes
Kotlinscip-javaYes
Scalascip-javaYes
C / C++scip-clangYes
Rustrust-analyzer (SCIP mode)Yes
Rubyscip-rubyYes
Additional languages are supported via community-maintained indexers. For languages without a precise indexer, search-based navigation applies automatically.

Using Code Navigation

In the Sourcegraph web UI

Open any file in Sourcegraph. Hover over a symbol to see its type signature and documentation. From the hover panel you can:
  • Click Go to definition to navigate to the symbol’s definition
  • Click Find references to open the references panel
  • Click Find implementations (for interfaces and abstract types)
The references panel groups results by repository and file, and distinguishes between definitions, references, and implementations.

In VS Code

Install the Sourcegraph VS Code extension to bring Code Navigation into your editor. Once configured with your Sourcegraph instance URL, the extension provides:
  • Hover documentation for symbols in files you are editing
  • Go to definition that can follow imports into external repositories indexed by Sourcegraph
  • Find references across your entire connected codebase, not just the local project
The VS Code extension is most powerful when combined with precise indexing. Results for precisely-indexed repositories are compiler-accurate and cross-repository.

Auto-indexing

Auto-indexing automatically generates and uploads SCIP indexes for your repositories on a schedule. Once enabled by a site administrator, Sourcegraph detects the language and build configuration of each repository and runs the appropriate indexer without manual setup. To check whether a repository has a precise index, open a file and hover over a symbol. The hover panel displays a badge indicating whether the result comes from a precise index or search-based heuristics.
Auto-indexing requires executors to be configured on your Sourcegraph instance. Ask your site administrator to enable it.

Manually uploading an index

If auto-indexing is not available, you can generate and upload a SCIP index manually using the Sourcegraph CLI:
# Example for a Go repository
scip-go

# Upload the generated index
src code-intel upload -file=index.scip
Refer to the documentation for each language’s indexer for the exact commands and configuration options.

Frequently asked questions

Search-based navigation can return results from any file containing the symbol name, including files in other repositories where the name is coincidentally the same. Precise navigation only returns results that are semantically connected to the symbol you clicked. If you have precise indexing enabled, precise results appear first and are labeled accordingly.
When a symbol has more than 500 references, Sourcegraph truncates the panel to avoid browser performance issues. To see all references, use Code Search with a query targeting the symbol name. This gives you the full filtering and pagination capabilities of search.
Open a file in the repository and hover over a symbol. The hover panel displays a label indicating “precise” or “search-based”. You can also check the repository’s indexing status in the site admin panel under Code Intelligence.
Yes, with precise indexing. Precise indexers capture cross-package references at compile time. If the dependency is also indexed in Sourcegraph (for example, as a public repository), you can navigate directly into it. Search-based navigation does not cross package boundaries.
Yes. Code Navigation is available in the Sourcegraph code review view and in pull request integrations with GitHub, GitLab, and Bitbucket. Hover and go-to-definition work on diff lines so you can navigate while reviewing changes.

Deep Search

Ask natural language questions about your codebase when you need explanation rather than navigation.

Code Search

Find all occurrences of a symbol using structured queries with full filtering capabilities.

Batch Changes

Use precise reference data to confidently make automated changes to every call site of a symbol.

Admin overview

Configure auto-indexing and executors for your Sourcegraph instance.

Build docs developers (and LLMs) love