-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: icon support #2869
Open
lazytanuki
wants to merge
8
commits into
helix-editor:master
Choose a base branch
from
lazytanuki:icons
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: icon support #2869
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7df6317
wip: generalised `load_theme` into `load_inheritable_toml`
lazytanuki 5dce354
wip: moved `load_inheritable_toml`, `path` (→ `get_toml_path`), and `…
lazytanuki 82c6710
wip: documented and moved `theme::Loader::read_names` to `helix_loade…
lazytanuki d994e17
wip: add the `icons` module as well as default and nerdfonts flavors
lazytanuki 2b2aee1
feat: add icons launch and runtime loading
lazytanuki 7abaed4
feat: add icons to pickers
lazytanuki f7d188c
feat: handle icons in statusline widget, bufferline and gutter
lazytanuki bee13fb
doc: icons configuration
lazytanuki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>`. | ||
lazytanuki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## 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 = "#…" } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still keep this config though, it makes sense to enable support per UI area