Code intelligence
Code Intelligence adds code navigation features common to interactive development environments (IDE), including:
- Type signatures and symbol documentation.
- Go-to definition.
Code Intelligence is built into GitLab and powered by LSIF (Language Server Index Format), a file format for precomputed code intelligence data. GitLab processes one LSIF file per project, and Code Intelligence does not support different LSIF files per branch.
Follow epic 4212 for progress on upcoming code intelligence enhancements.
Configure code intelligence
Prerequisites:
- You’ve checked the LSIF documentation to confirm an LSIF indexer exists for your project’s languages.
To enable code intelligence for a project:
-
Add a GitLab CI/CD job to your project’s
.gitlab-ci.yml
. This job generates the LSIF artifact:code_navigation: image: sourcegraph/lsif-go:v1 allow_failure: true # recommended script: - lsif-go artifacts: reports: lsif: dump.lsif
-
Depending on your CI/CD configuration, you might need to run the job manually, or wait for it to run as part of an existing pipeline.
This file is limited to 100 MB by the
(ci_max_artifact_size_lsif
)
artifact application limit. On self-managed installations, an instance administrator
can configure this value.
View code intelligence results
After the job succeeds, browse your repository to see code intelligence information:
- On the left sidebar, select Search or go to and find your project.
- Select Code > Repository.
- Go to the file in your repository. If you know the filename, either:
- Enter the
/~
keyboard shortcut to open the file finder, and enter the file’s name. - In the upper right, select Find file.
- Enter the
-
Point to lines of code. Items on that line with information from code intelligence display a dotted line underneath them:
- Select the item to learn more information about it.
Find references
Use code intelligence to see all uses of an object:
- On the left sidebar, select Search or go to and find your project.
- Select Code > Repository.
- Go to the file in your repository. If you know the filename, either:
- Enter the
/~
keyboard shortcut to open the file finder, and enter the file’s name. - In the upper right, select Find file.
- Enter the
- Point to the object, then select it.
- In the dialog, select References to view a list of the files that use this object.