<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>book/src/languages.md - fork/helix @ 25.01</title>
<meta name="description" content="book/src/languages.md in fork/helix at 25.01.">
<meta property="og:title" content="book/src/languages.md - fork/helix @ 25.01">
<meta property="og:description" content="book/src/languages.md in fork/helix at 25.01.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="25.01" data-tip="dabfb6ceeae1da57fb93efcd254e917db49655e6">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/helix</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/helix</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">Michael Davis</span><span class="commit-message" data-commit="127567df8e88cfa71feb66619a6016988d984256">docs: Fix dead links to tree-sitter docs</span><span class="snapshot-sha sha" data-commit="127567df8e88cfa71feb66619a6016988d984256">127567df</span><time datetime="2024-12-28T09:05:46-05:00" title="2024-12-28 09:05:46 -0500">2024-12-28</time></p>
<header class="topbar"><details class="switcher"><summary>25.01</summary><div class="menu"><strong>branches</strong><a href="/fork/helix/ref/master/">master</a><strong>tags</strong><a href="/fork/helix/ref/23.05/">23.05</a><a href="/fork/helix/ref/23.10/">23.10</a><a href="/fork/helix/ref/24.03/">24.03</a><a href="/fork/helix/ref/24.07/">24.07</a><a class="current" href="/fork/helix/ref/25.01/">25.01</a><a href="/fork/helix/ref/25.01.1/">25.01.1</a><a href="/fork/helix/ref/25.07/">25.07</a><a href="/fork/helix/ref/25.07.1/">25.07.1</a><a class="all" href="/fork/helix/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/helix/">helix</a> / <a href="/fork/helix/ref/25.01/tree/book/">book</a> / <a href="/fork/helix/ref/25.01/tree/book/src/">src</a> / <span class="cur">languages.md</span></nav>
<span class="view-stats"><span>13.4 KiB</span><span>244 lines</span></span><span class="actions"><a class="raw" href="/fork/helix/raw/d98b1fcb85ab866d2ebc6a8bdb1e4602e5412102/book/src/languages.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><h2>Languages</h2>
<p>Language-specific settings and settings for language servers are configured
in <code>languages.toml</code> files.</p>
<h2><code>languages.toml</code> files</h2>
<p>There are three possible locations for a <code>languages.toml</code> file:</p>
<ol>
<li>
<p>In the Helix source code, which lives in the
<a href="https://github.com/helix-editor/helix/blob/master/languages.toml">Helix repository</a>.
It provides the default configurations for languages and language servers.</p>
</li>
<li>
<p>In your <a href="/fork/helix/ref/25.01/blob/book/src/configuration.md">configuration directory</a>. This overrides values
from the built-in language configuration. For example, to disable
auto-formatting for Rust:</p>
<pre class="language-toml"><a-c># in &lt;config_dir&gt;/helix/languages.toml</a-c>

<a-p>[</a-p><a-pr>language-server</a-pr><a-p>.</a-p><a-pr>mylang-lsp</a-pr><a-p>]</a-p>
<a-pr>command</a-pr> <a-o>=</a-o> <a-s>&quot;mylang-lsp&quot;</a-s>

<a-p>[[</a-p><a-pr>language</a-pr><a-p>]]</a-p>
<a-pr>name</a-pr> <a-o>=</a-o> <a-s>&quot;rust&quot;</a-s>
<a-pr>auto-format</a-pr> <a-o>=</a-o> <a-co>false</a-co></pre>
</li>
<li>
<p>In a <code>.helix</code> folder in your project. Language configuration may also be
overridden local to a project by creating a <code>languages.toml</code> file in a
<code>.helix</code> folder. Its settings will be merged with the language configuration
in the configuration directory and the built-in configuration.</p>
</li>
</ol>
<h2>Language configuration</h2>
<p>Each language is configured by adding a <code>[[language]]</code> section to a
<code>languages.toml</code> file. For example:</p>
<pre class="language-toml"><a-p>[[</a-p><a-pr>language</a-pr><a-p>]]</a-p>
<a-pr>name</a-pr> <a-o>=</a-o> <a-s>&quot;mylang&quot;</a-s>
<a-pr>scope</a-pr> <a-o>=</a-o> <a-s>&quot;source.mylang&quot;</a-s>
<a-pr>injection-regex</a-pr> <a-o>=</a-o> <a-s>&quot;mylang&quot;</a-s>
<a-pr>file-types</a-pr> <a-o>=</a-o> <a-p>[</a-p><a-s>&quot;mylang&quot;</a-s><a-p>,</a-p> <a-s>&quot;myl&quot;</a-s><a-p>]</a-p>
<a-pr>comment-tokens</a-pr> <a-o>=</a-o> <a-s>&quot;#&quot;</a-s>
<a-pr>indent</a-pr> <a-o>=</a-o> <a-p>{</a-p> <a-pr>tab-width</a-pr> <a-o>=</a-o> <a-n>2</a-n><a-p>,</a-p> <a-pr>unit</a-pr> <a-o>=</a-o> <a-s>&quot;  &quot;</a-s> <a-p>}</a-p>
<a-pr>formatter</a-pr> <a-o>=</a-o> <a-p>{</a-p> <a-pr>command</a-pr> <a-o>=</a-o> <a-s>&quot;mylang-formatter&quot;</a-s> <a-p>,</a-p> <a-pr>args</a-pr> <a-o>=</a-o> <a-p>[</a-p><a-s>&quot;--stdin&quot;</a-s><a-p>]</a-p> <a-p>}</a-p>
<a-pr>language-servers</a-pr> <a-o>=</a-o> <a-p>[</a-p> <a-s>&quot;mylang-lsp&quot;</a-s> <a-p>]</a-p></pre>
<p>These configuration keys are available:</p>
<table><thead><tr><th>Key</th><th>Description</th></tr></thead><tbody>
<tr><td><code>name</code></td><td>The name of the language</td></tr>
<tr><td><code>language-id</code></td><td>The language-id for language servers, checkout the table at <a href="https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentItem">TextDocumentItem</a> for the right id</td></tr>
<tr><td><code>scope</code></td><td>A string like <code>source.js</code> that identifies the language. Currently, we strive to match the scope names used by popular TextMate grammars and by the Linguist library. Usually <code>source.&lt;name&gt;</code> or <code>text.&lt;name&gt;</code> in case of markup languages</td></tr>
<tr><td><code>injection-regex</code></td><td>regex pattern that will be tested against a language name in order to determine whether this language should be used for a potential <a href="https://tree-sitter.github.io/tree-sitter/3-syntax-highlighting.html#language-injection">language injection</a> site.</td></tr>
<tr><td><code>file-types</code></td><td>The filetypes of the language, for example <code>["yml", "yaml"]</code>. See the file-type detection section below.</td></tr>
<tr><td><code>shebangs</code></td><td>The interpreters from the shebang line, for example <code>["sh", "bash"]</code></td></tr>
<tr><td><code>roots</code></td><td>A set of marker files to look for when trying to find the workspace root. For example <code>Cargo.lock</code>, <code>yarn.lock</code></td></tr>
<tr><td><code>auto-format</code></td><td>Whether to autoformat this language when saving</td></tr>
<tr><td><code>diagnostic-severity</code></td><td>Minimal severity of diagnostic for it to be displayed. (Allowed values: <code>error</code>, <code>warning</code>, <code>info</code>, <code>hint</code>)</td></tr>
<tr><td><code>comment-tokens</code></td><td>The tokens to use as a comment token, either a single token <code>"//"</code> or an array <code>["//", "///", "//!"]</code> (the first token will be used for commenting). Also configurable as <code>comment-token</code> for backwards compatibility</td></tr>
<tr><td><code>block-comment-tokens</code></td><td>The start and end tokens for a multiline comment either an array or single table of <code>{ start = "/*", end = "*/"}</code>. The first set of tokens will be used for commenting, any pairs in the array can be uncommented</td></tr>
<tr><td><code>indent</code></td><td>The indent to use. Has sub keys <code>unit</code> (the text inserted into the document when indenting; usually set to N spaces or <code>"\t"</code> for tabs) and <code>tab-width</code> (the number of spaces rendered for a tab)</td></tr>
<tr><td><code>language-servers</code></td><td>The Language Servers used for this language. See below for more information in the section <a href="#configuring-language-servers-for-a-language">Configuring Language Servers for a language</a></td></tr>
<tr><td><code>grammar</code></td><td>The tree-sitter grammar to use (defaults to the value of <code>name</code>)</td></tr>
<tr><td><code>formatter</code></td><td>The formatter for the language, it will take precedence over the lsp when defined. The formatter must be able to take the original file as input from stdin and write the formatted file to stdout</td></tr>
<tr><td><code>soft-wrap</code></td><td><a href="/fork/helix/ref/25.01/blob/book/src/configuration.md#editorsoft-wrap-section">editor.softwrap</a></td></tr>
<tr><td><code>text-width</code></td><td>Maximum line length. Used for the <code>:reflow</code> command and soft-wrapping if <code>soft-wrap.wrap-at-text-width</code> is set, defaults to <code>editor.text-width</code></td></tr>
<tr><td><code>path-completion</code></td><td>Overrides the <code>editor.path-completion</code> config key for the language.</td></tr>
<tr><td><code>workspace-lsp-roots</code></td><td>Directories relative to the workspace root that are treated as LSP roots. Should only be set in <code>.helix/config.toml</code>. Overwrites the setting of the same name in <code>config.toml</code> if set.</td></tr>
<tr><td><code>persistent-diagnostic-sources</code></td><td>An array of LSP diagnostic sources assumed unchanged when the language server resends the same set of diagnostics. Helix can track the position for these diagnostics internally instead. Useful for diagnostics that are recomputed on save.</td></tr>
</tbody></table>
<h3>File-type detection and the <code>file-types</code> key</h3>
<p>Helix determines which language configuration to use based on the <code>file-types</code> key
from the above section. <code>file-types</code> is a list of strings or tables, for
example:</p>
<pre class="language-toml"><a-pr>file-types</a-pr> <a-o>=</a-o> <a-p>[</a-p><a-s>&quot;toml&quot;</a-s><a-p>,</a-p> <a-p>{</a-p> <a-pr>glob</a-pr> <a-o>=</a-o> <a-s>&quot;Makefile&quot;</a-s> <a-p>},</a-p> <a-p>{</a-p> <a-pr>glob</a-pr> <a-o>=</a-o> <a-s>&quot;.git/config&quot;</a-s> <a-p>},</a-p> <a-p>{</a-p> <a-pr>glob</a-pr> <a-o>=</a-o> <a-s>&quot;.github/workflows/*.yaml&quot;</a-s> <a-p>}</a-p> <a-p>]</a-p></pre>
<p>When determining a language configuration to use, Helix searches the file-types
with the following priorities:</p>
<ol>
<li>Glob: values in <code>glob</code> tables are checked against the full path of the given
file. Globs are standard Unix-style path globs (e.g. the kind you use in Shell)
and can be used to match paths for a specific prefix, suffix, directory, etc.
In the above example, the <code>{ glob = "Makefile" }</code> config would match files
with the name <code>Makefile</code>, the <code>{ glob = ".git/config" }</code> config would match
<code>config</code> files in <code>.git</code> directories, and the <code>{ glob = ".github/workflows/*.yaml" }</code>
config would match any <code>yaml</code> files in <code>.github/workflow</code> directories. Note
that globs should always use the Unix path separator <code>/</code> even on Windows systems;
the matcher will automatically take the machine-specific separators into account.
If the glob isn't an absolute path or doesn't already start with a glob prefix,
<code>*/</code> will automatically be added to ensure it matches for any subdirectory.</li>
<li>Extension: if there are no glob matches, any <code>file-types</code> string that matches
the file extension of a given file wins. In the example above, the <code>"toml"</code>
config matches files like <code>Cargo.toml</code> or <code>languages.toml</code>.</li>
</ol>
<h2>Language Server configuration</h2>
<p>Language servers are configured separately in the table <code>language-server</code> in the same file as the languages <code>languages.toml</code></p>
<p>For example:</p>
<pre class="language-toml"><a-p>[</a-p><a-pr>language-server</a-pr><a-p>.</a-p><a-pr>mylang-lsp</a-pr><a-p>]</a-p>
<a-pr>command</a-pr> <a-o>=</a-o> <a-s>&quot;mylang-lsp&quot;</a-s>
<a-pr>args</a-pr> <a-o>=</a-o> <a-p>[</a-p><a-s>&quot;--stdio&quot;</a-s><a-p>]</a-p>
<a-pr>config</a-pr> <a-o>=</a-o> <a-p>{</a-p> <a-pr>provideFormatter</a-pr> <a-o>=</a-o> <a-co>true</a-co> <a-p>}</a-p>
<a-pr>environment</a-pr> <a-o>=</a-o> <a-p>{</a-p> <a-s>&quot;ENV1&quot;</a-s> <a-o>=</a-o> <a-s>&quot;value1&quot;</a-s><a-p>,</a-p> <a-s>&quot;ENV2&quot;</a-s> <a-o>=</a-o> <a-s>&quot;value2&quot;</a-s> <a-p>}</a-p>

<a-p>[</a-p><a-pr>language-server</a-pr><a-p>.</a-p><a-pr>efm-lsp-prettier</a-pr><a-p>]</a-p>
<a-pr>command</a-pr> <a-o>=</a-o> <a-s>&quot;efm-langserver&quot;</a-s>

<a-p>[</a-p><a-pr>language-server</a-pr><a-p>.</a-p><a-pr>efm-lsp-prettier</a-pr><a-p>.</a-p><a-pr>config</a-pr><a-p>]</a-p>
<a-pr>documentFormatting</a-pr> <a-o>=</a-o> <a-co>true</a-co>
<a-pr>languages</a-pr> <a-o>=</a-o> <a-p>{</a-p> <a-pr>typescript</a-pr> <a-o>=</a-o> <a-p>[</a-p> <a-p>{</a-p> <a-pr>formatCommand</a-pr> <a-o>=</a-o><a-s>&quot;prettier --stdin-filepath ${INPUT}&quot;</a-s><a-p>,</a-p> <a-pr>formatStdin</a-pr> <a-o>=</a-o> <a-co>true</a-co> <a-p>}</a-p> <a-p>]</a-p> <a-p>}</a-p></pre>
<p>These are the available options for a language server.</p>
<table><thead><tr><th>Key</th><th>Description</th></tr></thead><tbody>
<tr><td><code>command</code></td><td>The name or path of the language server binary to execute. Binaries must be in <code>$PATH</code></td></tr>
<tr><td><code>args</code></td><td>A list of arguments to pass to the language server binary</td></tr>
<tr><td><code>config</code></td><td>Language server initialization options</td></tr>
<tr><td><code>timeout</code></td><td>The maximum time a request to the language server may take, in seconds. Defaults to <code>20</code></td></tr>
<tr><td><code>environment</code></td><td>Any environment variables that will be used when starting the language server <code>{ "KEY1" = "Value1", "KEY2" = "Value2" }</code></td></tr>
<tr><td><code>required-root-patterns</code></td><td>A list of <code>glob</code> patterns to look for in the working directory. The language server is started if at least one of them is found.</td></tr>
</tbody></table>
<p>A <code>format</code> sub-table within <code>config</code> can be used to pass extra formatting options to
<a href="https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_formatting">Document Formatting Requests</a>.
For example, with typescript:</p>
<pre class="language-toml"><a-p>[</a-p><a-pr>language-server</a-pr><a-p>.</a-p><a-pr>typescript-language-server</a-pr><a-p>]</a-p>
<a-c># pass format options according to https://github.com/typescript-language-server/typescript-language-server#workspacedidchangeconfiguration omitting the &quot;[language].format.&quot; prefix.</a-c>
<a-pr>config</a-pr> <a-o>=</a-o> <a-p>{</a-p> <a-pr>format</a-pr> <a-o>=</a-o> <a-p>{</a-p> <a-s>&quot;semicolons&quot;</a-s> <a-o>=</a-o> <a-s>&quot;insert&quot;</a-s><a-p>,</a-p> <a-s>&quot;insertSpaceBeforeFunctionParenthesis&quot;</a-s> <a-o>=</a-o> <a-co>true</a-co> <a-p>}</a-p> <a-p>}</a-p></pre>
<h3>Configuring Language Servers for a language</h3>
<p>The <code>language-servers</code> attribute in a language tells helix which language servers are used for this language.</p>
<p>They have to be defined in the <code>[language-server]</code> table as described in the previous section.</p>
<p>Different languages can use the same language server instance, e.g. <code>typescript-language-server</code> is used for javascript, jsx, tsx and typescript by default.</p>
<p>The definition order of language servers affects the order in the results list of code action menu.</p>
<p>In case multiple language servers are specified in the <code>language-servers</code> attribute of a <code>language</code>,
it's often useful to only enable/disable certain language-server features for these language servers.</p>
<p>As an example, <code>efm-lsp-prettier</code> of the previous example is used only with a formatting command <code>prettier</code>,
so everything else should be handled by the <code>typescript-language-server</code> (which is configured by default).
The language configuration for typescript could look like this:</p>
<pre class="language-toml"><a-p>[[</a-p><a-pr>language</a-pr><a-p>]]</a-p>
<a-pr>name</a-pr> <a-o>=</a-o> <a-s>&quot;typescript&quot;</a-s>
<a-pr>language-servers</a-pr> <a-o>=</a-o> <a-p>[</a-p> <a-p>{</a-p> <a-pr>name</a-pr> <a-o>=</a-o> <a-s>&quot;efm-lsp-prettier&quot;</a-s><a-p>,</a-p> <a-pr>only-features</a-pr> <a-o>=</a-o> <a-p>[</a-p> <a-s>&quot;format&quot;</a-s> <a-p>]</a-p> <a-p>},</a-p> <a-s>&quot;typescript-language-server&quot;</a-s> <a-p>]</a-p></pre>
<p>or equivalent:</p>
<pre class="language-toml"><a-p>[[</a-p><a-pr>language</a-pr><a-p>]]</a-p>
<a-pr>name</a-pr> <a-o>=</a-o> <a-s>&quot;typescript&quot;</a-s>
<a-pr>language-servers</a-pr> <a-o>=</a-o> <a-p>[</a-p> <a-p>{</a-p> <a-pr>name</a-pr> <a-o>=</a-o> <a-s>&quot;typescript-language-server&quot;</a-s><a-p>,</a-p> <a-pr>except-features</a-pr> <a-o>=</a-o> <a-p>[</a-p> <a-s>&quot;format&quot;</a-s> <a-p>]</a-p> <a-p>},</a-p> <a-s>&quot;efm-lsp-prettier&quot;</a-s> <a-p>]</a-p></pre>
<p>Each requested LSP feature is prioritized in the order of the <code>language-servers</code> array.
For example, the first <code>goto-definition</code> supported language server (in this case <code>typescript-language-server</code>) will be taken for the relevant LSP request (command <code>goto_definition</code>).
The features <code>diagnostics</code>, <code>code-action</code>, <code>completion</code>, <code>document-symbols</code> and <code>workspace-symbols</code> are an exception to that rule, as they are working for all language servers at the same time and are merged together, if enabled for the language.
If no <code>except-features</code> or <code>only-features</code> is given, all features for the language server are enabled.
If a language server itself doesn't support a feature, the next language server array entry will be tried (and so on).</p>
<p>The list of supported features is:</p>
<ul>
<li><code>format</code></li>
<li><code>goto-definition</code></li>
<li><code>goto-declaration</code></li>
<li><code>goto-type-definition</code></li>
<li><code>goto-reference</code></li>
<li><code>goto-implementation</code></li>
<li><code>signature-help</code></li>
<li><code>hover</code></li>
<li><code>document-highlight</code></li>
<li><code>completion</code></li>
<li><code>code-action</code></li>
<li><code>workspace-command</code></li>
<li><code>document-symbols</code></li>
<li><code>workspace-symbols</code></li>
<li><code>diagnostics</code></li>
<li><code>rename-symbol</code></li>
<li><code>inlay-hints</code></li>
</ul>
<h2>Tree-sitter grammar configuration</h2>
<p>The source for a language's tree-sitter grammar is specified in a <code>[[grammar]]</code>
section in <code>languages.toml</code>. For example:</p>
<pre class="language-toml"><a-p>[[</a-p><a-pr>grammar</a-pr><a-p>]]</a-p>
<a-pr>name</a-pr> <a-o>=</a-o> <a-s>&quot;mylang&quot;</a-s>
<a-pr>source</a-pr> <a-o>=</a-o> <a-p>{</a-p> <a-pr>git</a-pr> <a-o>=</a-o> <a-s>&quot;https://github.com/example/mylang&quot;</a-s><a-p>,</a-p> <a-pr>rev</a-pr> <a-o>=</a-o> <a-s>&quot;a250c4582510ff34767ec3b7dcdd3c24e8c8aa68&quot;</a-s> <a-p>}</a-p></pre>
<p>Grammar configuration takes these keys:</p>
<table><thead><tr><th>Key</th><th>Description</th></tr></thead><tbody>
<tr><td><code>name</code></td><td>The name of the tree-sitter grammar</td></tr>
<tr><td><code>source</code></td><td>The method of fetching the grammar - a table with a schema defined below</td></tr>
</tbody></table>
<p>Where <code>source</code> is a table with either these keys when using a grammar from a
git repository:</p>
<table><thead><tr><th>Key</th><th>Description</th></tr></thead><tbody>
<tr><td><code>git</code></td><td>A git remote URL from which the grammar should be cloned</td></tr>
<tr><td><code>rev</code></td><td>The revision (commit hash or tag) which should be fetched</td></tr>
<tr><td><code>subpath</code></td><td>A path within the grammar directory which should be built. Some grammar repositories host multiple grammars (for example <code>tree-sitter-typescript</code> and <code>tree-sitter-ocaml</code>) in subdirectories. This key is used to point <code>hx --grammar build</code> to the correct path for compilation. When omitted, the root of repository is used</td></tr>
</tbody></table>
<h3>Choosing grammars</h3>
<p>You may use a top-level <code>use-grammars</code> key to control which grammars are
fetched and built when using <code>hx --grammar fetch</code> and <code>hx --grammar build</code>.</p>
<pre class="language-toml"><a-c># Note: this key must come **before** the [[language]] and [[grammar]] sections</a-c>
<a-pr>use-grammars</a-pr> <a-o>=</a-o> <a-p>{</a-p> <a-pr>only</a-pr> <a-o>=</a-o> <a-p>[</a-p> <a-s>&quot;rust&quot;</a-s><a-p>,</a-p> <a-s>&quot;c&quot;</a-s><a-p>,</a-p> <a-s>&quot;cpp&quot;</a-s> <a-p>]</a-p> <a-p>}</a-p>
<a-c># or</a-c>
<a-pr>use-grammars</a-pr> <a-o>=</a-o> <a-p>{</a-p> <a-pr>except</a-pr> <a-o>=</a-o> <a-p>[</a-p> <a-s>&quot;yaml&quot;</a-s><a-p>,</a-p> <a-s>&quot;json&quot;</a-s> <a-p>]</a-p> <a-p>}</a-p></pre>
<p>When omitted, all grammars are fetched and built.</p>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-p>##</a-p> <a-tt>Languages</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text">Language-specific settings and settings for language servers are configured</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text">in `languages.toml` files.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text"><a-p>##</a-p> <a-tt>`languages.toml` files</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text">There are three possible locations for a `languages.toml` file:</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"><a-p>1. </a-p>In the Helix source code, which lives in the</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text"><a-p>   </a-p>[Helix repository](https://github.com/helix-editor/helix/blob/master/languages.toml).</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text"><a-p>   </a-p>It provides the default configurations for languages and language servers.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text"><a-p>2. In your [configuration directory](./configuration.md). This overrides values</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"><a-p>   from the built-in language configuration. For example, to disable</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"><a-p>   auto-formatting for Rust:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text"><a-p>   </a-p><a-tl>```toml</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text"><a-p>   </a-p><a-c># in &lt;config_dir&gt;/helix/languages.toml</a-c></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"><a-p>   [</a-p><a-pr>language-server</a-pr><a-p>.</a-p><a-pr>mylang-lsp</a-pr><a-p>]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text"><a-p>   </a-p><a-pr>command</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;mylang-lsp&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text"><a-p>   [[</a-p><a-pr>language</a-pr><a-p>]]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text"><a-p>   </a-p><a-pr>name</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;rust&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text"><a-p>   </a-p><a-pr>auto-format</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-co>false</a-co></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text"><a-p>   ```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L28" href="#L28">28</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L29" href="#L29">29</a><span class="code-text"><a-p>3. In a `.helix` folder in your project. Language configuration may also be</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L30" href="#L30">30</a><span class="code-text"><a-p>   overridden local to a project by creating a `languages.toml` file in a</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L31" href="#L31">31</a><span class="code-text"><a-p>   `.helix` folder. Its settings will be merged with the language configuration</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L32" href="#L32">32</a><span class="code-text"><a-p>   in the configuration directory and the built-in configuration.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L33" href="#L33">33</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L34" href="#L34">34</a><span class="code-text"><a-p>## </a-p><a-tt>Language configuration</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L35" href="#L35">35</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L36" href="#L36">36</a><span class="code-text"><a-p>Each language is configured by adding a `[[language]]` section to a</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L37" href="#L37">37</a><span class="code-text"><a-p>`languages.toml` file. For example:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L38" href="#L38">38</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L39" href="#L39">39</a><span class="code-text"><a-p>```</a-p><a-tl>toml</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L40" href="#L40">40</a><span class="code-text"><a-p>[[</a-p><a-pr>language</a-pr><a-p>]]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L41" href="#L41">41</a><span class="code-text"><a-p>name </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;mylang&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L42" href="#L42">42</a><span class="code-text"><a-p>scope </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;source.mylang&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L43" href="#L43">43</a><span class="code-text"><a-p>injection-regex </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;mylang&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L44" href="#L44">44</a><span class="code-text"><a-p>file-types </a-p><a-o>=</a-o><a-p> [</a-p><a-s>&quot;mylang&quot;</a-s><a-p>, </a-p><a-s>&quot;myl&quot;</a-s><a-p>]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L45" href="#L45">45</a><span class="code-text"><a-p>comment-tokens </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;#&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L46" href="#L46">46</a><span class="code-text"><a-p>indent </a-p><a-o>=</a-o><a-p> { </a-p><a-pr>tab-width</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-n>2</a-n><a-p>, </a-p><a-pr>unit</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;  &quot;</a-s><a-p> }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L47" href="#L47">47</a><span class="code-text"><a-p>formatter </a-p><a-o>=</a-o><a-p> { </a-p><a-pr>command</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;mylang-formatter&quot;</a-s><a-p> , </a-p><a-pr>args</a-pr><a-p> </a-p><a-o>=</a-o><a-p> [</a-p><a-s>&quot;--stdin&quot;</a-s><a-p>] }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L48" href="#L48">48</a><span class="code-text"><a-p>language-servers </a-p><a-o>=</a-o><a-p> [ </a-p><a-s>&quot;mylang-lsp&quot;</a-s><a-p> ]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L49" href="#L49">49</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L50" href="#L50">50</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L51" href="#L51">51</a><span class="code-text"><a-p>These configuration keys are available:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L52" href="#L52">52</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L53" href="#L53">53</a><span class="code-text"><a-p>| Key                   | Description                                                   |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L54" href="#L54">54</a><span class="code-text"><a-p>| ----                  | -----------                                                   |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L55" href="#L55">55</a><span class="code-text"><a-p>| `name`                | The name of the language                                      |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L56" href="#L56">56</a><span class="code-text"><a-p>| `language-id`         | The language-id for language servers, checkout the table at [TextDocumentItem](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentItem) for the right id |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L57" href="#L57">57</a><span class="code-text"><a-p>| `scope`               | A string like `source.js` that identifies the language. Currently, we strive to match the scope names used by popular TextMate grammars and by the Linguist library. Usually `source.&lt;name&gt;` or `text.&lt;name&gt;` in case of markup languages |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L58" href="#L58">58</a><span class="code-text"><a-p>| `injection-regex`     | regex pattern that will be tested against a language name in order to determine whether this language should be used for a potential [language injection][treesitter-language-injection] site. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L59" href="#L59">59</a><span class="code-text"><a-p>| `file-types`          | The filetypes of the language, for example `[&quot;yml&quot;, &quot;yaml&quot;]`. See the file-type detection section below. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L60" href="#L60">60</a><span class="code-text"><a-p>| `shebangs`            | The interpreters from the shebang line, for example `[&quot;sh&quot;, &quot;bash&quot;]` |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L61" href="#L61">61</a><span class="code-text"><a-p>| `roots`               | A set of marker files to look for when trying to find the workspace root. For example `Cargo.lock`, `yarn.lock` |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L62" href="#L62">62</a><span class="code-text"><a-p>| `auto-format`         | Whether to autoformat this language when saving               |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L63" href="#L63">63</a><span class="code-text"><a-p>| `diagnostic-severity` | Minimal severity of diagnostic for it to be displayed. (Allowed values: `error`, `warning`, `info`, `hint`) |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L64" href="#L64">64</a><span class="code-text"><a-p>| `comment-tokens`      | The tokens to use as a comment token, either a single token `&quot;//&quot;` or an array `[&quot;//&quot;, &quot;///&quot;, &quot;//!&quot;]` (the first token will be used for commenting). Also configurable as `comment-token` for backwards compatibility|</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L65" href="#L65">65</a><span class="code-text"><a-p>| `block-comment-tokens`| The start and end tokens for a multiline comment either an array or single table of `{ start = &quot;/*&quot;, end = &quot;*/&quot;}`. The first set of tokens will be used for commenting, any pairs in the array can be uncommented |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L66" href="#L66">66</a><span class="code-text"><a-p>| `indent`              | The indent to use. Has sub keys `unit` (the text inserted into the document when indenting; usually set to N spaces or `&quot;\t&quot;` for tabs) and `tab-width` (the number of spaces rendered for a tab) |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L67" href="#L67">67</a><span class="code-text"><a-p>| `language-servers`    | The Language Servers used for this language. See below for more information in the section [Configuring Language Servers for a language](#configuring-language-servers-for-a-language)   |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L68" href="#L68">68</a><span class="code-text"><a-p>| `grammar`             | The tree-sitter grammar to use (defaults to the value of `name`) |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L69" href="#L69">69</a><span class="code-text"><a-p>| `formatter`           | The formatter for the language, it will take precedence over the lsp when defined. The formatter must be able to take the original file as input from stdin and write the formatted file to stdout |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L70" href="#L70">70</a><span class="code-text"><a-p>| `soft-wrap` | [editor.softwrap](./configuration.md#editorsoft-wrap-section)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L71" href="#L71">71</a><span class="code-text"><a-p>| `text-width`          |  Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap-at-text-width` is set, defaults to `editor.text-width`   |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L72" href="#L72">72</a><span class="code-text"><a-p>| `path-completion`     | Overrides the `editor.path-completion` config key for the language. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L73" href="#L73">73</a><span class="code-text"><a-p>| `workspace-lsp-roots`     | Directories relative to the workspace root that are treated as LSP roots. Should only be set in `.helix/config.toml`. Overwrites the setting of the same name in `config.toml` if set. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L74" href="#L74">74</a><span class="code-text"><a-p>| `persistent-diagnostic-sources` | An array of LSP diagnostic sources assumed unchanged when the language server resends the same set of diagnostics. Helix can track the position for these diagnostics internally instead. Useful for diagnostics that are recomputed on save.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L75" href="#L75">75</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L76" href="#L76">76</a><span class="code-text"><a-p>### </a-p><a-tt>File-type detection and the `file-types` key</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L77" href="#L77">77</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L78" href="#L78">78</a><span class="code-text"><a-p>Helix determines which language configuration to use based on the `file-types` key</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L79" href="#L79">79</a><span class="code-text"><a-p>from the above section. `file-types` is a list of strings or tables, for</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L80" href="#L80">80</a><span class="code-text"><a-p>example:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L81" href="#L81">81</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L82" href="#L82">82</a><span class="code-text"><a-p>```</a-p><a-tl>toml</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L83" href="#L83">83</a><span class="code-text"><a-p>file-types </a-p><a-o>=</a-o><a-p> [</a-p><a-s>&quot;toml&quot;</a-s><a-p>, { </a-p><a-pr>glob</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;Makefile&quot;</a-s><a-p> }, { </a-p><a-pr>glob</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;.git/config&quot;</a-s><a-p> }, { </a-p><a-pr>glob</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;.github/workflows/*.yaml&quot;</a-s><a-p> } ]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L84" href="#L84">84</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L85" href="#L85">85</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L86" href="#L86">86</a><span class="code-text"><a-p>When determining a language configuration to use, Helix searches the file-types</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L87" href="#L87">87</a><span class="code-text"><a-p>with the following priorities:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L88" href="#L88">88</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L89" href="#L89">89</a><span class="code-text"><a-p>1. Glob: values in `glob` tables are checked against the full path of the given</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L90" href="#L90">90</a><span class="code-text"><a-p>   file. Globs are standard Unix-style path globs (e.g. the kind you use in Shell)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L91" href="#L91">91</a><span class="code-text"><a-p>   and can be used to match paths for a specific prefix, suffix, directory, etc.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L92" href="#L92">92</a><span class="code-text"><a-p>   In the above example, the `{ glob = &quot;Makefile&quot; }` config would match files</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L93" href="#L93">93</a><span class="code-text"><a-p>   with the name `Makefile`, the `{ glob = &quot;.git/config&quot; }` config would match</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L94" href="#L94">94</a><span class="code-text"><a-p>   `config` files in `.git` directories, and the `{ glob = &quot;.github/workflows/*.yaml&quot; }`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L95" href="#L95">95</a><span class="code-text"><a-p>   config would match any `yaml` files in `.github/workflow` directories. Note</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L96" href="#L96">96</a><span class="code-text"><a-p>   that globs should always use the Unix path separator `/` even on Windows systems;</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L97" href="#L97">97</a><span class="code-text"><a-p>   the matcher will automatically take the machine-specific separators into account.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L98" href="#L98">98</a><span class="code-text"><a-p>   If the glob isn&#39;t an absolute path or doesn&#39;t already start with a glob prefix,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L99" href="#L99">99</a><span class="code-text"><a-p>   `*/` will automatically be added to ensure it matches for any subdirectory.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L100" href="#L100">100</a><span class="code-text"><a-p>2. Extension: if there are no glob matches, any `file-types` string that matches</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L101" href="#L101">101</a><span class="code-text"><a-p>   the file extension of a given file wins. In the example above, the `&quot;toml&quot;`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L102" href="#L102">102</a><span class="code-text"><a-p>   config matches files like `Cargo.toml` or `languages.toml`.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L103" href="#L103">103</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L104" href="#L104">104</a><span class="code-text"><a-p>## </a-p><a-tt>Language Server configuration</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L105" href="#L105">105</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L106" href="#L106">106</a><span class="code-text"><a-p>Language servers are configured separately in the table `language-server` in the same file as the languages `languages.toml`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L107" href="#L107">107</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L108" href="#L108">108</a><span class="code-text"><a-p>For example:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L109" href="#L109">109</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L110" href="#L110">110</a><span class="code-text"><a-p>```</a-p><a-tl>toml</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L111" href="#L111">111</a><span class="code-text"><a-p>[</a-p><a-pr>language-server</a-pr><a-p>.</a-p><a-pr>mylang-lsp</a-pr><a-p>]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L112" href="#L112">112</a><span class="code-text"><a-p>command </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;mylang-lsp&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L113" href="#L113">113</a><span class="code-text"><a-p>args </a-p><a-o>=</a-o><a-p> [</a-p><a-s>&quot;--stdio&quot;</a-s><a-p>]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L114" href="#L114">114</a><span class="code-text"><a-p>config </a-p><a-o>=</a-o><a-p> { </a-p><a-pr>provideFormatter</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-co>true</a-co><a-p> }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L115" href="#L115">115</a><span class="code-text"><a-p>environment </a-p><a-o>=</a-o><a-p> { </a-p><a-s>&quot;ENV1&quot;</a-s><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;value1&quot;</a-s><a-p>, </a-p><a-s>&quot;ENV2&quot;</a-s><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;value2&quot;</a-s><a-p> }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L116" href="#L116">116</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L117" href="#L117">117</a><span class="code-text"><a-p>[</a-p><a-pr>language-server</a-pr><a-p>.</a-p><a-pr>efm-lsp-prettier</a-pr><a-p>]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L118" href="#L118">118</a><span class="code-text"><a-p>command </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;efm-langserver&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L119" href="#L119">119</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L120" href="#L120">120</a><span class="code-text"><a-p>[</a-p><a-pr>language-server</a-pr><a-p>.</a-p><a-pr>efm-lsp-prettier</a-pr><a-p>.</a-p><a-pr>config</a-pr><a-p>]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L121" href="#L121">121</a><span class="code-text"><a-p>documentFormatting </a-p><a-o>=</a-o><a-p> </a-p><a-co>true</a-co></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L122" href="#L122">122</a><span class="code-text"><a-p>languages </a-p><a-o>=</a-o><a-p> { </a-p><a-pr>typescript</a-pr><a-p> </a-p><a-o>=</a-o><a-p> [ { </a-p><a-pr>formatCommand</a-pr><a-p> </a-p><a-o>=</a-o><a-s>&quot;prettier --stdin-filepath ${INPUT}&quot;</a-s><a-p>, </a-p><a-pr>formatStdin</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-co>true</a-co><a-p> } ] }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L123" href="#L123">123</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L124" href="#L124">124</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L125" href="#L125">125</a><span class="code-text"><a-p>These are the available options for a language server.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L126" href="#L126">126</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L127" href="#L127">127</a><span class="code-text"><a-p>| Key                        | Description                                                                                                                       |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L128" href="#L128">128</a><span class="code-text"><a-p>| ----                       | -----------                                                                                                                       |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L129" href="#L129">129</a><span class="code-text"><a-p>| `command`                  | The name or path of the language server binary to execute. Binaries must be in `$PATH`                                            |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L130" href="#L130">130</a><span class="code-text"><a-p>| `args`                     | A list of arguments to pass to the language server binary                                                                         |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L131" href="#L131">131</a><span class="code-text"><a-p>| `config`                   | Language server initialization options                                                                                            |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L132" href="#L132">132</a><span class="code-text"><a-p>| `timeout`                  | The maximum time a request to the language server may take, in seconds. Defaults to `20`                                          |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L133" href="#L133">133</a><span class="code-text"><a-p>| `environment`              | Any environment variables that will be used when starting the language server `{ &quot;KEY1&quot; = &quot;Value1&quot;, &quot;KEY2&quot; = &quot;Value2&quot; }`          |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L134" href="#L134">134</a><span class="code-text"><a-p>| `required-root-patterns`   | A list of `glob` patterns to look for in the working directory. The language server is started if at least one of them is found.  |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L135" href="#L135">135</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L136" href="#L136">136</a><span class="code-text"><a-p>A `format` sub-table within `config` can be used to pass extra formatting options to</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L137" href="#L137">137</a><span class="code-text"><a-p>[Document Formatting Requests](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_formatting).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L138" href="#L138">138</a><span class="code-text"><a-p>For example, with typescript:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L139" href="#L139">139</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L140" href="#L140">140</a><span class="code-text"><a-p>```</a-p><a-tl>toml</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L141" href="#L141">141</a><span class="code-text"><a-p>[</a-p><a-pr>language-server</a-pr><a-p>.</a-p><a-pr>typescript-language-server</a-pr><a-p>]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L142" href="#L142">142</a><span class="code-text"><a-p># pass format options according to https://github.com/typescript-language-server/typescript-language-server#workspacedidchangeconfiguration omitting the &quot;[language].format.&quot; prefix.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L143" href="#L143">143</a><span class="code-text"><a-p>config </a-p><a-o>=</a-o><a-p> { </a-p><a-pr>format</a-pr><a-p> </a-p><a-o>=</a-o><a-p> { </a-p><a-s>&quot;semicolons&quot;</a-s><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;insert&quot;</a-s><a-p>, </a-p><a-s>&quot;insertSpaceBeforeFunctionParenthesis&quot;</a-s><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-co>true</a-co><a-p> } }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L144" href="#L144">144</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L145" href="#L145">145</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L146" href="#L146">146</a><span class="code-text"><a-p>### </a-p><a-tt>Configuring Language Servers for a language</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L147" href="#L147">147</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L148" href="#L148">148</a><span class="code-text"><a-p>The `language-servers` attribute in a language tells helix which language servers are used for this language.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L149" href="#L149">149</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L150" href="#L150">150</a><span class="code-text"><a-p>They have to be defined in the `[language-server]` table as described in the previous section.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L151" href="#L151">151</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L152" href="#L152">152</a><span class="code-text"><a-p>Different languages can use the same language server instance, e.g. `typescript-language-server` is used for javascript, jsx, tsx and typescript by default.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L153" href="#L153">153</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L154" href="#L154">154</a><span class="code-text"><a-p>The definition order of language servers affects the order in the results list of code action menu.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L155" href="#L155">155</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L156" href="#L156">156</a><span class="code-text"><a-p>In case multiple language servers are specified in the `language-servers` attribute of a `language`,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L157" href="#L157">157</a><span class="code-text"><a-p>it&#39;s often useful to only enable/disable certain language-server features for these language servers.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L158" href="#L158">158</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L159" href="#L159">159</a><span class="code-text"><a-p>As an example, `efm-lsp-prettier` of the previous example is used only with a formatting command `prettier`,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L160" href="#L160">160</a><span class="code-text"><a-p>so everything else should be handled by the `typescript-language-server` (which is configured by default).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L161" href="#L161">161</a><span class="code-text"><a-p>The language configuration for typescript could look like this:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L162" href="#L162">162</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L163" href="#L163">163</a><span class="code-text"><a-p>```</a-p><a-tl>toml</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L164" href="#L164">164</a><span class="code-text"><a-p>[[</a-p><a-pr>language</a-pr><a-p>]]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L165" href="#L165">165</a><span class="code-text"><a-p>name </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;typescript&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L166" href="#L166">166</a><span class="code-text"><a-p>language-servers </a-p><a-o>=</a-o><a-p> [ { </a-p><a-pr>name</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;efm-lsp-prettier&quot;</a-s><a-p>, </a-p><a-pr>only-features</a-pr><a-p> </a-p><a-o>=</a-o><a-p> [ </a-p><a-s>&quot;format&quot;</a-s><a-p> ] }, </a-p><a-s>&quot;typescript-language-server&quot;</a-s><a-p> ]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L167" href="#L167">167</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L168" href="#L168">168</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L169" href="#L169">169</a><span class="code-text"><a-p>or equivalent:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L170" href="#L170">170</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L171" href="#L171">171</a><span class="code-text"><a-p>```</a-p><a-tl>toml</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L172" href="#L172">172</a><span class="code-text"><a-p>[[</a-p><a-pr>language</a-pr><a-p>]]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L173" href="#L173">173</a><span class="code-text"><a-p>name </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;typescript&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L174" href="#L174">174</a><span class="code-text"><a-p>language-servers </a-p><a-o>=</a-o><a-p> [ { </a-p><a-pr>name</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;typescript-language-server&quot;</a-s><a-p>, </a-p><a-pr>except-features</a-pr><a-p> </a-p><a-o>=</a-o><a-p> [ </a-p><a-s>&quot;format&quot;</a-s><a-p> ] }, </a-p><a-s>&quot;efm-lsp-prettier&quot;</a-s><a-p> ]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L175" href="#L175">175</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L176" href="#L176">176</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L177" href="#L177">177</a><span class="code-text"><a-p>Each requested LSP feature is prioritized in the order of the `language-servers` array.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L178" href="#L178">178</a><span class="code-text"><a-p>For example, the first `goto-definition` supported language server (in this case `typescript-language-server`) will be taken for the relevant LSP request (command `goto_definition`).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L179" href="#L179">179</a><span class="code-text"><a-p>The features `diagnostics`, `code-action`, `completion`, `document-symbols` and `workspace-symbols` are an exception to that rule, as they are working for all language servers at the same time and are merged together, if enabled for the language.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L180" href="#L180">180</a><span class="code-text"><a-p>If no `except-features` or `only-features` is given, all features for the language server are enabled.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L181" href="#L181">181</a><span class="code-text"><a-p>If a language server itself doesn&#39;t support a feature, the next language server array entry will be tried (and so on).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L182" href="#L182">182</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L183" href="#L183">183</a><span class="code-text"><a-p>The list of supported features is:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L184" href="#L184">184</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L185" href="#L185">185</a><span class="code-text"><a-p>- `format`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L186" href="#L186">186</a><span class="code-text"><a-p>- `goto-definition`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L187" href="#L187">187</a><span class="code-text"><a-p>- `goto-declaration`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L188" href="#L188">188</a><span class="code-text"><a-p>- `goto-type-definition`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L189" href="#L189">189</a><span class="code-text"><a-p>- `goto-reference`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L190" href="#L190">190</a><span class="code-text"><a-p>- `goto-implementation`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L191" href="#L191">191</a><span class="code-text"><a-p>- `signature-help`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L192" href="#L192">192</a><span class="code-text"><a-p>- `hover`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L193" href="#L193">193</a><span class="code-text"><a-p>- `document-highlight`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L194" href="#L194">194</a><span class="code-text"><a-p>- `completion`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L195" href="#L195">195</a><span class="code-text"><a-p>- `code-action`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L196" href="#L196">196</a><span class="code-text"><a-p>- `workspace-command`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L197" href="#L197">197</a><span class="code-text"><a-p>- `document-symbols`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L198" href="#L198">198</a><span class="code-text"><a-p>- `workspace-symbols`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L199" href="#L199">199</a><span class="code-text"><a-p>- `diagnostics`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L200" href="#L200">200</a><span class="code-text"><a-p>- `rename-symbol`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L201" href="#L201">201</a><span class="code-text"><a-p>- `inlay-hints`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L202" href="#L202">202</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L203" href="#L203">203</a><span class="code-text"><a-p>## </a-p><a-tt>Tree-sitter grammar configuration</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L204" href="#L204">204</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L205" href="#L205">205</a><span class="code-text"><a-p>The source for a language&#39;s tree-sitter grammar is specified in a `[[grammar]]`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L206" href="#L206">206</a><span class="code-text"><a-p>section in `languages.toml`. For example:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L207" href="#L207">207</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L208" href="#L208">208</a><span class="code-text"><a-p>```</a-p><a-tl>toml</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L209" href="#L209">209</a><span class="code-text"><a-p>[[</a-p><a-pr>grammar</a-pr><a-p>]]</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L210" href="#L210">210</a><span class="code-text"><a-p>name </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;mylang&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L211" href="#L211">211</a><span class="code-text"><a-p>source </a-p><a-o>=</a-o><a-p> { </a-p><a-pr>git</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;https://github.com/example/mylang&quot;</a-s><a-p>, </a-p><a-pr>rev</a-pr><a-p> </a-p><a-o>=</a-o><a-p> </a-p><a-s>&quot;a250c4582510ff34767ec3b7dcdd3c24e8c8aa68&quot;</a-s><a-p> }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L212" href="#L212">212</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L213" href="#L213">213</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L214" href="#L214">214</a><span class="code-text"><a-p>Grammar configuration takes these keys:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L215" href="#L215">215</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L216" href="#L216">216</a><span class="code-text"><a-p>| Key      | Description                                                              |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L217" href="#L217">217</a><span class="code-text"><a-p>| ---      | -----------                                                              |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L218" href="#L218">218</a><span class="code-text"><a-p>| `name`   | The name of the tree-sitter grammar                                      |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L219" href="#L219">219</a><span class="code-text"><a-p>| `source` | The method of fetching the grammar - a table with a schema defined below |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L220" href="#L220">220</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L221" href="#L221">221</a><span class="code-text"><a-p>Where `source` is a table with either these keys when using a grammar from a</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L222" href="#L222">222</a><span class="code-text"><a-p>git repository:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L223" href="#L223">223</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L224" href="#L224">224</a><span class="code-text"><a-p>| Key    | Description                                               |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L225" href="#L225">225</a><span class="code-text"><a-p>| ---    | -----------                                               |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L226" href="#L226">226</a><span class="code-text"><a-p>| `git`  | A git remote URL from which the grammar should be cloned  |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L227" href="#L227">227</a><span class="code-text"><a-p>| `rev`  | The revision (commit hash or tag) which should be fetched |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L228" href="#L228">228</a><span class="code-text"><a-p>| `subpath` | A path within the grammar directory which should be built. Some grammar repositories host multiple grammars (for example `tree-sitter-typescript` and `tree-sitter-ocaml`) in subdirectories. This key is used to point `hx --grammar build` to the correct path for compilation. When omitted, the root of repository is used |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L229" href="#L229">229</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L230" href="#L230">230</a><span class="code-text"><a-p>### </a-p><a-tt>Choosing grammars</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L231" href="#L231">231</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L232" href="#L232">232</a><span class="code-text"><a-p>You may use a top-level `use-grammars` key to control which grammars are</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L233" href="#L233">233</a><span class="code-text"><a-p>fetched and built when using `hx --grammar fetch` and `hx --grammar build`.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L234" href="#L234">234</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L235" href="#L235">235</a><span class="code-text"><a-p>```</a-p><a-tl>toml</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L236" href="#L236">236</a><span class="code-text"><a-p># Note: this key must come **before** the [[language]] and [[grammar]] sections</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L237" href="#L237">237</a><span class="code-text"><a-p>use-grammars </a-p><a-o>=</a-o><a-p> { </a-p><a-pr>only</a-pr><a-p> </a-p><a-o>=</a-o><a-p> [ </a-p><a-s>&quot;rust&quot;</a-s><a-p>, </a-p><a-s>&quot;c&quot;</a-s><a-p>, </a-p><a-s>&quot;cpp&quot;</a-s><a-p> ] }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L238" href="#L238">238</a><span class="code-text"><a-p># or</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L239" href="#L239">239</a><span class="code-text"><a-p>use-grammars </a-p><a-o>=</a-o><a-p> { </a-p><a-pr>except</a-pr><a-p> </a-p><a-o>=</a-o><a-p> [ </a-p><a-s>&quot;yaml&quot;</a-s><a-p>, </a-p><a-s>&quot;json&quot;</a-s><a-p> ] }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L240" href="#L240">240</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L241" href="#L241">241</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L242" href="#L242">242</a><span class="code-text"><a-p>When omitted, all grammars are fetched and built.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L243" href="#L243">243</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L244" href="#L244">244</a><span class="code-text"><a-tu>[treesitter-language-injection]</a-tu><a-p>: </a-p><a-tu>https://tree-sitter.github.io/tree-sitter/3-syntax-highlighting.html#language-injection</a-tu></span></span></pre></div></div>
</main>
</body>
</html>
