aboutsummaryrefslogtreecommitdiff
path: root/book/src/guides
diff options
context:
space:
mode:
Diffstat (limited to 'book/src/guides')
-rw-r--r--book/src/guides/README.md2
-rw-r--r--book/src/guides/adding_languages.md77
-rw-r--r--book/src/guides/indent.md4
-rw-r--r--book/src/guides/textobject.md16
4 files changed, 52 insertions, 47 deletions
diff --git a/book/src/guides/README.md b/book/src/guides/README.md
index e0c44ce7..c25768e6 100644
--- a/book/src/guides/README.md
+++ b/book/src/guides/README.md
@@ -1,4 +1,4 @@
# Guides
This section contains guides for adding new language server configurations,
-tree-sitter grammars, textobject queries, etc.
+tree-sitter grammars, textobject queries, and other similar items.
diff --git a/book/src/guides/adding_languages.md b/book/src/guides/adding_languages.md
index 6598b9bf..b92af402 100644
--- a/book/src/guides/adding_languages.md
+++ b/book/src/guides/adding_languages.md
@@ -1,45 +1,52 @@
-# Adding languages
+# Adding new languages to Helix
+
+In order to add a new language to Helix, you will need to follow the steps
+below.
## Language configuration
-To add a new language, you need to add a `[[language]]` entry to the
-`languages.toml` (see the [language configuration section]).
+1. Add a new `[[language]]` entry in the `languages.toml` file and provide the
+ necessary configuration for the new language. For more information on
+ language configuration, refer to the
+ [language configuration section](../languages.md) of the documentation.
+2. If you are adding a new language or updating an existing language server
+ configuration, run the command `cargo xtask docgen` to update the
+ [Language Support](../lang-support.md) documentation.
-When adding a new language or Language Server configuration for an existing
-language, run `cargo xtask docgen` to add the new configuration to the
-[Language Support][lang-support] docs before creating a pull request.
-When adding a Language Server configuration, be sure to update the
-[Language Server Wiki][install-lsp-wiki] with installation notes.
+> 💡 If you are adding a new Language Server configuration, make sure to update
+> the
+> [Language Server Wiki](https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers)
+> with the installation instructions.
## Grammar configuration
-If a tree-sitter grammar is available for the language, add a new `[[grammar]]`
-entry to `languages.toml`.
-
-You may use the `source.path` key rather than `source.git` with an absolute path
-to a locally available grammar for testing, but switch to `source.git` before
-submitting a pull request.
+1. If a tree-sitter grammar is available for the new language, add a new
+ `[[grammar]]` entry to the `languages.toml` file.
+2. If you are testing the grammar locally, you can use the `source.path` key
+ with an absolute path to the grammar. However, before submitting a pull
+ request, make sure to switch to using `source.git`.
## Queries
-For a language to have syntax-highlighting and indentation among
-other things, you have to add queries. Add a directory for your
-language with the path `runtime/queries/<name>/`. The tree-sitter
-[website](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#queries)
-gives more info on how to write queries.
-
-> NOTE: When evaluating queries, the first matching query takes
-precedence, which is different from other editors like Neovim where
-the last matching query supersedes the ones before it. See
-[this issue][neovim-query-precedence] for an example.
-
-## Common Issues
-
-- If you get errors when running after switching branches, you may have to update the tree-sitter grammars. Run `hx --grammar fetch` to fetch the grammars and `hx --grammar build` to build any out-of-date grammars.
-
-- If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so`
-
-[language configuration section]: ../languages.md
-[neovim-query-precedence]: https://github.com/helix-editor/helix/pull/1170#issuecomment-997294090
-[install-lsp-wiki]: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers
-[lang-support]: ../lang-support.md
+1. In order to provide syntax highlighting and indentation for the new language,
+ you will need to add queries.
+2. Create a new directory for the language with the path
+ `runtime/queries/<name>/`.
+3. Refer to the
+ [tree-sitter website](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#queries)
+ for more information on writing queries.
+
+> 💡 In Helix, the first matching query takes precedence when evaluating
+> queries, which is different from other editors such as Neovim where the last
+> matching query supersedes the ones before it. See
+> [this issue](https://github.com/helix-editor/helix/pull/1170#issuecomment-997294090)
+> for an example.
+
+## Common issues
+
+- If you encounter errors when running Helix after switching branches, you may
+ need to update the tree-sitter grammars. Run the command `hx --grammar fetch`
+ to fetch the grammars and `hx --grammar build` to build any out-of-date
+ grammars.
+- If a parser is causing a segfault, or you want to remove it, make sure to
+ remove the compiled parser located at `runtime/grammars/<name>.so`.
diff --git a/book/src/guides/indent.md b/book/src/guides/indent.md
index 0e259289..b660d785 100644
--- a/book/src/guides/indent.md
+++ b/book/src/guides/indent.md
@@ -1,4 +1,4 @@
-# Adding Indent Queries
+# Adding indent queries
Helix uses tree-sitter to correctly indent new lines. This requires
a tree-sitter grammar and an `indent.scm` query file placed in
@@ -36,7 +36,7 @@ changed by using a `#set!` declaration anywhere in the pattern:
(#set! "scope" "all"))
```
-## Capture Types
+## Capture types
- `@indent` (default scope `tail`):
Increase the indent level by 1. Multiple occurrences in the same line
diff --git a/book/src/guides/textobject.md b/book/src/guides/textobject.md
index 8a217354..405f11c1 100644
--- a/book/src/guides/textobject.md
+++ b/book/src/guides/textobject.md
@@ -1,14 +1,14 @@
-# Adding Textobject Queries
+# Adding textobject queries
-Textobjects that are language specific ([like functions, classes, etc][textobjects])
-require an accompanying tree-sitter grammar and a `textobjects.scm` query file
+Helix supports textobjects that are language specific, such as functions, classes, etc.
+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
documentation][tree-sitter-queries].
Query files should be placed in `runtime/queries/{language}/textobjects.scm`
-when contributing. Note that to test the query files locally you should put
+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).
@@ -28,9 +28,9 @@ The following [captures][tree-sitter-captures] are recognized:
[Example query files][textobject-examples] can be found in the helix GitHub repository.
-## Queries for Textobject Based Navigation
+## Queries for textobject based navigation
-[Tree-sitter based navigation][textobjects-nav] is done using captures in the
+Tree-sitter based navigation in Helix is done using captures in the
following order:
- `object.movement`
@@ -38,12 +38,10 @@ following order:
- `object.inside`
For example if a `function.around` capture has been already defined for a language
-in it's `textobjects.scm` file, function navigation should also work automatically.
+in its `textobjects.scm` file, function navigation should also work automatically.
`function.movement` should be defined only if the node captured by `function.around`
doesn't make sense in a navigation context.
-[textobjects]: ../usage.md#textobjects
-[textobjects-nav]: ../usage.md#tree-sitter-textobject-based-navigation
[tree-sitter-queries]: https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax
[tree-sitter-captures]: https://tree-sitter.github.io/tree-sitter/using-parsers#capturing-nodes
[textobject-examples]: https://github.com/search?q=repo%3Ahelix-editor%2Fhelix+filename%3Atextobjects.scm&type=Code&ref=advsearch&l=&l=