Search-based Code Navigation
Learn and understand about Search-based Code Navigation.
Sourcegraph comes with a default built-in code navigation provided by search-based heuristics. It works out of the box with all of the most popular programming languages.
How does it work?
Search-based Code Navigation provides 3-core navigation features:
- Jump to definition: Performs a symbol search.
- Hover documentation: First, finds the definition. Then, extracts documentation from comments near the definition.
- Find references: Performs a case-sensitive word-boundary cross-repository plain text search for the given symbol
Search-based Code Navigation also filters results by file extension and by imports at the top of the file for some languages.
What configuration settings can I apply?
The symbols container recognizes these environment variables:
Env Vars | Deafult | Details |
---|---|---|
CTAGS_COMMAND | universal-ctags | Ctags command (should point to universal-ctags executable compiled with JSON and seccomp support) |
CTAGS_PATTERN_LENGTH_LIMIT | 250 | The maximum length of the patterns output by ctags |
LOG_CTAGS_ERRORS | false | Log ctags errors |
SANITY_CHECK | false | Check that go-sqlite3 works then exit 0 if it's ok or 1 if not |
SYMBOLS_CACHE_DIR | /tmp/symbols-cache | Directory in which to store cached symbols |
SYMBOLS_CACHE_SIZE_MB | 100000 | Maximum size of the disk cache (in megabytes) |
CTAGS_PROCESSES | strconv.Itoa(runtime.GOMAXPROCS(0)) | Number of concurrent parser processes to run |
REQUEST_BUFFER_SIZE | 8192 | Maximum size of buffered parser request channel |
PROCESSING_TIMEOUT | 2 hrs | Maximum time to spend processing a repository |
MAX_TOTAL_PATHS_LENGTH | 100000 | Maximum sum of lengths of all paths in a single call to git archive |
USE_ROCKSKIP | false | Enables Rockskip for fast symbol searches and search-based code navigation on repositories specified in ROCKSKIP_REPOS , or respositories over ROCKSKIP_MIN_REPO_SIZE_MB in size |
ROCKSKIP_REPOS | N/A | In combination with USE_ROCKSKIP=true this specifies a comma-separated list of repositories to index using Rockskip |
ROCKSKIP_MIN_REPO_SIZE_MB | N/A | In combination with USE_ROCKSKIP=true all repos that are at least this big will be indexed using Rockskip |
MAX_CONCURRENTLY_INDEXING | 4 | Maximum number of repositories being indexed at a time by Rockskip (also limits ctags processes) |
The default values for these environment variables come from config.go
.
To enable precise code navigation for your repository, see our docs here.