Adding Injection Queries
Writing language injection queries allows one to highlight a specific node as a different language. -In addition to the standard language injection options used by tree-sitter, there +In addition to the standard language injection options used by tree-sitter, there are a few Helix specific extensions that allow for more control.
And example of a simple query that would highlight all strings as bash in Nix:
((string_expression (string_fragment) @injection.content)
diff --git a/master/guides/textobject.html b/master/guides/textobject.html
index 633d20505..e648fb20a 100644
--- a/master/guides/textobject.html
+++ b/master/guides/textobject.html
@@ -165,13 +165,13 @@
These textobjects require an accompanying tree-sitter grammar and a textobjects.scm
query file
to work properly. Tree-sitter allows us to query the source code syntax tree
and capture specific parts of it. The queries are written in a lisp dialect.
-More information on how to write queries can be found in the official tree-sitter
+More information on how to write queries can be found in the official tree-sitter
documentation.
Query files should be placed in runtime/queries/{language}/textobjects.scm
when contributing to Helix. Note that to test the query files locally you should put
them under your local runtime directory (~/.config/helix/runtime
on Linux
for example).
-The following captures are recognized:
+The following captures are recognized:
Capture Name
function.inside
function.around
diff --git a/master/languages.html b/master/languages.html
index ce9bd8b36..37b931132 100644
--- a/master/languages.html
+++ b/master/languages.html
@@ -210,7 +210,7 @@ language-servers = [ "mylang-lsp" ]
name
The name of the language
language-id
The language-id for language servers, checkout the table at TextDocumentItem for the right id
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.<name>
or text.<name>
in case of markup languages
-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 site.
+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 site.
file-types
The filetypes of the language, for example ["yml", "yaml"]
. See the file-type detection section below.
shebangs
The interpreters from the shebang line, for example ["sh", "bash"]
roots
A set of marker files to look for when trying to find the workspace root. For example Cargo.lock
, yarn.lock
diff --git a/master/print.html b/master/print.html
index c1dc1bce9..f0d0046c9 100644
--- a/master/print.html
+++ b/master/print.html
@@ -2244,7 +2244,7 @@ berry = "#2A2A4D"
Scopes
The following is a list of scopes available to use for styling:
Syntax highlighting
-These keys match tree-sitter scopes.
+These keys match tree-sitter scopes.
When determining styling for a highlight, the longest matching theme key will be used. For example, if the highlight is function.builtin.static
, the key function.builtin
will be used instead of function
.
We use a similar set of scopes as
Sublime Text. See also
@@ -2704,7 +2704,7 @@ language-servers = [ "mylang-lsp" ]
name
The name of the language
language-id
The language-id for language servers, checkout the table at TextDocumentItem for the right id
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.<name>
or text.<name>
in case of markup languages
-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 site.
+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 site.
file-types
The filetypes of the language, for example ["yml", "yaml"]
. See the file-type detection section below.
shebangs
The interpreters from the shebang line, for example ["sh", "bash"]
roots
A set of marker files to look for when trying to find the workspace root. For example Cargo.lock
, yarn.lock
@@ -2892,7 +2892,7 @@ you will need to add queries.
Create a new directory for the language with the path
runtime/queries/<name>/
.
Refer to the
-tree-sitter website
+tree-sitter website
for more information on writing queries.
A list of highlight captures can be found on the themes page.
@@ -2918,13 +2918,13 @@ remove the compiled parser located at runtime/grammars/<name>.sotextobjects.scm
query file
to work properly. Tree-sitter allows us to query the source code syntax tree
and capture specific parts of it. The queries are written in a lisp dialect.
-More information on how to write queries can be found in the official tree-sitter
+More information on how to write queries can be found in the official tree-sitter
documentation.
Query files should be placed in runtime/queries/{language}/textobjects.scm
when contributing to Helix. Note that to test the query files locally you should put
them under your local runtime directory (~/.config/helix/runtime
on Linux
for example).
-The following captures are recognized:
+The following captures are recognized:
Capture Name
function.inside
function.around
@@ -3284,7 +3284,7 @@ line. (Note these scopes are the defaults for @indent
and @ou
written explicitly for demonstration.)
Adding Injection Queries
Writing language injection queries allows one to highlight a specific node as a different language.
-In addition to the standard language injection options used by tree-sitter, there
+In addition to the standard language injection options used by tree-sitter, there
are a few Helix specific extensions that allow for more control.
And example of a simple query that would highlight all strings as bash in Nix:
((string_expression (string_fragment) @injection.content)
diff --git a/master/themes.html b/master/themes.html
index f582f5220..ad4eb48ca 100644
--- a/master/themes.html
+++ b/master/themes.html
@@ -264,7 +264,7 @@ berry = "#2A2A4D"
Scopes
The following is a list of scopes available to use for styling:
Syntax highlighting
-These keys match tree-sitter scopes.
+These keys match tree-sitter scopes.
When determining styling for a highlight, the longest matching theme key will be used. For example, if the highlight is function.builtin.static
, the key function.builtin
will be used instead of function
.
We use a similar set of scopes as
Sublime Text. See also