2021-06-19 13:19:31 +02:00
# Themes
2022-01-07 19:14:31 +01:00
To use a theme add `theme = "<name>"` to your [`config.toml` ](./configuration.md ) at the very top of the file before the first section or select it during runtime using `:theme <name>` .
2021-06-19 13:19:31 +02:00
2022-01-07 19:14:31 +01:00
## Creating a theme
2021-06-19 13:19:31 +02:00
2022-01-07 19:14:31 +01:00
Create a file with the name of your theme as file name (i.e `mytheme.toml` ) and place it in your `themes` directory (i.e `~/.config/helix/themes` ). The directory might have to be created beforehand.
2021-06-19 13:19:31 +02:00
2022-01-07 19:14:31 +01:00
The names "default" and "base16_default" are reserved for the builtin themes and cannot be overridden by user defined themes.
2021-06-19 13:19:31 +02:00
2022-01-07 19:14:31 +01:00
The default theme.toml can be found [here ](https://github.com/helix-editor/helix/blob/master/theme.toml ), and user submitted themes [here ](https://github.com/helix-editor/helix/blob/master/runtime/themes ).
2021-06-19 13:19:31 +02:00
Each line in the theme file is specified as below:
```toml
key = { fg = "#ffffff ", bg = "#000000 ", modifiers = ["bold", "italic"] }
```
where `key` represents what you want to style, `fg` specifies the foreground color, `bg` the background color, and `modifiers` is a list of style modifiers. `bg` and `modifiers` can be omitted to defer to the defaults.
To specify only the foreground color:
```toml
key = "#ffffff "
```
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 ).
```toml
"key.key" = "#ffffff "
```
2021-09-07 13:00:52 +09:00
### Color palettes
2021-06-19 13:19:31 +02:00
2021-09-07 13:00:52 +09:00
It's recommended define a palette of named colors, and refer to them from the
2021-06-30 16:24:30 +02:00
configuration values in your theme. To do this, add a table called
`palette` to your theme file:
```toml
2022-04-08 15:21:52 -07:00
"ui.background" = "white"
"ui.text" = "black"
2021-06-30 16:24:30 +02:00
[palette]
white = "#ffffff "
black = "#000000 "
```
Remember that the `[palette]` table includes all keys after its header,
so you should define the palette after normal theme options.
2021-09-02 22:05:33 +05:30
2021-09-03 16:42:29 +05:30
The default palette uses the terminal's default 16 colors, and the colors names
are listed below. The `[palette]` section in the config file takes precedence
over it and is merged into the default palette.
2021-09-02 22:05:33 +05:30
| Color Name |
| --- |
| `black` |
| `red` |
| `green` |
| `yellow` |
| `blue` |
| `magenta` |
| `cyan` |
| `gray` |
| `light-red` |
| `light-green` |
| `light-yellow` |
| `light-blue` |
| `light-magenta` |
| `light-cyan` |
| `light-gray` |
| `white` |
2021-09-07 13:00:52 +09:00
### Modifiers
The following values may be used as modifiers.
Less common modifiers might not be supported by your terminal emulator.
| Modifier |
| --- |
| `bold` |
| `dim` |
| `italic` |
| `underlined` |
| `slow_blink` |
| `rapid_blink` |
| `reversed` |
| `hidden` |
| `crossed_out` |
### Scopes
The following is a list of scopes available to use for styling.
#### Syntax highlighting
These keys match [tree-sitter scopes ](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#theme ).
For a given highlight produced, styling will be determined based on the longest matching theme key. For example, the highlight `function.builtin.static` would match the key `function.builtin` rather than `function` .
We use a similar set of scopes as
[SublimeText ](https://www.sublimetext.com/docs/scope_naming.html ). See also
[TextMate ](https://macromates.com/manual/en/language_grammars ) scopes.
- `type` - Types
- `builtin` - Primitive types provided by the language (`int` , `usize` )
2021-12-19 00:05:43 +05:30
- `constructor`
2021-09-07 13:00:52 +09:00
- `constant` (TODO: constant.other.placeholder for %v)
- `builtin` Special constants provided by the language (`true` , `false` , `nil` etc)
- `boolean`
- `character`
2021-11-02 23:00:52 -04:00
- `escape`
- `numeric` (numbers)
- `integer`
- `float`
2021-09-07 13:00:52 +09:00
- `string` (TODO: string.quoted.{single, double}, string.raw/.unquoted)?
- `regexp` - Regular expressions
- `special`
- `path`
- `url`
2021-10-14 13:58:08 -05:00
- `symbol` - Erlang/Elixir atoms, Ruby symbols, Clojure keywords
2021-10-14 13:45:32 -05:00
2021-09-07 13:00:52 +09:00
- `comment` - Code comments
- `line` - Single line comments (`//` )
- `block` - Block comments (e.g. (`/* */` )
- `documentation` - Documentation comments (e.g. `///` in Rust)
- `variable` - Variables
- `builtin` - Reserved language variables (`self` , `this` , `super` , etc)
- `parameter` - Function parameters
2021-11-02 23:00:52 -04:00
- `other`
- `member` - Fields of composite data types (e.g. structs, unions)
2021-09-07 13:00:52 +09:00
- `function` (TODO: ?)
- `label`
- `punctuation`
- `delimiter` - Commas, colons
- `bracket` - Parentheses, angle brackets, etc.
- `keyword`
- `control`
- `conditional` - `if` , `else`
- `repeat` - `for` , `while` , `loop`
- `import` - `import` , `export`
2021-11-28 20:38:17 -05:00
- `return`
2022-01-03 20:31:17 -06:00
- `exception`
2021-11-28 20:38:17 -05:00
- `operator` - `or` , `in`
2021-09-07 13:00:52 +09:00
- `directive` - Preprocessor directives (`#if` in C)
- `function` - `fn` , `func`
2021-11-28 20:38:17 -05:00
- `operator` - `||` , `+=` , `>`
2021-09-07 13:00:52 +09:00
- `function`
- `builtin`
- `method`
- `macro`
- `special` (preprocesor in C)
- `tag` - Tags (e.g. `<body>` in HTML)
- `namespace`
2021-12-15 17:46:40 +09:00
- `markup`
- `heading`
2022-02-21 08:45:48 +01:00
- `marker`
- `1` , `2` , `3` , `4` , `5` , `6` - heading text for h1 through h6
2021-12-15 17:46:40 +09:00
- `list`
- `unnumbered`
- `numbered`
- `bold`
- `italic`
2021-12-19 00:05:43 +05:30
- `link`
2022-01-08 09:27:50 -06:00
- `url` - urls pointed to by links
- `label` - non-url link references
- `text` - url and image descriptions in links
2021-12-15 17:46:40 +09:00
- `quote`
- `raw`
- `inline`
- `block`
2021-12-22 09:58:51 -06:00
- `diff` - version control changes
- `plus` - additions
- `minus` - deletions
- `delta` - modifications
- `moved` - renamed or moved files/changes
2021-09-07 13:00:52 +09:00
#### Interface
These scopes are used for theming the editor interface.
2022-01-24 09:41:25 +08:00
- `markup`
- `normal`
- `completion` - for completion doc popup ui
- `hover` - for hover popup ui
- `heading`
- `completion` - for completion doc popup ui
- `hover` - for hover popup ui
- `raw`
- `inline`
- `completion` - for completion doc popup ui
- `hover` - for hover popup ui
2021-09-07 13:00:52 +09:00
2022-04-15 01:58:16 +01:00
| Key | Notes |
| --- | --- |
| `ui.background` | |
| `ui.cursor` | |
| `ui.cursor.insert` | |
| `ui.cursor.select` | |
| `ui.cursor.match` | Matching bracket etc. |
| `ui.cursor.primary` | Cursor with primary selection |
| `ui.linenr` | Line numbers |
| `ui.linenr.selected` | Line number for the line the cursor is on |
| `ui.statusline` | Statusline |
| `ui.statusline.inactive` | Statusline (unfocused document) |
| `ui.popup` | Documentation popups (e.g space-k) |
| `ui.popup.info` | Prompt for multiple key options |
| `ui.window` | Border lines separating splits |
| `ui.help` | Description box for commands |
| `ui.text` | Command prompts, popup text, etc. |
| `ui.text.focus` | |
| `ui.text.info` | The key: command text in `ui.popup.info` boxes |
2022-04-20 13:04:17 -05:00
| `ui.virtual.ruler` | Ruler columns (see the [`editor.rulers` config][rulers-config])|
2021-12-01 17:59:23 -05:00
| `ui.virtual.whitespace` | Visible white-space characters |
2022-04-15 01:58:16 +01:00
| `ui.menu` | Code and command completion menus |
| `ui.menu.selected` | Selected autocomplete item |
| `ui.selection` | For selections in the editing area |
| `ui.selection.primary` | |
| `warning` | Diagnostics warning (gutter) |
| `error` | Diagnostics error (gutter) |
| `info` | Diagnostics info (gutter) |
| `hint` | Diagnostics hint (gutter) |
| `diagnostic` | For text in editing area |
2022-04-20 13:04:17 -05:00
[rulers-config]: ./configuration.md#editor -section