mirror of https://github.com/helix-editor/helix
Rewrite and refactor the guides
parent
421b5ebace
commit
dc6a0e3064
@ -1,4 +1,4 @@
|
|||||||
# Guides
|
# Guides
|
||||||
|
|
||||||
This section contains guides for adding new language server configurations,
|
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.
|
||||||
|
@ -1,45 +1,59 @@
|
|||||||
# 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
|
## Language configuration
|
||||||
|
|
||||||
To add a new language, you need to add a `[[language]]` entry to the
|
1. Add a new `[[language]]` entry in the `languages.toml` file and provide the
|
||||||
`languages.toml` (see the [language configuration section]).
|
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
|
> 💡 If you are adding a new Language Server configuration, make sure to update
|
||||||
language, run `cargo xtask docgen` to add the new configuration to the
|
> the
|
||||||
[Language Support][lang-support] docs before creating a pull request.
|
> [Language Server Wiki](https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers)
|
||||||
When adding a Language Server configuration, be sure to update the
|
> with the installation instructions.
|
||||||
[Language Server Wiki][install-lsp-wiki] with installation notes.
|
|
||||||
|
|
||||||
## Grammar configuration
|
## Grammar configuration
|
||||||
|
|
||||||
If a tree-sitter grammar is available for the language, add a new `[[grammar]]`
|
1. If a tree-sitter grammar is available for the new language, add a new
|
||||||
entry to `languages.toml`.
|
`[[grammar]]` entry to the `languages.toml` file.
|
||||||
|
2. If you are testing the grammar locally, you can use the `source.path` key
|
||||||
You may use the `source.path` key rather than `source.git` with an absolute path
|
with an absolute path to the grammar. However, before submitting a pull
|
||||||
to a locally available grammar for testing, but switch to `source.git` before
|
request, make sure to switch to using `source.git`.
|
||||||
submitting a pull request.
|
|
||||||
|
|
||||||
## Queries
|
## Queries
|
||||||
|
|
||||||
For a language to have syntax-highlighting and indentation among
|
1. In order to provide syntax highlighting and indentation for the new language,
|
||||||
other things, you have to add queries. Add a directory for your
|
you will need to add queries.
|
||||||
language with the path `runtime/queries/<name>/`. The tree-sitter
|
2. Create a new directory for the language with the path
|
||||||
[website](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#queries)
|
`runtime/queries/<name>/`.
|
||||||
gives more info on how to write queries.
|
3. Refer to the
|
||||||
|
[tree-sitter website](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#queries)
|
||||||
> NOTE: When evaluating queries, the first matching query takes
|
for more information on writing queries.
|
||||||
precedence, which is different from other editors like Neovim where
|
|
||||||
the last matching query supersedes the ones before it. See
|
> 💡 In Helix, the first matching query takes precedence when evaluating
|
||||||
[this issue][neovim-query-precedence] for an example.
|
> queries, which is different from other editors such as Neovim where the last
|
||||||
|
> matching query supersedes the ones before it. See
|
||||||
## Common Issues
|
> [this issue](https://github.com/helix-editor/helix/pull/1170#issuecomment-997294090)
|
||||||
|
> for an example.
|
||||||
- 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.
|
|
||||||
|
## Common issues
|
||||||
- If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so`
|
|
||||||
|
- 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/grammar/<name>.so`.
|
||||||
|
|
||||||
[language configuration section]: ../languages.md
|
[language configuration section]: ../languages.md
|
||||||
[neovim-query-precedence]: https://github.com/helix-editor/helix/pull/1170#issuecomment-997294090
|
[neovim-query-precedence]:
|
||||||
[install-lsp-wiki]: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers
|
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
|
[lang-support]: ../lang-support.md
|
||||||
|
Loading…
Reference in New Issue