From 9e88e2ced5b7db5bcd92973bb11e009764d57cb4 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Mon, 11 Jul 2022 19:10:36 -0500 Subject: [PATCH] Add rainbow_brackets configuration option This option is similar to the `rulers` config: it can be set no the editor key in config and also overridden for specific languages, so you could enable rainbow brackets for lisps for example without enabling it globally. --- book/src/editor.md | 1 + book/src/languages.md | 2 ++ helix-core/src/syntax.rs | 3 +++ helix-view/src/editor.rs | 3 +++ 4 files changed, 9 insertions(+) diff --git a/book/src/editor.md b/book/src/editor.md index 82d5f8461..45abc7d53 100644 --- a/book/src/editor.md +++ b/book/src/editor.md @@ -44,6 +44,7 @@ | `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file | `[]` | | `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` | | `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` | +| `rainbow-brackets` | Whether to render rainbow colors for matching brackets. Requires tree-sitter `rainbows.scm` queries for the language. | `false` | | `text-width` | Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap-at-text-width` is set | `80` | | `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` | diff --git a/book/src/languages.md b/book/src/languages.md index fe105cced..0ba3de71b 100644 --- a/book/src/languages.md +++ b/book/src/languages.md @@ -71,6 +71,8 @@ These configuration keys are available: | `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. | | `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. +| `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/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 7de6ddf44..c935db05e 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -169,6 +169,9 @@ pub struct LanguageConfiguration { pub workspace_lsp_roots: Option>, #[serde(default)] pub persistent_diagnostic_sources: Vec, + + /// If set, overrides rainbow brackets for a language. + pub rainbow_brackets: Option, } #[derive(Debug, PartialEq, Eq, Hash)] diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 26dea3a21..0950e8db9 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -316,6 +316,8 @@ pub struct Config { pub rulers: Vec, #[serde(default)] pub whitespace: WhitespaceConfig, + /// Whether to render rainbow highlights. Defaults to `false`. + pub rainbow_brackets: bool, /// Persistently display open buffers along the top pub bufferline: BufferLine, /// Vertical indent width guides. @@ -964,6 +966,7 @@ impl Default for Config { terminal: get_terminal_provider(), rulers: Vec::new(), whitespace: WhitespaceConfig::default(), + rainbow_brackets: false, bufferline: BufferLine::default(), indent_guides: IndentGuidesConfig::default(), color_modes: false,