Skip to content

Commit

Permalink
Add a "yes-color" configuration option to allow overriding NO_COLOR
Browse files Browse the repository at this point in the history
environment variable, which crossterm honors by default.

As noted in https://no-color.org/, "User-level configuration files
and per-instance command-line arguments should override $NO_COLOR".
  • Loading branch information
kevin-vigor committed Apr 19, 2024
1 parent 94405f3 commit 7c3b0c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Its settings will be merged with the configuration directory `config.toml` and t
| `completion-replace` | Set to `true` to make completions always replace the entire word and not just the part before the cursor | `false` |
| `auto-info` | Whether to display info boxes | `true` |
| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative | `false` |
| `yes-color` | Force override of NO_COLOR environment variable (see https://no-color.org/) | `false` |
| `undercurl` | Set to `true` to override automatic detection of terminal undercurl support in the event of a false negative | `false` |
| `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` |
Expand Down
3 changes: 3 additions & 0 deletions helix-tui/src/backend/crossterm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ where
W: Write,
{
pub fn new(buffer: W, config: &EditorConfig) -> CrosstermBackend<W> {
if config.yes_color {
crossterm::style::force_color_output(true);
}
CrosstermBackend {
buffer,
capabilities: Capabilities::from_env_or_default(config),
Expand Down
3 changes: 3 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ pub struct Config {
pub true_color: bool,
/// Set to `true` to override automatic detection of terminal undercurl support in the event of a false negative. Defaults to `false`.
pub undercurl: bool,
/// Force override of NO_COLOR environment variable (see https://no-color.org/)
pub yes_color: bool,
/// Search configuration.
#[serde(default)]
pub search: SearchConfig,
Expand Down Expand Up @@ -892,6 +894,7 @@ impl Default for Config {
cursor_shape: CursorShapeConfig::default(),
true_color: false,
undercurl: false,
yes_color: false,
search: SearchConfig::default(),
lsp: LspConfig::default(),
terminal: get_terminal_provider(),
Expand Down

0 comments on commit 7c3b0c3

Please sign in to comment.