aboutsummaryrefslogtreecommitdiff
path: root/book
diff options
context:
space:
mode:
authorJJ2023-11-01 01:00:19 +0000
committerJJ2023-11-01 04:08:32 +0000
commiteaf8d6d30da5014a3c475c4187b9dccfe621afd5 (patch)
treedd1d64f6b72b27256caa988120ab3075d08a9c69 /book
parent5c371208692df2727d02a37646b7829f011680a8 (diff)
Add rainbow tree-sitter highlights
ref: https://github.com/helix-editor/helix/issues/695 ref: https://github.com/helix-editor/helix/pull/2857 Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Diffstat (limited to 'book')
-rw-r--r--book/src/SUMMARY.md1
-rw-r--r--book/src/configuration.md1
-rw-r--r--book/src/generated/lang-support.md370
-rw-r--r--book/src/guides/README.md2
-rw-r--r--book/src/guides/rainbow_bracket_queries.md132
-rw-r--r--book/src/languages.md2
-rw-r--r--book/src/themes.md11
7 files changed, 333 insertions, 186 deletions
diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md
index ba330cf7..dcd128de 100644
--- a/book/src/SUMMARY.md
+++ b/book/src/SUMMARY.md
@@ -17,3 +17,4 @@
- [Adding textobject queries](./guides/textobject.md)
- [Adding indent queries](./guides/indent.md)
- [Adding injection queries](./guides/injection.md)
+ - [Adding rainbow bracket queries](./guides/rainbow_bracket_queries.md)
diff --git a/book/src/configuration.md b/book/src/configuration.md
index d223b6e9..9b0ff36a 100644
--- a/book/src/configuration.md
+++ b/book/src/configuration.md
@@ -65,6 +65,7 @@ Its settings will be merged with the configuration directory `config.toml` and t
| `workspace-lsp-roots` | Directories relative to the workspace root that are treated as LSP roots. Should only be set in `.helix/config.toml` | `[]` |
| `default-line-ending` | The line ending to use for new documents. Can be `native`, `lf`, `crlf`, `ff`, `cr` or `nel`. `native` uses the platform's native line ending (`crlf` on Windows, otherwise `lf`). | `native` |
| `insert-final-newline` | Whether to automatically insert a trailing line-ending on write if missing | `true` |
+| `rainbow-brackets` | Whether to render rainbow colors for matching brackets. Requires tree-sitter `rainbows.scm` queries for the language. | `false` |
### `[editor.statusline]` Section
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 6fdc6f11..04627c8e 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -1,185 +1,185 @@
-| Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Default LSP |
-| --- | --- | --- | --- | --- |
-| astro | ✓ | | | |
-| awk | ✓ | ✓ | | `awk-language-server` |
-| bash | ✓ | ✓ | ✓ | `bash-language-server` |
-| bass | ✓ | | | `bass` |
-| beancount | ✓ | | | |
-| bibtex | ✓ | | | `texlab` |
-| bicep | ✓ | | | `bicep-langserver` |
-| blueprint | ✓ | | | `blueprint-compiler` |
-| c | ✓ | ✓ | ✓ | `clangd` |
-| c-sharp | ✓ | ✓ | | `OmniSharp` |
-| cabal | | | | |
-| cairo | ✓ | ✓ | ✓ | `cairo-language-server` |
-| capnp | ✓ | | ✓ | |
-| clojure | ✓ | | | `clojure-lsp` |
-| cmake | ✓ | ✓ | ✓ | `cmake-language-server` |
-| comment | ✓ | | | |
-| common-lisp | ✓ | | | `cl-lsp` |
-| cpon | ✓ | | ✓ | |
-| cpp | ✓ | ✓ | ✓ | `clangd` |
-| crystal | ✓ | ✓ | | `crystalline` |
-| css | ✓ | | | `vscode-css-language-server` |
-| cue | ✓ | | | `cuelsp` |
-| d | ✓ | ✓ | ✓ | `serve-d` |
-| dart | ✓ | | ✓ | `dart` |
-| devicetree | ✓ | | | |
-| dhall | ✓ | ✓ | | `dhall-lsp-server` |
-| diff | ✓ | | | |
-| dockerfile | ✓ | | | `docker-langserver` |
-| dot | ✓ | | | `dot-language-server` |
-| dtd | ✓ | | | |
-| edoc | ✓ | | | |
-| eex | ✓ | | | |
-| ejs | ✓ | | | |
-| elixir | ✓ | ✓ | ✓ | `elixir-ls` |
-| elm | ✓ | ✓ | | `elm-language-server` |
-| elvish | ✓ | | | `elvish` |
-| env | ✓ | | | |
-| erb | ✓ | | | |
-| erlang | ✓ | ✓ | | `erlang_ls` |
-| esdl | ✓ | | | |
-| fish | ✓ | ✓ | ✓ | |
-| forth | ✓ | | | `forth-lsp` |
-| fortran | ✓ | | ✓ | `fortls` |
-| fsharp | ✓ | | | `fsautocomplete` |
-| gas | ✓ | ✓ | | |
-| gdscript | ✓ | ✓ | ✓ | |
-| gemini | ✓ | | | |
-| git-attributes | ✓ | | | |
-| git-commit | ✓ | ✓ | | |
-| git-config | ✓ | | | |
-| git-ignore | ✓ | | | |
-| git-rebase | ✓ | | | |
-| gleam | ✓ | ✓ | | `gleam` |
-| glsl | ✓ | ✓ | ✓ | |
-| go | ✓ | ✓ | ✓ | `gopls` |
-| godot-resource | ✓ | | | |
-| gomod | ✓ | | | `gopls` |
-| gotmpl | ✓ | | | `gopls` |
-| gowork | ✓ | | | `gopls` |
-| graphql | ✓ | | | `graphql-lsp` |
-| hare | ✓ | | | |
-| haskell | ✓ | ✓ | | `haskell-language-server-wrapper` |
-| haskell-persistent | ✓ | | | |
-| hcl | ✓ | | ✓ | `terraform-ls` |
-| heex | ✓ | ✓ | | `elixir-ls` |
-| hosts | ✓ | | | |
-| html | ✓ | | | `vscode-html-language-server` |
-| hurl | ✓ | | ✓ | |
-| idris | | | | `idris2-lsp` |
-| iex | ✓ | | | |
-| ini | ✓ | | | |
-| java | ✓ | ✓ | ✓ | `jdtls` |
-| javascript | ✓ | ✓ | ✓ | `typescript-language-server` |
-| jinja | ✓ | | | |
-| jsdoc | ✓ | | | |
-| json | ✓ | | ✓ | `vscode-json-language-server` |
-| json5 | ✓ | | | |
-| jsonnet | ✓ | | | `jsonnet-language-server` |
-| jsx | ✓ | ✓ | ✓ | `typescript-language-server` |
-| julia | ✓ | ✓ | ✓ | `julia` |
-| just | ✓ | ✓ | ✓ | |
-| kdl | ✓ | | | |
-| kotlin | ✓ | | | `kotlin-language-server` |
-| latex | ✓ | ✓ | | `texlab` |
-| lean | ✓ | | | `lean` |
-| ledger | ✓ | | | |
-| llvm | ✓ | ✓ | ✓ | |
-| llvm-mir | ✓ | ✓ | ✓ | |
-| llvm-mir-yaml | ✓ | | ✓ | |
-| lua | ✓ | ✓ | ✓ | `lua-language-server` |
-| make | ✓ | | | |
-| markdoc | ✓ | | | `markdoc-ls` |
-| markdown | ✓ | | | `marksman` |
-| markdown.inline | ✓ | | | |
-| matlab | ✓ | ✓ | ✓ | |
-| mermaid | ✓ | | | |
-| meson | ✓ | | ✓ | |
-| mint | | | | `mint` |
-| msbuild | ✓ | | ✓ | |
-| nasm | ✓ | ✓ | | |
-| nickel | ✓ | | ✓ | `nls` |
-| nim | ✓ | ✓ | ✓ | `nimlangserver` |
-| nix | ✓ | | | `nil` |
-| nu | ✓ | | | |
-| nunjucks | ✓ | | | |
-| ocaml | ✓ | | ✓ | `ocamllsp` |
-| ocaml-interface | ✓ | | | `ocamllsp` |
-| odin | ✓ | | ✓ | `ols` |
-| opencl | ✓ | ✓ | ✓ | `clangd` |
-| openscad | ✓ | | | `openscad-lsp` |
-| org | ✓ | | | |
-| pascal | ✓ | ✓ | | `pasls` |
-| passwd | ✓ | | | |
-| pem | ✓ | | | |
-| perl | ✓ | ✓ | ✓ | `perlnavigator` |
-| php | ✓ | ✓ | ✓ | `intelephense` |
-| po | ✓ | ✓ | | |
-| pod | ✓ | | | |
-| ponylang | ✓ | ✓ | ✓ | |
-| prisma | ✓ | | | `prisma-language-server` |
-| prolog | | | | `swipl` |
-| protobuf | ✓ | | ✓ | `bufls`, `pb` |
-| prql | ✓ | | | |
-| purescript | ✓ | ✓ | | `purescript-language-server` |
-| python | ✓ | ✓ | ✓ | `pylsp` |
-| qml | ✓ | | ✓ | `qmlls` |
-| r | ✓ | | | `R` |
-| racket | ✓ | | | `racket` |
-| regex | ✓ | | | |
-| rego | ✓ | | | `regols` |
-| rescript | ✓ | ✓ | | `rescript-language-server` |
-| rmarkdown | ✓ | | ✓ | `R` |
-| robot | ✓ | | | `robotframework_ls` |
-| ron | ✓ | | ✓ | |
-| rst | ✓ | | | |
-| ruby | ✓ | ✓ | ✓ | `solargraph` |
-| rust | ✓ | ✓ | ✓ | `rust-analyzer` |
-| sage | ✓ | ✓ | | |
-| scala | ✓ | | ✓ | `metals` |
-| scheme | ✓ | | | |
-| scss | ✓ | | | `vscode-css-language-server` |
-| slint | ✓ | | ✓ | `slint-lsp` |
-| smithy | ✓ | | | `cs` |
-| sml | ✓ | | | |
-| solidity | ✓ | | | `solc` |
-| sql | ✓ | | | |
-| sshclientconfig | ✓ | | | |
-| starlark | ✓ | ✓ | | |
-| strace | ✓ | | | |
-| svelte | ✓ | | ✓ | `svelteserver` |
-| sway | ✓ | ✓ | ✓ | `forc` |
-| swift | ✓ | | | `sourcekit-lsp` |
-| t32 | ✓ | | | |
-| tablegen | ✓ | ✓ | ✓ | |
-| task | ✓ | | | |
-| templ | ✓ | | | `templ` |
-| tfvars | ✓ | | ✓ | `terraform-ls` |
-| todotxt | ✓ | | | |
-| toml | ✓ | | | `taplo` |
-| tsq | ✓ | | | |
-| tsx | ✓ | ✓ | ✓ | `typescript-language-server` |
-| twig | ✓ | | | |
-| typescript | ✓ | ✓ | ✓ | `typescript-language-server` |
-| ungrammar | ✓ | | | |
-| unison | ✓ | | | |
-| uxntal | ✓ | | | |
-| v | ✓ | ✓ | ✓ | `v-analyzer` |
-| vala | ✓ | | | `vala-language-server` |
-| verilog | ✓ | ✓ | | `svlangserver` |
-| vhdl | ✓ | | | `vhdl_ls` |
-| vhs | ✓ | | | |
-| vue | ✓ | | | `vue-language-server` |
-| wast | ✓ | | | |
-| wat | ✓ | | | |
-| webc | ✓ | | | |
-| wgsl | ✓ | | | `wgsl_analyzer` |
-| wit | ✓ | | ✓ | |
-| wren | ✓ | ✓ | ✓ | |
-| xit | ✓ | | | |
-| xml | ✓ | | ✓ | |
-| yaml | ✓ | | ✓ | `yaml-language-server`, `ansible-language-server` |
-| yuck | ✓ | | | |
-| zig | ✓ | ✓ | ✓ | `zls` |
+| Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Rainbow Brackets | Default LSP |
+| --- | --- | --- | --- | --- | --- |
+| astro | ✓ | | | | |
+| awk | ✓ | ✓ | | | `awk-language-server` |
+| bash | ✓ | ✓ | ✓ | ✓ | `bash-language-server` |
+| bass | ✓ | | | | `bass` |
+| beancount | ✓ | | | | |
+| bibtex | ✓ | | | | `texlab` |
+| bicep | ✓ | | | | `bicep-langserver` |
+| blueprint | ✓ | | | | `blueprint-compiler` |
+| c | ✓ | ✓ | ✓ | ✓ | `clangd` |
+| c-sharp | ✓ | ✓ | | | `OmniSharp` |
+| cabal | | | | | |
+| cairo | ✓ | ✓ | ✓ | | `cairo-language-server` |
+| capnp | ✓ | | ✓ | | |
+| clojure | ✓ | | | ✓ | `clojure-lsp` |
+| cmake | ✓ | ✓ | ✓ | | `cmake-language-server` |
+| comment | ✓ | | | | |
+| common-lisp | ✓ | | | ✓ | `cl-lsp` |
+| cpon | ✓ | | ✓ | | |
+| cpp | ✓ | ✓ | ✓ | ✓ | `clangd` |
+| crystal | ✓ | ✓ | | | `crystalline` |
+| css | ✓ | | | ✓ | `vscode-css-language-server` |
+| cue | ✓ | | | | `cuelsp` |
+| d | ✓ | ✓ | ✓ | | `serve-d` |
+| dart | ✓ | | ✓ | | `dart` |
+| devicetree | ✓ | | | | |
+| dhall | ✓ | ✓ | | | `dhall-lsp-server` |
+| diff | ✓ | | | | |
+| dockerfile | ✓ | | | | `docker-langserver` |
+| dot | ✓ | | | | `dot-language-server` |
+| dtd | ✓ | | | | |
+| edoc | ✓ | | | | |
+| eex | ✓ | | | | |
+| ejs | ✓ | | | | |
+| elixir | ✓ | ✓ | ✓ | ✓ | `elixir-ls` |
+| elm | ✓ | ✓ | | | `elm-language-server` |
+| elvish | ✓ | | | | `elvish` |
+| env | ✓ | | | | |
+| erb | ✓ | | | | |
+| erlang | ✓ | ✓ | | ✓ | `erlang_ls` |
+| esdl | ✓ | | | | |
+| fish | ✓ | ✓ | ✓ | | |
+| forth | ✓ | | | | `forth-lsp` |
+| fortran | ✓ | | ✓ | | `fortls` |
+| fsharp | ✓ | | | | `fsautocomplete` |
+| gas | ✓ | ✓ | | | |
+| gdscript | ✓ | ✓ | ✓ | | |
+| gemini | ✓ | | | | |
+| git-attributes | ✓ | | | | |
+| git-commit | ✓ | ✓ | | | |
+| git-config | ✓ | | | | |
+| git-ignore | ✓ | | | | |
+| git-rebase | ✓ | | | | |
+| gleam | ✓ | ✓ | | | `gleam` |
+| glsl | ✓ | ✓ | ✓ | | |
+| go | ✓ | ✓ | ✓ | ✓ | `gopls` |
+| godot-resource | ✓ | | | | |
+| gomod | ✓ | | | | `gopls` |
+| gotmpl | ✓ | | | | `gopls` |
+| gowork | ✓ | | | | `gopls` |
+| graphql | ✓ | | | | `graphql-lsp` |
+| hare | ✓ | | | | |
+| haskell | ✓ | ✓ | | | `haskell-language-server-wrapper` |
+| haskell-persistent | ✓ | | | | |
+| hcl | ✓ | | ✓ | | `terraform-ls` |
+| heex | ✓ | ✓ | | | `elixir-ls` |
+| hosts | ✓ | | | | |
+| html | ✓ | | | ✓ | `vscode-html-language-server` |
+| hurl | ✓ | | ✓ | | |
+| idris | | | | | `idris2-lsp` |
+| iex | ✓ | | | | |
+| ini | ✓ | | | | |
+| java | ✓ | ✓ | ✓ | ✓ | `jdtls` |
+| javascript | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
+| jinja | ✓ | | | | |
+| jsdoc | ✓ | | | | |
+| json | ✓ | | ✓ | ✓ | `vscode-json-language-server` |
+| json5 | ✓ | | | | |
+| jsonnet | ✓ | | | | `jsonnet-language-server` |
+| jsx | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
+| julia | ✓ | ✓ | ✓ | | `julia` |
+| just | ✓ | ✓ | ✓ | | |
+| kdl | ✓ | | | | |
+| kotlin | ✓ | | | | `kotlin-language-server` |
+| latex | ✓ | ✓ | | | `texlab` |
+| lean | ✓ | | | | `lean` |
+| ledger | ✓ | | | | |
+| llvm | ✓ | ✓ | ✓ | | |
+| llvm-mir | ✓ | ✓ | ✓ | | |
+| llvm-mir-yaml | ✓ | | ✓ | | |
+| lua | ✓ | ✓ | ✓ | | `lua-language-server` |
+| make | ✓ | | | | |
+| markdoc | ✓ | | | | `markdoc-ls` |
+| markdown | ✓ | | | | `marksman` |
+| markdown.inline | ✓ | | | | |
+| matlab | ✓ | ✓ | ✓ | | |
+| mermaid | ✓ | | | | |
+| meson | ✓ | | ✓ | | |
+| mint | | | | | `mint` |
+| msbuild | ✓ | | ✓ | | |
+| nasm | ✓ | ✓ | | | |
+| nickel | ✓ | | ✓ | | `nls` |
+| nim | ✓ | ✓ | ✓ | | `nimlangserver` |
+| nix | ✓ | | | ✓ | `nil` |
+| nu | ✓ | | | | |
+| nunjucks | ✓ | | | | |
+| ocaml | ✓ | | ✓ | | `ocamllsp` |
+| ocaml-interface | ✓ | | | | `ocamllsp` |
+| odin | ✓ | | ✓ | | `ols` |
+| opencl | ✓ | ✓ | ✓ | | `clangd` |
+| openscad | ✓ | | | | `openscad-lsp` |
+| org | ✓ | | | | |
+| pascal | ✓ | ✓ | | | `pasls` |
+| passwd | ✓ | | | | |
+| pem | ✓ | | | | |
+| perl | ✓ | ✓ | ✓ | | `perlnavigator` |
+| php | ✓ | ✓ | ✓ | | `intelephense` |
+| po | ✓ | ✓ | | | |
+| pod | ✓ | | | | |
+| ponylang | ✓ | ✓ | ✓ | | |
+| prisma | ✓ | | | | `prisma-language-server` |
+| prolog | | | | | `swipl` |
+| protobuf | ✓ | | ✓ | | `bufls`, `pb` |
+| prql | ✓ | | | | |
+| purescript | ✓ | ✓ | | | `purescript-language-server` |
+| python | ✓ | ✓ | ✓ | ✓ | `pylsp` |
+| qml | ✓ | | ✓ | | `qmlls` |
+| r | ✓ | | | | `R` |
+| racket | ✓ | | | ✓ | `racket` |
+| regex | ✓ | | | ✓ | |
+| rego | ✓ | | | | `regols` |
+| rescript | ✓ | ✓ | | | `rescript-language-server` |
+| rmarkdown | ✓ | | ✓ | | `R` |
+| robot | ✓ | | | | `robotframework_ls` |
+| ron | ✓ | | ✓ | | |
+| rst | ✓ | | | | |
+| ruby | ✓ | ✓ | ✓ | ✓ | `solargraph` |
+| rust | ✓ | ✓ | ✓ | ✓ | `rust-analyzer` |
+| sage | ✓ | ✓ | | | |
+| scala | ✓ | | ✓ | | `metals` |
+| scheme | ✓ | | | ✓ | |
+| scss | ✓ | | | ✓ | `vscode-css-language-server` |
+| slint | ✓ | | ✓ | | `slint-lsp` |
+| smithy | ✓ | | | | `cs` |
+| sml | ✓ | | | | |
+| solidity | ✓ | | | | `solc` |
+| sql | ✓ | | | | |
+| sshclientconfig | ✓ | | | | |
+| starlark | ✓ | ✓ | | ✓ | |
+| strace | ✓ | | | | |
+| svelte | ✓ | | ✓ | | `svelteserver` |
+| sway | ✓ | ✓ | ✓ | | `forc` |
+| swift | ✓ | | | | `sourcekit-lsp` |
+| t32 | ✓ | | | | |
+| tablegen | ✓ | ✓ | ✓ | | |
+| task | ✓ | | | | |
+| templ | ✓ | | | | `templ` |
+| tfvars | ✓ | | ✓ | | `terraform-ls` |
+| todotxt | ✓ | | | | |
+| toml | ✓ | | | ✓ | `taplo` |
+| tsq | ✓ | | | ✓ | |
+| tsx | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
+| twig | ✓ | | | | |
+| typescript | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
+| ungrammar | ✓ | | | | |
+| unison | ✓ | | | | |
+| uxntal | ✓ | | | | |
+| v | ✓ | ✓ | ✓ | | `v-analyzer` |
+| vala | ✓ | | | | `vala-language-server` |
+| verilog | ✓ | ✓ | | | `svlangserver` |
+| vhdl | ✓ | | | | `vhdl_ls` |
+| vhs | ✓ | | | | |
+| vue | ✓ | | | | `vue-language-server` |
+| wast | ✓ | | | | |
+| wat | ✓ | | | | |
+| webc | ✓ | | | | |
+| wgsl | ✓ | | | | `wgsl_analyzer` |
+| wit | ✓ | | ✓ | | |
+| wren | ✓ | ✓ | ✓ | | |
+| xit | ✓ | | | | |
+| xml | ✓ | | ✓ | ✓ | |
+| yaml | ✓ | | ✓ | ✓ | `yaml-language-server`, `ansible-language-server` |
+| yuck | ✓ | | | | |
+| zig | ✓ | ✓ | ✓ | ✓ | `zls` |
diff --git a/book/src/guides/README.md b/book/src/guides/README.md
index c25768e6..e53983d6 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, and other similar items.
+tree-sitter grammars, textobject and rainbow bracket queries, and other similar items.
diff --git a/book/src/guides/rainbow_bracket_queries.md b/book/src/guides/rainbow_bracket_queries.md
new file mode 100644
index 00000000..1cba6a99
--- /dev/null
+++ b/book/src/guides/rainbow_bracket_queries.md
@@ -0,0 +1,132 @@
+# Adding Rainbow Bracket Queries
+
+Helix uses `rainbows.scm` tree-sitter query files to provide rainbow bracket
+functionality.
+
+Tree-sitter queries are documented in the tree-sitter online documentation.
+If you're writing queries for the first time, be sure to check out the section
+on [syntax highlighting queries] and on [query syntax].
+
+Rainbow queries have two captures: `@rainbow.scope` and `@rainbow.bracket`.
+`@rainbow.scope` should capture any node that increases the nesting level
+while `@rainbow.bracket` should capture any bracket nodes. Put another way:
+`@rainbow.scope` switches to the next rainbow color for all nodes in the tree
+under it while `@rainbow.bracket` paints captured nodes with the current
+rainbow color.
+
+For an example, let's add rainbow queries for the tree-sitter query (TSQ)
+language itself. These queries will go into a
+`runtime/queries/tsq/rainbows.scm` file in the repository root.
+
+First we'll add the `@rainbow.bracket` captures. TSQ only has parentheses and
+square brackets:
+
+```tsq
+["(" ")" "[" "]"] @rainbow.bracket
+```
+
+The ordering of the nodes within the alternation (square brackets) is not
+taken into consideration.
+
+> Note: Why are these nodes quoted? Most syntax highlights capture text
+> surrounded by parentheses. These are _named nodes_ and correspond to the
+> names of rules in the grammar. Brackets are usually written in tree-sitter
+> grammars as literal strings, for example:
+>
+> ```js
+> {
+> // ...
+> arguments: seq("(", repeat($.argument), ")"),
+> // ...
+> }
+> ```
+>
+> Nodes written as literal strings in tree-sitter grammars may be captured
+> in queries with those same literal strings.
+
+Then we'll add `@rainbow.scope` captures. The easiest way to do this is to
+view the `grammar.js` file in the tree-sitter grammar's repository. For TSQ,
+that file is [here][tsq grammar.js]. As we scroll down the `grammar.js`, we
+see that the `(alternation)`, (L36) `(group)` (L57), `(named_node)` (L59),
+`(predicate)` (L87) and `(wildcard_node)` (L97) nodes all contain literal
+parentheses or square brackets in their definitions. These nodes are all
+direct parents of brackets and happen to also be the nodes we want to change
+to the next rainbow color, so we capture them as `@rainbow.scope`.
+
+```tsq
+[
+ (group)
+ (named_node)
+ (wildcard_node)
+ (predicate)
+ (alternation)
+] @rainbow.scope
+```
+
+This strategy works as a rule of thumb for most programming and configuration
+languages. Markup languages can be trickier and may take additional
+experimentation to find the correct nodes to use for scopes and brackets.
+
+The `:tree-sitter-subtree` command shows the syntax tree under the primary
+selection in S-expression format and can be a useful tool for determining how
+to write a query.
+
+### Properties
+
+The `rainbow.include-children` property may be applied to `@rainbow.scope`
+captures. By default, all `@rainbow.bracket` captures must be direct descendant
+of a node captured with `@rainbow.scope` in a syntax tree in order to be
+highlighted. The `rainbow.include-children` property disables that check and
+allows `@rainbow.bracket` captures to be highlighted if they are direct or
+indirect descendants of some node captured with `@rainbow.scope`.
+
+For example, this property is used in the HTML rainbow queries.
+
+For a document like `<a>link</a>`, the syntax tree is:
+
+```tsq
+(element ; <a>link</a>
+ (start_tag ; <a>
+ (tag_name)) ; a
+ (text) ; link
+ (end_tag ; </a>
+ (tag_name))) ; a
+```
+
+If we want to highlight the `<`, `>` and `</` nodes with rainbow colors, we
+capture them as `@rainbow.bracket`:
+
+```tsq
+["<" ">" "</"] @rainbow.bracket
+```
+
+And we capture `(element)` as `@rainbow.scope` because `(element)` nodes nest
+within each other: they increment the nesting level and switch to the next
+color in the rainbow.
+
+```tsq
+(element) @rainbow.scope
+```
+
+But this combination of `@rainbow.scope` and `@rainbow.bracket` will not
+highlight any nodes. `<`, `>` and `</` are children of the `(start_tag)` and
+`(end_tag)` nodes. We can't capture `(start_tag)` and `(end_tag)` as
+`@rainbow.scope` because they don't nest other elements. We can fix this case
+by removing the requirement that `<`, `>` and `</` are direct descendants of
+`(element)` using the `rainbow.include-children` property.
+
+```tsq
+((element) @rainbow.scope
+ (#set! rainbow.include-children))
+```
+
+With this property set, `<`, `>`, and `</` will highlight with rainbow colors
+even though they aren't direct descendents of the `(element)` node.
+
+`rainbow.include-children` is not necessary for the vast majority of programming
+languages. It is only necessary when the node that increments the nesting level
+(changes rainbow color) is not the direct parent of the bracket node.
+
+[syntax highlighting queries]: https://tree-sitter.github.io/tree-sitter/syntax-highlighting#highlights
+[query syntax]: https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries
+[tsq grammar.js]: https://github.com/the-mikedavis/tree-sitter-tsq/blob/48b5e9f82ae0a4727201626f33a17f69f8e0ff86/grammar.js
diff --git a/book/src/languages.md b/book/src/languages.md
index 778489f8..a8ac7dda 100644
--- a/book/src/languages.md
+++ b/book/src/languages.md
@@ -68,6 +68,8 @@ These configuration keys are available:
| `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 |
| `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` |
| `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. |
+| `rulers` | Overrides the `editor.rulers` config key for the language. |
+| `rainbow-brackets` | Overrides the `editor.rainbow-brackets` config key for the language. |
### File-type detection and the `file-types` key
diff --git a/book/src/themes.md b/book/src/themes.md
index 66121076..2d347176 100644
--- a/book/src/themes.md
+++ b/book/src/themes.md
@@ -137,6 +137,17 @@ inherits = "boo_berry"
berry = "#2A2A4D"
```
+### Rainbow
+
+The `rainbow` key is used for rainbow highlight for matching brackets.
+The key is a list of styles.
+
+```toml
+rainbow = ["#ff0000", "#ffa500", "#fff000", { fg = "#00ff00", modifiers = ["bold"] }]
+```
+
+Colors from the palette and modifiers may be used.
+
### Scopes
The following is a list of scopes available to use for styling: