|
| 1 | +# Syntactic Code Navigation |
| 2 | + |
| 3 | +<TierCallout> |
| 4 | + Supported on [Enterprise](/pricing/enterprise) plans. |
| 5 | + <user> |
| 6 | + This feature is currently experimental and enabled by default for Cloud customers |
| 7 | + </user> |
| 8 | +</TierCallout> |
| 9 | + |
| 10 | +Syntactic code navigation is an opt-in zero configuration feature that improves code navigation for certain languages in the absence of |
| 11 | +[Precise code navigation](./precise_code_navigation) set up. It works by periodically indexing repositories for which it is [enabled](#enabling-syntactic-code-navigation), using high level syntax analysis heuristics. |
| 12 | + |
| 13 | +This mechanism is more robust than search-based navigation, but less powerful than Precise code navigation. |
| 14 | +When syntactic indexing data is available for a given file and repository, it will be selected over search-based navigation automatically, |
| 15 | +but only if Precise data is not available. To summarise the order of priorities is as follows: |
| 16 | + |
| 17 | +- Precise data |
| 18 | +- Syntactic, if no precise data available |
| 19 | +- Search-based, if no syntactic available |
| 20 | + |
| 21 | +## Enabling Syntactic code navigation |
| 22 | + |
| 23 | +First, enable the experimental feature flag in Site config: |
| 24 | + |
| 25 | +```json |
| 26 | + "experimentalFeatures.codeintelSyntacticIndexing.enabled": true |
| 27 | +``` |
| 28 | + |
| 29 | +Next, you need to ensure that syntactic indexing is enabled in a code graph configuration policy. Note that for cloud customers this feature is enabled by default for all repositories, as part of |
| 30 | +automatically managed policy called `[Sourcegraph Managed] Head of default branch policy`. |
| 31 | + |
| 32 | +For all other deployments, you will need to create a HEAD policy with "Syntactic indexing" enabled: |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +Syntactic indexing can only be enabled if the policy type is set to HEAD – only indexing the tip of default branch on each repository. You may choose to apply this policy only to selected repositories, although the recommendation is to enable it instance-wide. |
| 37 | + |
| 38 | +## Supported languages |
| 39 | + |
| 40 | +Syntactic code navigation requires language-specific implementations, and we currently support the following languages: [Java](https://www.java.com/en/), [Go](https://go.dev/), [Scala](https://scala-lang.org). |
| 41 | + |
| 42 | +We are constantly looking to expand the list of supported languages, with Python, Typescript/Javascript, C, C++, C# planned. If you are interested in syntactic indexing for these or any other languages, please contact your Sourcegraph account representative. |
0 commit comments