doc: icons configuration

pull/11/head
LazyTanuki 1 year ago
parent d9e342796e
commit cd8a7de454

@ -10,6 +10,7 @@
- [Migrating from Vim](./from-vim.md)
- [Configuration](./configuration.md)
- [Themes](./themes.md)
- [Icons](./icons.md)
- [Key remapping](./remapping.md)
- [Languages](./languages.md)
- [Guides](./guides/README.md)

@ -11,6 +11,7 @@ Example config:
```toml
theme = "onedark"
icons = "nerdfonts"
[editor]
line-number = "relative"
@ -108,6 +109,7 @@ The following statusline elements can be configured:
| `file-line-ending` | The file line endings (CRLF or LF) |
| `total-line-numbers` | The total line numbers of the opened file |
| `file-type` | The type of the opened file |
| `file-type-icon` | The icon representing the language of the open file, or else its file type (see `[editor.icons]` section) |
| `diagnostics` | The number of warnings and/or errors |
| `workspace-diagnostics` | The number of warnings and/or errors on workspace |
| `selections` | The number of active selections |
@ -322,6 +324,18 @@ Currently unused
Currently unused
### `[editor.icons]` Section
Option for displaying icons within the editor.
> Warning: some symbols (such as file-type and symbol-kind icons that you would see in the picker) are not available in the "default" icon set. They usually require a patched font such as [NerdFonts](https://www.nerdfonts.com/) to be installed and configured in your terminal emulator, and the corresponding icon set to be configured in the editor (for example, using `icons = "nerdfonts"` in your configuration file).
| Key | Description | Default |
| --- | --- | --- |
| `picker` | Whether icons in pickers are enabled. | `true` |
| `bufferline` | Whether icons in the buffer line are enabled. | `true` |
| `statusline` | Whether icons in the status line are enabled. | `true` |
### `[editor.soft-wrap]` Section
Options for soft wrapping lines that exceed the view width:

@ -29,6 +29,7 @@
| `:cquit`, `:cq` | Quit with exit code (default 1). Accepts an optional integer exit code (:cq 2). |
| `:cquit!`, `:cq!` | Force quit with exit code (default 1) ignoring unsaved changes. Accepts an optional integer exit code (:cq! 2). |
| `:theme` | Change the editor theme (show current theme if no name specified). |
| `:icons` | Change the editor icon flavor (show current flavor if no name specified). |
| `:clipboard-yank` | Yank main selection into system clipboard. |
| `:clipboard-yank-join` | Yank joined selections into system clipboard. A separator can be provided as first argument. Default value is newline. |
| `:primary-clipboard-yank` | Yank main selection into system primary clipboard. |

@ -0,0 +1,140 @@
# Icons
## Requirements
File-type and symbol-kind icons require a patched font such as [NerdFonts](https://www.nerdfonts.com/) to be installed and configured in your terminal emulator. These types of fonts are called *patched* fonts because they define arbitrary symbols for a range of Unicode values, which may vary from one font to another. Therefore, you need to use an icon flavor adapted to your configured terminal font, otherwise you may end up with undefined characters and mismatched icons.
To enable file-type and symbol-kind icons within the editor, see the `[editor.icons]` section of the [configuration file](./configuration.md).
To use an icon flavor add `icons = "<name>"` to your [`config.toml`](./configuration.md) at the very top of the file before the first section or select it during runtime using `:icons <name>`.
## Creating an icon flavor
Create a file with the name of your icon flavor as file name (i.e `myicons.toml`) and place it in your `icons` directory (i.e `~/.config/helix/icons`). The directory might have to be created beforehand.
The name "default" is reserved for the builtin icons and cannot be overridden by user defined icons.
The name of the icon flavor must be set using the `name` key.
The default icons.toml can be found [here](https://github.com/helix-editor/helix/blob/master/icons.toml), and user submitted icon flavors [here](https://github.com/helix-editor/helix/blob/master/runtime/icons).
Icons flavors have five sections:
- Diagnostics
- Breakpoints
- Diff
- Symbol kinds
- Mime types
Each line in these sections is specified as below:
```toml
key = { icon = "…", color = "#ff0000" }
```
where `key` represents what you want to style, `icon` specifies the character to show as the icon, and `color` specifies the foreground color of the icon. `color` can be omitted to defer to the defaults.
### Diagnostic icons
The `[diagnostic]` section defines four **required** diagnostic icons:
- `error`
- `warning`
- `info`
- `hint`
These icons appear in the gutter, in the diagnostic pickers as well as in the status line diagnostic component.
By default, they have the foreground color defined in the current theme's corresponding keys.
> An icon flavor TOML file must define all of these icons.
### Diff icons
The `[diff]` section defines three **required** diffing icons:
- `added`
- `deleted`
- `modified`
These icons appear in the gutter.
By default, they have the foreground color defined in the current theme's corresponding keys.
> An icon flavor TOML file must define all of these icons.
### Breakpoint icons
The `[breakpoint]` section defines two **required** breakpoint icons:
- `verified`
- `unverified`
These icons appear in the gutter while using the Debug Adapter Protocol (DAP). Their color depends on the breakpoint's condition and log message, it cannot be overridden by the `color` key.
> An icon flavor TOML file must define all of these icons.
### Symbol kinds icons
The `[symbol-kind]` section defines **optional** icons for the following required LSP-defined symbol kinds:
- `file` (this icon is also used on files for which the mime type has not been defined in the next section, as a "generic file" icon)
- `module`
- `namespace`
- `package`
- `class`
- `method`
- `property`
- `field`
- `constructor`
- `enumeration`
- `interface`
- `variable`
- `function`
- `constant`
- `string`
- `number`
- `boolean`
- `array`
- `object`
- `key`
- `null`
- `enum-member`
- `structure`
- `event`
- `operator`
- `type-parameter`
By default, these icons have the same style as the loaded theme's `keyword` key. Their style can be customized using the `symbolkind` key in the theme configuration file, or it can individually be overridden by their `color` key.
> An icon flavor TOML file must define either none or all of these icons.
### Mime types icons
The `[mime-type]` section defines **optional** icons for mime types or filename, such as:
```toml
[mime-type]
".bashrc" = { icon = "…", color = "#…" }
"LICENSE" = { icon = "…", color = "#…" }
"rs" = { icon = "…", color = "#…" }
```
These icons appear in the file picker, in the statusline `file-type-icon` component, and in the bufferline (when enabled).
> An icon flavor TOML file can define none, some or all of these icons.
### Inheritance
Extend upon other icon flavors by setting the `inherits` property to an existing theme.
```toml
inherits = "nerdfonts"
name = "custom_nerdfonts"
# Override the icon for generic files:
[symbol-kind]
file = {icon = "…"}
# Override the icon for Rust files
[mime-type]
"rs" = { icon = "…", color = "#…" }
```

@ -316,14 +316,15 @@ These scopes are used for theming the editor interface:
| `ui.cursorline.secondary` | The lines of any other cursors ([if cursorline is enabled][editor-section]) |
| `ui.cursorcolumn.primary` | The column of the primary cursor ([if cursorcolumn is enabled][editor-section]) |
| `ui.cursorcolumn.secondary` | The columns of any other cursors ([if cursorcolumn is enabled][editor-section]) |
| `warning` | Diagnostics warning (gutter) |
| `error` | Diagnostics error (gutter) |
| `info` | Diagnostics info (gutter) |
| `hint` | Diagnostics hint (gutter) |
| `warning` | Diagnostics warning icon (gutter, statusline, and diagnostic pickers) |
| `error` | Diagnostics error icon (gutter, statusline, and diagnostic pickers) |
| `info` | Diagnostics info icon (gutter, statusline, and diagnostic pickers) |
| `hint` | Diagnostics hint icon (gutter, statusline, and diagnostic pickers) |
| `diagnostic` | Diagnostics fallback style (editing area) |
| `diagnostic.hint` | Diagnostics hint (editing area) |
| `diagnostic.info` | Diagnostics info (editing area) |
| `diagnostic.warning` | Diagnostics warning (editing area) |
| `diagnostic.error` | Diagnostics error (editing area) |
| `symbolkind` | Symbol kind icons (symbol picker) |
[editor-section]: ./configuration.md#editor-section

Loading…
Cancel
Save