| 1 | ## Themes |
| 2 | |
| 3 | To use a theme add `theme = "<name>"` to the top of your [`config.toml`](./configuration.md) file, or select it during runtime using `:theme <name>`. |
| 4 | |
| 5 | Separate themes can be configured for light and dark modes. On terminals supporting [mode 2031 dark/light detection](https://github.com/contour-terminal/contour/blob/master/docs/vt-extensions/color-palette-update-notifications.md), the theme mode is detected from the terminal. |
| 6 | |
| 7 | ```toml |
| 8 | [theme] |
| 9 | dark = "catppuccin_frappe" |
| 10 | light = "catppuccin_latte" |
| 11 | ## Optional. Used if the terminal doesn't declare a preference. |
| 12 | ## Defaults to the theme set for `dark` if not specified. |
| 13 | # fallback = "catppuccin_frappe" |
| 14 | ``` |
| 15 | |
| 16 | ## Creating a theme |
| 17 | |
| 18 | Create a file with the name of your theme as the file name (i.e `mytheme.toml`) and place it in your `themes` directory (i.e `~/.config/helix/themes` or `%AppData%\helix\themes` on Windows). The directory might have to be created beforehand. |
| 19 | |
| 20 | > 💡 The names "default" and "base16_default" are reserved for built-in themes |
| 21 | > and cannot be overridden by user-defined themes. |
| 22 | |
| 23 | ### Overview |
| 24 | |
| 25 | Each line in the theme file is specified as below: |
| 26 | |
| 27 | ```toml |
| 28 | key = { fg = "#ffffff", bg = "#000000", underline = { color = "#ff0000", style = "curl"}, modifiers = ["bold", "italic"] } |
| 29 | ``` |
| 30 | |
| 31 | Where `key` represents what you want to style, `fg` specifies the foreground color, `bg` the background color, `underline` the underline `style`/`color`, and `modifiers` is a list of style modifiers. `bg`, `underline` and `modifiers` can be omitted to defer to the defaults. |
| 32 | |
| 33 | To specify only the foreground color: |
| 34 | |
| 35 | ```toml |
| 36 | # Valid hex-color format is `#RGB` or `#RRGGBB` |
| 37 | # (each letter is a nibble) |
| 38 | key = "#ffffff" |
| 39 | ``` |
| 40 | |
| 41 | If the key contains a dot `'.'`, it must be quoted to prevent it being parsed as a [dotted key](https://toml.io/en/v1.0.0#keys). |
| 42 | |
| 43 | ```toml |
| 44 | "key.key" = "#fff" |
| 45 | ``` |
| 46 | |
| 47 | Color values must be either a [CSS hex RGB string](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/hex-color) or a name declared in the [`palette`](#color-palettes). |
| 48 | |
| 49 | > 💡 Note that Helix doesn't support transparency (alpha channel). |
| 50 | |
| 51 | For inspiration, you can find the default `theme.toml` |
| 52 | [here](https://github.com/helix-editor/helix/blob/master/theme.toml) and |
| 53 | user-submitted themes |
| 54 | [here](https://github.com/helix-editor/helix/blob/master/runtime/themes). |
| 55 | |
| 56 | |
| 57 | ## The details of theme creation |
| 58 | |
| 59 | ### Color palettes |
| 60 | |
| 61 | It's recommended to define a palette of named colors, and refer to them in the |
| 62 | configuration values in your theme. To do this, add a table called |
| 63 | `palette` to your theme file: |
| 64 | |
| 65 | ```toml |
| 66 | "ui.background" = "white" |
| 67 | "ui.text" = "black" |
| 68 | |
| 69 | [palette] |
| 70 | white = "#ffffff" |
| 71 | black = "#000000" |
| 72 | ``` |
| 73 | |
| 74 | Keep in mind that the `[palette]` table includes all keys after its header, |
| 75 | so it should be defined after the normal theme options. |
| 76 | |
| 77 | The default palette uses the terminal's default 16 colors, and the colors names |
| 78 | are listed below. The `[palette]` section in the config file takes precedence |
| 79 | over it and is merged into the default palette. |
| 80 | |
| 81 | | Color Name | |
| 82 | | --- | |
| 83 | | `default` | |
| 84 | | `black` | |
| 85 | | `red` | |
| 86 | | `green` | |
| 87 | | `yellow` | |
| 88 | | `blue` | |
| 89 | | `magenta` | |
| 90 | | `cyan` | |
| 91 | | `gray` | |
| 92 | | `light-red` | |
| 93 | | `light-green` | |
| 94 | | `light-yellow` | |
| 95 | | `light-blue` | |
| 96 | | `light-magenta` | |
| 97 | | `light-cyan` | |
| 98 | | `light-gray` | |
| 99 | | `white` | |
| 100 | |
| 101 | ### Modifiers |
| 102 | |
| 103 | The following values may be used as modifier, provided they are supported by |
| 104 | your terminal emulator. |
| 105 | |
| 106 | | Modifier | |
| 107 | | --- | |
| 108 | | `bold` | |
| 109 | | `dim` | |
| 110 | | `italic` | |
| 111 | | `underlined` | |
| 112 | | `slow_blink` | |
| 113 | | `rapid_blink` | |
| 114 | | `reversed` | |
| 115 | | `hidden` | |
| 116 | | `crossed_out` | |
| 117 | |
| 118 | > 💡 The `underlined` modifier is deprecated and only available for backwards compatibility. |
| 119 | > Its behavior is equivalent to setting `underline.style="line"`. |
| 120 | |
| 121 | ### Underline style |
| 122 | |
| 123 | One of the following values may be used as a value for `underline.style`, providing it is |
| 124 | supported by your terminal emulator. |
| 125 | |
| 126 | | Modifier | |
| 127 | | --- | |
| 128 | | `line` | |
| 129 | | `curl` | |
| 130 | | `dashed` | |
| 131 | | `dotted` | |
| 132 | | `double_line` | |
| 133 | |
| 134 | |
| 135 | ### Inheritance |
| 136 | |
| 137 | Extend other themes by setting the `inherits` property to an existing theme. |
| 138 | |
| 139 | ```toml |
| 140 | inherits = "boo_berry" |
| 141 | |
| 142 | # Override the theming for "keyword"s: |
| 143 | "keyword" = { fg = "gold" } |
| 144 | |
| 145 | # Override colors in the palette: |
| 146 | [palette] |
| 147 | berry = "#2A2A4D" |
| 148 | ``` |
| 149 | |
| 150 | ### Rainbow |
| 151 | |
| 152 | The `rainbow` key is used for rainbow highlight for matching brackets. |
| 153 | The key is a list of styles. |
| 154 | |
| 155 | ```toml |
| 156 | rainbow = ["#ff0000", "#ffa500", "#fff000", { fg = "#00ff00", modifiers = ["bold"] }] |
| 157 | ``` |
| 158 | |
| 159 | Colors from the palette and modifiers may be used. |
| 160 | |
| 161 | ### Scopes |
| 162 | |
| 163 | The following is a list of scopes available to use for styling: |
| 164 | |
| 165 | #### Syntax highlighting |
| 166 | |
| 167 | These keys match [tree-sitter scopes](https://tree-sitter.github.io/tree-sitter/3-syntax-highlighting.html#highlights). |
| 168 | |
| 169 | When determining styling for a highlight, the longest matching theme key will be used. For example, if the highlight is `function.builtin.static`, the key `function.builtin` will be used instead of `function`. |
| 170 | |
| 171 | This list is also the reference for the capture names used in `highlights.scm` queries (`@function`, `@type`, …) — see [Adding languages](./guides/adding_languages.md). When several captures cover the same text the **last** matching pattern in the file wins; when they sit on nested nodes the **innermost** node wins regardless of order, so capture the leaf you mean (put `@function` on the called identifier, not a node wrapping it). A method call is `@function.method`; a field access with no call is `@variable.other.member`. |
| 172 | |
| 173 | We use a similar set of scopes as |
| 174 | [Sublime Text](https://www.sublimetext.com/docs/scope_naming.html). See also |
| 175 | [TextMate](https://macromates.com/manual/en/language_grammars) scopes. |
| 176 | |
| 177 | - `attribute` - Class attributes, HTML tag attributes |
| 178 | |
| 179 | - `type` - Types |
| 180 | - `builtin` - Primitive types provided by the language (`int`, `usize`) |
| 181 | - `parameter` - Generic type parameters (`T`) |
| 182 | - `enum` |
| 183 | - `variant` - Enum variants |
| 184 | - `constructor` - Constructors, struct/record literals, type names in value position |
| 185 | |
| 186 | - `constant` (TODO: constant.other.placeholder for `%v`) |
| 187 | - `builtin` Special constants provided by the language (`true`, `false`, `nil` etc) |
| 188 | - `boolean` |
| 189 | - `character` |
| 190 | - `escape` |
| 191 | - `numeric` (numbers) |
| 192 | - `integer` |
| 193 | - `float` |
| 194 | |
| 195 | - `string` (TODO: string.quoted.{single, double}, string.raw/.unquoted)? |
| 196 | - `regexp` - Regular expressions |
| 197 | - `special` |
| 198 | - `path` |
| 199 | - `url` |
| 200 | - `symbol` - Erlang/Elixir atoms, Ruby symbols, Clojure keywords |
| 201 | |
| 202 | - `comment` - Code comments |
| 203 | - `line` - Single line comments (`//`) |
| 204 | - `documentation` - Line documentation comments (e.g. `///` in Rust) |
| 205 | - `block` - Block comments (e.g. (`/* */`) |
| 206 | - `documentation` - Block documentation comments (e.g. `/** */` in Rust) |
| 207 | - `unused` - Unused variables and patterns, e.g. `_` and `_foo` |
| 208 | |
| 209 | - `variable` - Variables |
| 210 | - `mutable` - Mutable variables (e.g. marked with `mut` in Rust) |
| 211 | - `builtin` - Reserved language variables (`self`, `this`, `super`, etc.) |
| 212 | - `mutable` - Mutable language variables (e.g. `mut self` in Rust) |
| 213 | - `parameter` - Function parameters |
| 214 | - `mutable` - Mutable function parameters (e.g. marked with `mut` in Rust) |
| 215 | - `other` |
| 216 | - `member` - Fields of composite data types (e.g. structs, unions) |
| 217 | - `private` - Private fields that use a unique syntax (currently just ECMAScript-based languages) |
| 218 | |
| 219 | - `label` - `.class`, `#id` in CSS, etc. |
| 220 | |
| 221 | - `punctuation` |
| 222 | - `delimiter` - Commas, colons |
| 223 | - `bracket` - Parentheses, angle brackets, etc. |
| 224 | - `special` - String interpolation brackets. |
| 225 | |
| 226 | - `keyword` |
| 227 | - `control` |
| 228 | - `conditional` - `if`, `else` |
| 229 | - `repeat` - `for`, `while`, `loop` |
| 230 | - `import` - `import`, `export` |
| 231 | - `return` |
| 232 | - `exception` |
| 233 | - `operator` - `or`, `in` |
| 234 | - `directive` - Preprocessor directives (`#if` in C) |
| 235 | - `function` - `fn`, `func` |
| 236 | - `storage` - Keywords describing how things are stored |
| 237 | - `type` - The type of something, `class`, `function`, `var`, `let`, etc. |
| 238 | - `modifier` - Storage modifiers like `static`, `mut`, `const`, `ref`, etc. |
| 239 | |
| 240 | - `operator` - `||`, `+=`, `>` |
| 241 | |
| 242 | - `function` - Function definitions and calls |
| 243 | - `builtin` - Language built-in functions |
| 244 | - `method` - Method definitions and calls (`obj.method()`) |
| 245 | - `private` - Private methods that use a unique syntax (currently just ECMAScript-based languages) |
| 246 | - `macro` - Macro invocations (e.g. `println!` in Rust) |
| 247 | - `special` (preprocessor in C) |
| 248 | |
| 249 | - `tag` - Tags (e.g. `<body>` in HTML) |
| 250 | - `builtin` |
| 251 | |
| 252 | - `namespace` - Modules and namespaces (e.g. `std::collections`, package names) |
| 253 | |
| 254 | - `special` - `derive` in Rust, bolded query-match in pickers (includes file explorer), etc. |
| 255 | See also [#2380] |
| 256 | |
| 257 | - `markup` |
| 258 | - `heading` |
| 259 | - `marker` |
| 260 | - `1`, `2`, `3`, `4`, `5`, `6` - heading text for h1 through h6 |
| 261 | - `list` |
| 262 | - `unnumbered` |
| 263 | - `numbered` |
| 264 | - `checked` |
| 265 | - `unchecked` |
| 266 | - `bold` |
| 267 | - `italic` |
| 268 | - `strikethrough` |
| 269 | - `link` |
| 270 | - `url` - URLs pointed to by links |
| 271 | - `label` - non-URL link references |
| 272 | - `text` - URL and image descriptions in links |
| 273 | - `quote` |
| 274 | - `raw` |
| 275 | - `inline` |
| 276 | - `block` |
| 277 | |
| 278 | - `diff` - version control changes |
| 279 | - `plus` - additions |
| 280 | - `gutter` - gutter indicator |
| 281 | - `minus` - deletions |
| 282 | - `gutter` - gutter indicator |
| 283 | - `delta` - modifications |
| 284 | - `moved` - renamed or moved files/changes |
| 285 | - `conflict` - merge conflicts |
| 286 | - `gutter` - gutter indicator |
| 287 | |
| 288 | - `embedded` - Interpolated expressions embedded in a string template (`${…}`) |
| 289 | |
| 290 | #### Interface |
| 291 | |
| 292 | These scopes are used for theming the editor interface: |
| 293 | |
| 294 | - `markup` |
| 295 | - `normal` |
| 296 | - `completion` - for completion doc popup UI |
| 297 | - `hover` - for hover popup UI |
| 298 | - `heading` |
| 299 | - `completion` - for completion doc popup UI |
| 300 | - `hover` - for hover popup UI |
| 301 | - `raw` |
| 302 | - `inline` |
| 303 | - `completion` - for completion doc popup UI |
| 304 | - `hover` - for hover popup UI |
| 305 | |
| 306 | |
| 307 | | Key | Notes | |
| 308 | | --- | --- | |
| 309 | | `ui.background` | | |
| 310 | | `ui.background.separator` | Picker separator below input line | |
| 311 | | `ui.cursor` | | |
| 312 | | `ui.cursor.normal` | | |
| 313 | | `ui.cursor.insert` | | |
| 314 | | `ui.cursor.select` | | |
| 315 | | `ui.cursor.match` | Matching bracket etc. | |
| 316 | | `ui.cursor.primary` | Cursor with primary selection | |
| 317 | | `ui.cursor.primary.normal` | | |
| 318 | | `ui.cursor.primary.insert` | | |
| 319 | | `ui.cursor.primary.select` | | |
| 320 | | `ui.debug.breakpoint` | Breakpoint indicator, found in the gutter | |
| 321 | | `ui.debug.active` | Indicator for the line at which debugging execution is paused at, found in the gutter | |
| 322 | | `ui.gutter` | Gutter | |
| 323 | | `ui.gutter.selected` | Gutter for the line the cursor is on | |
| 324 | | `ui.linenr` | Line numbers | |
| 325 | | `ui.linenr.selected` | Line number for the line the cursor is on | |
| 326 | | `ui.statusline` | Statusline | |
| 327 | | `ui.statusline.inactive` | Statusline (unfocused document) | |
| 328 | | `ui.statusline.normal` | Statusline mode during normal mode ([only if `editor.color-modes` is enabled][editor-section]) | |
| 329 | | `ui.statusline.insert` | Statusline mode during insert mode ([only if `editor.color-modes` is enabled][editor-section]) | |
| 330 | | `ui.statusline.select` | Statusline mode during select mode ([only if `editor.color-modes` is enabled][editor-section]) | |
| 331 | | `ui.statusline.separator` | Separator character in statusline | |
| 332 | | `ui.bufferline` | Style for the buffer line | |
| 333 | | `ui.bufferline.active` | Style for the active buffer in buffer line | |
| 334 | | `ui.bufferline.background` | Style for bufferline background | |
| 335 | | `ui.popup` | Documentation popups (e.g. Space + k) | |
| 336 | | `ui.popup.info` | Prompt for multiple key options | |
| 337 | | `ui.picker.header` | Header row area in pickers with multiple columns | |
| 338 | | `ui.picker.header.column` | Column names in pickers with multiple columns | |
| 339 | | `ui.picker.header.column.active` | The column name in pickers with multiple columns where the cursor is entering into. | |
| 340 | | `ui.window` | Borderlines separating splits | |
| 341 | | `ui.help` | Description box for commands | |
| 342 | | `ui.text` | Default text style, command prompts, popup text, etc. | |
| 343 | | `ui.text.focus` | The currently selected line in the picker | |
| 344 | | `ui.text.inactive` | Same as `ui.text` but when the text is inactive (e.g. suggestions) | |
| 345 | | `ui.text.info` | The key: command text in `ui.popup.info` boxes | |
| 346 | | `ui.text.directory` | Directory names in prompt completion | |
| 347 | | `ui.text.symlink` | Symlink names in prompt completion | |
| 348 | | `ui.virtual.ruler` | Ruler columns (see the [`editor.rulers` config][editor-section]) | |
| 349 | | `ui.virtual.whitespace` | Visible whitespace characters | |
| 350 | | `ui.virtual.indent-guide` | Vertical indent width guides | |
| 351 | | `ui.virtual.inlay-hint` | Default style for inlay hints of all kinds | |
| 352 | | `ui.virtual.inlay-hint.parameter` | Style for inlay hints of kind `parameter` (language servers are not required to set a kind) | |
| 353 | | `ui.virtual.inlay-hint.type` | Style for inlay hints of kind `type` (language servers are not required to set a kind) | |
| 354 | | `ui.virtual.wrap` | Soft-wrap indicator (see the [`editor.soft-wrap` config][editor-section]) | |
| 355 | | `ui.virtual.jump-label` | Style for virtual jump labels | |
| 356 | | `ui.menu` | Code and command completion menus | |
| 357 | | `ui.menu.selected` | Selected autocomplete item | |
| 358 | | `ui.menu.scroll` | `fg` sets thumb color, `bg` sets track color of scrollbar | |
| 359 | | `ui.selection` | For selections in the editing area | |
| 360 | | `ui.selection.primary` | | |
| 361 | | `ui.highlight` | Highlighted lines in the picker preview | |
| 362 | | `ui.highlight.frameline` | Line at which debugging execution is paused at | |
| 363 | | `ui.cursorline.primary` | The line of the primary cursor ([if cursorline is enabled][editor-section]) | |
| 364 | | `ui.cursorline.secondary` | The lines of any other cursors ([if cursorline is enabled][editor-section]) | |
| 365 | | `ui.cursorcolumn.primary` | The column of the primary cursor ([if cursorcolumn is enabled][editor-section]) | |
| 366 | | `ui.cursorcolumn.secondary` | The columns of any other cursors ([if cursorcolumn is enabled][editor-section]) | |
| 367 | | `warning` | Diagnostics warning (gutter) | |
| 368 | | `warning.diagnostic.inline` | The inline diagnostic for the warning severity | |
| 369 | | `error` | Diagnostics error (gutter) | |
| 370 | | `error.diagnostic.inline` | The inline diagnostic for the error severity | |
| 371 | | `info` | Diagnostics info (gutter) | |
| 372 | | `info.diagnostic.inline` | The inline diagnostic for the warning severity | |
| 373 | | `hint` | Diagnostics hint (gutter) | |
| 374 | | `hint.diagnostic.inline` | The inline diagnostic for the hint severity | |
| 375 | | `diagnostic` | Diagnostics fallback style (editing area) | |
| 376 | | `diagnostic.hint` | Diagnostics hint (editing area) | |
| 377 | | `diagnostic.info` | Diagnostics info (editing area) | |
| 378 | | `diagnostic.warning` | Diagnostics warning (editing area) | |
| 379 | | `diagnostic.error` | Diagnostics error (editing area) | |
| 380 | | `diagnostic.unnecessary` | Diagnostics with unnecessary tag (editing area) | |
| 381 | | `diagnostic.deprecated` | Diagnostics with deprecated tag (editing area) | |
| 382 | | `tabstop` | Snippet placeholder | |
| 383 | |
| 384 | [editor-section]: ./configuration.md#editor-section |
| 385 | [#2380]: https://github.com/helix-editor/helix/issues/2380 |