Debian Codegraph @

book/src/themes.md

raw symbols SCIP
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 - `public` - Public function definitions
244 - `builtin` - Language built-in functions
245 - `method` - Method definitions and calls (`obj.method()`)
246 - `public` - Public method definitions
247 - `private` - Private methods that use a unique syntax (currently just ECMAScript-based languages)
248 - `macro` - Macro invocations (e.g. `println!` in Rust)
249 - `special` (preprocessor in C)
250
251 - `tag` - Tags (e.g. `<body>` in HTML)
252 - `builtin`
253
254 - `namespace` - Modules and namespaces (e.g. `std::collections`, package names)
255
256 - `special` - `derive` in Rust, bolded query-match in pickers (includes file explorer), etc.
257 See also [#2380]
258
259 - `markup`
260 - `heading`
261 - `marker`
262 - `1`, `2`, `3`, `4`, `5`, `6` - heading text for h1 through h6
263 - `list`
264 - `unnumbered`
265 - `numbered`
266 - `checked`
267 - `unchecked`
268 - `bold`
269 - `italic`
270 - `strikethrough`
271 - `link`
272 - `url` - URLs pointed to by links
273 - `label` - non-URL link references
274 - `text` - URL and image descriptions in links
275 - `quote`
276 - `raw`
277 - `inline`
278 - `block`
279
280 - `diff` - version control changes
281 - `plus` - additions
282 - `gutter` - gutter indicator
283 - `minus` - deletions
284 - `gutter` - gutter indicator
285 - `delta` - modifications
286 - `moved` - renamed or moved files/changes
287 - `conflict` - merge conflicts
288 - `gutter` - gutter indicator
289
290 - `embedded` - Interpolated expressions embedded in a string template (`${…}`)
291
292 #### Interface
293
294 These scopes are used for theming the editor interface:
295
296 - `markup`
297 - `normal`
298 - `completion` - for completion doc popup UI
299 - `hover` - for hover popup UI
300 - `heading`
301 - `completion` - for completion doc popup UI
302 - `hover` - for hover popup UI
303 - `raw`
304 - `inline`
305 - `completion` - for completion doc popup UI
306 - `hover` - for hover popup UI
307
308
309 | Key | Notes |
310 | --- | --- |
311 | `ui.background` | |
312 | `ui.background.separator` | Picker separator below input line |
313 | `ui.cursor` | |
314 | `ui.cursor.normal` | |
315 | `ui.cursor.insert` | |
316 | `ui.cursor.select` | |
317 | `ui.cursor.match` | Matching bracket etc. |
318 | `ui.cursor.primary` | Cursor with primary selection |
319 | `ui.cursor.primary.normal` | |
320 | `ui.cursor.primary.insert` | |
321 | `ui.cursor.primary.select` | |
322 | `ui.debug.breakpoint` | Breakpoint indicator, found in the gutter |
323 | `ui.debug.active` | Indicator for the line at which debugging execution is paused at, found in the gutter |
324 | `ui.gutter` | Gutter |
325 | `ui.gutter.selected` | Gutter for the line the cursor is on |
326 | `ui.linenr` | Line numbers |
327 | `ui.linenr.selected` | Line number for the line the cursor is on |
328 | `ui.statusline` | Statusline |
329 | `ui.statusline.inactive` | Statusline (unfocused document) |
330 | `ui.statusline.normal` | Statusline mode during normal mode ([only if `editor.color-modes` is enabled][editor-section]) |
331 | `ui.statusline.insert` | Statusline mode during insert mode ([only if `editor.color-modes` is enabled][editor-section]) |
332 | `ui.statusline.select` | Statusline mode during select mode ([only if `editor.color-modes` is enabled][editor-section]) |
333 | `ui.statusline.separator` | Separator character in statusline |
334 | `ui.bufferline` | Style for the buffer line |
335 | `ui.bufferline.active` | Style for the active buffer in buffer line |
336 | `ui.bufferline.background` | Style for bufferline background |
337 | `ui.popup` | Documentation popups (e.g. Space + k) |
338 | `ui.popup.info` | Prompt for multiple key options |
339 | `ui.picker.header` | Header row area in pickers with multiple columns |
340 | `ui.picker.header.column` | Column names in pickers with multiple columns |
341 | `ui.picker.header.column.active` | The column name in pickers with multiple columns where the cursor is entering into. |
342 | `ui.window` | Borderlines separating splits |
343 | `ui.help` | Description box for commands |
344 | `ui.text` | Default text style, command prompts, popup text, etc. |
345 | `ui.text.focus` | The currently selected line in the picker |
346 | `ui.text.inactive` | Same as `ui.text` but when the text is inactive (e.g. suggestions) |
347 | `ui.text.info` | The key: command text in `ui.popup.info` boxes |
348 | `ui.text.directory` | Directory names in prompt completion |
349 | `ui.text.symlink` | Symlink names in prompt completion |
350 | `ui.virtual.ruler` | Ruler columns (see the [`editor.rulers` config][editor-section]) |
351 | `ui.virtual.whitespace` | Visible whitespace characters |
352 | `ui.virtual.indent-guide` | Vertical indent width guides |
353 | `ui.virtual.inlay-hint` | Default style for inlay hints of all kinds |
354 | `ui.virtual.inlay-hint.parameter` | Style for inlay hints of kind `parameter` (language servers are not required to set a kind) |
355 | `ui.virtual.inlay-hint.type` | Style for inlay hints of kind `type` (language servers are not required to set a kind) |
356 | `ui.virtual.wrap` | Soft-wrap indicator (see the [`editor.soft-wrap` config][editor-section]) |
357 | `ui.virtual.jump-label` | Style for virtual jump labels |
358 | `ui.menu` | Code and command completion menus |
359 | `ui.menu.selected` | Selected autocomplete item |
360 | `ui.menu.scroll` | `fg` sets thumb color, `bg` sets track color of scrollbar |
361 | `ui.selection` | For selections in the editing area |
362 | `ui.selection.primary` | |
363 | `ui.highlight` | Highlighted lines in the picker preview |
364 | `ui.highlight.frameline` | Line at which debugging execution is paused at |
365 | `ui.cursorline.primary` | The line of the primary cursor ([if cursorline is enabled][editor-section]) |
366 | `ui.cursorline.secondary` | The lines of any other cursors ([if cursorline is enabled][editor-section]) |
367 | `ui.cursorcolumn.primary` | The column of the primary cursor ([if cursorcolumn is enabled][editor-section]) |
368 | `ui.cursorcolumn.secondary` | The columns of any other cursors ([if cursorcolumn is enabled][editor-section]) |
369 | `warning` | Diagnostics warning (gutter) |
370 | `warning.diagnostic.inline` | The inline diagnostic for the warning severity |
371 | `error` | Diagnostics error (gutter) |
372 | `error.diagnostic.inline` | The inline diagnostic for the error severity |
373 | `info` | Diagnostics info (gutter) |
374 | `info.diagnostic.inline` | The inline diagnostic for the warning severity |
375 | `hint` | Diagnostics hint (gutter) |
376 | `hint.diagnostic.inline` | The inline diagnostic for the hint severity |
377 | `diagnostic` | Diagnostics fallback style (editing area) |
378 | `diagnostic.hint` | Diagnostics hint (editing area) |
379 | `diagnostic.info` | Diagnostics info (editing area) |
380 | `diagnostic.warning` | Diagnostics warning (editing area) |
381 | `diagnostic.error` | Diagnostics error (editing area) |
382 | `diagnostic.unnecessary` | Diagnostics with unnecessary tag (editing area) |
383 | `diagnostic.deprecated` | Diagnostics with deprecated tag (editing area) |
384 | `tabstop` | Snippet placeholder |
385
386 [editor-section]: ./configuration.md#editor-section
387 [#2380]: https://github.com/helix-editor/helix/issues/2380