Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Latest commit

 

History

History

template

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Code intelligence for LANG

This extension provides LANG code intelligence on Sourcegraph.

🗃️ Source code

Go code intelligence

Usage

  1. 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.
  2. Visit any LANG code file on Sourcegraph.
  3. 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.

On your code host

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:

  1. Follow the usage steps above to enable this extension.
  2. 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.
  3. 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.

screenshot of using LANGID on GitHub

Search-based code intelligence

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.

Indexed and archived repositories

To include indexed and/or archived repositories in search results, add the following to your Sourcegraph global settings:

  "basicCodeIntel.includeForks": true,
  "basicCodeIntel.includeArchives": true

Large repositories

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

Many repositories

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