This extension provides LANG code intelligence on Sourcegraph.
- Enable the
sourcegraph/LANGID
extension:- On Sourcegraph.com, visit the extension page to enable it.
- On a self-hosted Sourcegraph instance, select User menu > Extensions, search for
sourcegraph/LANGID
, and enable it.
- Visit any LANG code file on Sourcegraph.
- Hover over a token in the code file.
- See a description of the token.
- Click Go to definition (if available) to go to the token's definition.
- Click Find references to see all references to the token.
This extension adds the same features to code files and diffs on your code host if you're using the Sourcegraph browser extension. To use it on your code host:
- Follow the usage steps above to enable this extension.
- Install the Sourcegraph browser extension.
- If you're using it with a self-hosted Sourcegraph instance, enter the Sourcegraph instance URL into the Sourcegraph browser extension options menu. Then click the gear icon and enable Experimental features: Use extensions.
- Visit any file on your code host and hover over a token to see a description of the token, a Go to definition action (if available), and a Find references action.
This extension comes with built-in code intelligence provided by search-based heuristics. Because this extension uses text-based heuristics, its definition and reference results are not precise:
- "Go to definition" on a token goes to the definition found by universal-ctags, a cross-language parsing suite.
- "Find references" on a token finds all instances of token (with the same case) in the current repository and other repositories.
These heuristics work well for tokens with unique names, such as render_to_view
or TLSConfig
. They do not work well for ambiguous tokens, such as open
or file
.
To include indexed and/or archived repositories in search results, add the following to your Sourcegraph global settings:
"basicCodeIntel.includeForks": true,
"basicCodeIntel.includeArchives": true
Search-based code intelligence will perform a search query in the commit you are viewing. This may cause performance issues if the commit is not indexed and the repository is large. After a timeout period with no results, an index-only search will be performed. This type of query may return results for a commit other than the one you are currently viewing. The default timeout period is five seconds, but can be lowered by adding the following to your Sourcegraph global settings (units are milliseconds):
"basicCodeIntel.unindexedSearchTimeout": 1000
For organizations that organize code in a monorepo, it may never be useful to perform an un-indexed search. To force only indexed search queries, add the following to your Sourcgraph global settings:
"basicCodeIntel.indexOnly": true
On instances with many repositories, global searches over all repositories can lead to issues such as: low quality results, slow response times, or significant load on the Sourcegraph instance. Global searches are enabled by default, but can disabled by adding the following to your Sourcegraph global settings:
"basicCodeIntel.globalSearchesEnabled": false