on master help sign in
Merge branch 'master' into test-harness
commit458b89e21dcf76bbf9ca6ba237bd334f4922722d authorBlaž Hrastnik <blaz@mxxn.io> dateTue 21 Jun 2022, 18:38 (4 years ago) parent5f7c2476a3f7f2
52 files changed+465−197
Cargo.lock+2−2 book/src/guides/adding_languages.md+7−60 book/src/guides/textobject.md+2 book/src/keymap.md+2 book/src/languages.md+90−16 book/src/usage.md+1 helix-core/src/lib.rs+3−1 helix-core/src/movement.rs+21−22 helix-core/src/position.rs+103−3 helix-term/src/commands.rs+26−12 helix-term/src/health.rs+10−5 helix-term/src/keymap/default.rs+2 helix-term/src/ui/editor.rs+5−3 helix-view/src/gutter.rs+12−1 helix-view/src/view.rs+12−41 runtime/queries/elixir/textobjects.scm+7−1 runtime/queries/erlang/textobjects.scm+8 runtime/queries/gleam/textobjects.scm+5 runtime/queries/go/textobjects.scm+5 runtime/queries/javascript/injections.scm+10−2 runtime/queries/jsdoc/injections.scm+5 runtime/queries/python/textobjects.scm+5 runtime/queries/rust/textobjects.scm+14 runtime/themes/base16_default_dark.toml+1−1 runtime/themes/base16_default_light.toml+1−1 runtime/themes/base16_terminal.toml+1−1 runtime/themes/bogster.toml+1−1 runtime/themes/boo_berry.toml+1−1 runtime/themes/catppuccin.toml+1−1 runtime/themes/dark_plus.toml+1−1 runtime/themes/dracula.toml+1−1 runtime/themes/everforest_dark.toml+1−1 runtime/themes/everforest_light.toml+1−1 runtime/themes/gruvbox.toml+1−1 runtime/themes/gruvbox_light.toml+1−1 runtime/themes/ingrid.toml+1−1 runtime/themes/monokai.toml+1−1 runtime/themes/monokai_pro.toml+1−1 runtime/themes/monokai_pro_machine.toml+1−1 runtime/themes/monokai_pro_octagon.toml+1−1 runtime/themes/monokai_pro_ristretto.toml+1−1 runtime/themes/monokai_pro_spectrum.toml+1−1 runtime/themes/noctis_bordo.toml+80 runtime/themes/nord.toml+1−1 runtime/themes/rose_pine.toml+1−1 runtime/themes/rose_pine_dawn.toml+1−1 runtime/themes/serika-dark.toml+1−1 runtime/themes/serika-light.toml+1−1 runtime/themes/snazzy.toml+1−1 runtime/themes/solarized_dark.toml+1−1 runtime/themes/solarized_light.toml+1−1 runtime/themes/spacebones_light.toml+1−1
Cargo.lock+2−2
@@ -13,9 +13,9 @@ dependencies = [
1313
1414[[package]]
1515name = "anyhow"
16−version = "1.0.53"
16+version = "1.0.58"
1717source = "registry+https://github.com/rust-lang/crates.io-index"
18−checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
18+checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
1919
2020[[package]]
2121name = "arc-swap"
book/src/guides/adding_languages.md+7−60
@@ -2,40 +2,8 @@
22
33## Language configuration
44
5−To add a new language, you need to add a `language` entry to the
6−[`languages.toml`][languages.toml] found in the root of the repository;
7−this `languages.toml` file is included at compilation time, and is
8−distinct from the `languages.toml` file in the user's [configuration
9−directory](../configuration.md).
10−
11−```toml
12−[[language]]
13−name = "mylang"
14−scope = "scope.mylang"
15−injection-regex = "^mylang$"
16−file-types = ["mylang", "myl"]
17−comment-token = "#"
18−indent = { tab-width = 2, unit = " " }
19−language-server = { command = "mylang-lsp", args = ["--stdio"] }
20−```
21−
22−These are the available keys and descriptions for the file.
23−
24−| Key | Description |
25−| ---- | ----------- |
26−| `name` | The name of the language |
27−| `scope` | A string like `source.js` that identifies the language. Currently, we strive to match the scope names used by popular TextMate grammars and by the Linguist library. Usually `source.<name>` or `text.<name>` in case of markup languages |
28−| `injection-regex` | regex pattern that will be tested against a language name in order to determine whether this language should be used for a potential [language injection][treesitter-language-injection] site. |
29−| `file-types` | The filetypes of the language, for example `["yml", "yaml"]`. Extensions and full file names are supported. |
30−| `shebangs` | The interpreters from the shebang line, for example `["sh", "bash"]` |
31−| `roots` | A set of marker files to look for when trying to find the workspace root. For example `Cargo.lock`, `yarn.lock` |
32−| `auto-format` | Whether to autoformat this language when saving |
33−| `diagnostic-severity` | Minimal severity of diagnostic for it to be displayed. (Allowed values: `Error`, `Warning`, `Info`, `Hint`) |
34−| `comment-token` | The token to use as a comment-token |
35−| `indent` | The indent to use. Has sub keys `tab-width` and `unit` |
36−| `language-server` | The Language Server to run. Has sub keys `command` and `args` |
37−| `config` | Language Server configuration |
38−| `grammar` | The tree-sitter grammar to use (defaults to the value of `name`) |
5+To add a new language, you need to add a `[[language]]` entry to the
6+`languages.toml` (see the [language configuration section]).
397
408When adding a new language or Language Server configuration for an existing
419language, run `cargo xtask docgen` to add the new configuration to the
@@ -45,32 +13,12 @@ When adding a Language Server configuration, be sure to update the
4513
4614## Grammar configuration
4715
48−If a tree-sitter grammar is available for the language, add a new `grammar`
16+If a tree-sitter grammar is available for the language, add a new `[[grammar]]`
4917entry to `languages.toml`.
5018
51−```toml
52−[[grammar]]
53−name = "mylang"
54−source = { git = "https://github.com/example/mylang", rev = "a250c4582510ff34767ec3b7dcdd3c24e8c8aa68" }
55−```
56−
57−Grammar configuration takes these keys:
58−
59−| Key | Description |
60−| --- | ----------- |
61−| `name` | The name of the tree-sitter grammar |
62−| `source` | The method of fetching the grammar - a table with a schema defined below |
63−
64−Where `source` is a table with either these keys when using a grammar from a
65−git repository:
66−
67−| Key | Description |
68−| --- | ----------- |
69−| `git` | A git remote URL from which the grammar should be cloned |
70−| `rev` | The revision (commit hash or tag) which should be fetched |
71−| `subpath` | A path within the grammar directory which should be built. Some grammar repositories host multiple grammars (for example `tree-sitter-typescript` and `tree-sitter-ocaml`) in subdirectories. This key is used to point `hx --grammar build` to the correct path for compilation. When omitted, the root of repository is used |
72−
73−Or a `path` key with an absolute path to a locally available grammar directory.
19+You may use the `source.path` key rather than `source.git` with an absolute path
20+to a locally available grammar for testing, but switch to `source.git` before
21+submitting a pull request.
7422
7523## Queries
7624
@@ -91,8 +39,7 @@ the last matching query supersedes the ones before it. See
9139
9240- If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so`
9341
94−[treesitter-language-injection]: https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection
95−[languages.toml]: https://github.com/helix-editor/helix/blob/master/languages.toml
42+[language configuration section]: ../languages.md
9643[neovim-query-precedence]: https://github.com/helix-editor/helix/pull/1170#issuecomment-997294090
9744[install-lsp-wiki]: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers
9845[lang-support]: ../lang-support.md
book/src/guides/textobject.md+2
@@ -20,6 +20,8 @@ The following [captures][tree-sitter-captures] are recognized:
2020| `function.around` |
2121| `class.inside` |
2222| `class.around` |
23+| `test.inside` |
24+| `test.around` |
2325| `parameter.inside` |
2426| `comment.inside` |
2527| `comment.around` |
book/src/keymap.md+2
@@ -282,6 +282,8 @@ Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaire
282282| `[a` | Go to previous argument/parameter (**TS**) | `goto_prev_parameter` |
283283| `]o` | Go to next comment (**TS**) | `goto_next_comment` |
284284| `[o` | Go to previous comment (**TS**) | `goto_prev_comment` |
285+| `]t` | Go to next test (**TS**) | `goto_next_test` |
286+| `]t` | Go to previous test (**TS**) | `goto_prev_test` |
285287| `]p` | Go to next paragraph | `goto_next_paragraph` |
286288| `[p` | Go to previous paragraph | `goto_prev_paragraph` |
287289| `[space` | Add newline above | `add_newline_above` |
book/src/languages.md+90−16
@@ -1,10 +1,17 @@
11# Languages
22
3−Language-specific settings and settings for particular language servers can be configured in a `languages.toml` file placed in your [configuration directory](./configuration.md). Helix actually uses two `languages.toml` files, the [first one](https://github.com/helix-editor/helix/blob/master/languages.toml) is in the main helix repository; it contains the default settings for each language and is included in the helix binary at compile time. Users who want to see the available settings and options can either reference the helix repo's `languages.toml` file, or consult the table in the [adding languages](./guides/adding_languages.md) section.
3+Language-specific settings and settings for language servers are configured
4+in `languages.toml` files.
45
5−A local `languages.toml` can be created within a `.helix` directory. Its settings will be merged with both the global and default configs.
6+## `languages.toml` files
67
7−Changes made to the `languages.toml` file in a user's [configuration directory](./configuration.md) are merged with helix's defaults on start-up, such that a user's settings will take precedence over defaults in the event of a collision. For example, the default `languages.toml` sets rust's `auto-format` to `true`. If a user wants to disable auto-format, they can change the `languages.toml` in their [configuration directory](./configuration.md) to make the rust entry read like the example below; the new key/value pair `auto-format = false` will override the default when the two sets of settings are merged on start-up:
8+There are three possible `languages.toml` files. The first is compiled into
9+Helix and lives in the [Helix repository](https://github.com/helix-editor/helix/blob/master/languages.toml).
10+This provides the default configurations for languages and language servers.
11+
12+You may define a `languages.toml` in your [configuration directory](./configuration.md)
13+which overrides values from the built-in language configuration. For example
14+to disable auto-LSP-formatting in Rust:
815
916```toml
1017# in <config_dir>/helix/languages.toml
@@ -14,9 +21,60 @@ name = "rust"
1421auto-format = false
1522```
1623
17−## LSP formatting options
24+Language configuration may also be overridden local to a project by creating
25+a `languages.toml` file under a `.helix` directory. Its settings will be merged
26+with the language configuration in the configuration directory and the built-in
27+configuration.
28+
29+## Language configuration
1830
19−Use `format` field to pass extra formatting options to [Document Formatting Requests](https://github.com/microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md#document-formatting-request--leftwards_arrow_with_hook).
31+Each language is configured by adding a `[[language]]` section to a
32+`languages.toml` file. For example:
33+
34+```toml
35+[[language]]
36+name = "mylang"
37+scope = "source.mylang"
38+injection-regex = "^mylang$"
39+file-types = ["mylang", "myl"]
40+comment-token = "#"
41+indent = { tab-width = 2, unit = " " }
42+language-server = { command = "mylang-lsp", args = ["--stdio"] }
43+```
44+
45+These configuration keys are available:
46+
47+| Key | Description |
48+| ---- | ----------- |
49+| `name` | The name of the language |
50+| `scope` | A string like `source.js` that identifies the language. Currently, we strive to match the scope names used by popular TextMate grammars and by the Linguist library. Usually `source.<name>` or `text.<name>` in case of markup languages |
51+| `injection-regex` | regex pattern that will be tested against a language name in order to determine whether this language should be used for a potential [language injection][treesitter-language-injection] site. |
52+| `file-types` | The filetypes of the language, for example `["yml", "yaml"]`. Extensions and full file names are supported. |
53+| `shebangs` | The interpreters from the shebang line, for example `["sh", "bash"]` |
54+| `roots` | A set of marker files to look for when trying to find the workspace root. For example `Cargo.lock`, `yarn.lock` |
55+| `auto-format` | Whether to autoformat this language when saving |
56+| `diagnostic-severity` | Minimal severity of diagnostic for it to be displayed. (Allowed values: `Error`, `Warning`, `Info`, `Hint`) |
57+| `comment-token` | The token to use as a comment-token |
58+| `indent` | The indent to use. Has sub keys `tab-width` and `unit` |
59+| `language-server` | The Language Server to run. See the Language Server configuration section below. |
60+| `config` | Language Server configuration |
61+| `grammar` | The tree-sitter grammar to use (defaults to the value of `name`) |
62+
63+### Language Server configuration
64+
65+The `language-server` field takes the following keys:
66+
67+| Key | Description |
68+| --- | ----------- |
69+| `command` | The name of the language server binary to execute. Binaries must be in `$PATH` |
70+| `args` | A list of arguments to pass to the language server binary |
71+| `timeout` | The maximum time a request to the language server may take, in seconds. Defaults to `20` |
72+| `language-id` | The language name to pass to the language server. Some language servers support multiple languages and use this field to determine which one is being served in a buffer |
73+
74+The top-level `config` field is used to configure the LSP initialization options. A `format`
75+sub-table within `config` can be used to pass extra formatting options to
76+[Document Formatting Requests](https://github.com/microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md#document-formatting-request--leftwards_arrow_with_hook).
77+For example with typescript:
2078
2179```toml
2280[[language]]
@@ -26,23 +84,37 @@ auto-format = true
2684config = { format = { "semicolons" = "insert", "insertSpaceBeforeFunctionParenthesis" = true } }
2785```
2886
29−## Tree-sitter grammars
87+## Tree-sitter grammar configuration
3088
31−Tree-sitter grammars can also be configured in `languages.toml`:
89+The source for a language's tree-sitter grammar is specified in a `[[grammar]]`
90+section in `languages.toml`. For example:
3291
3392```toml
34−# in <config_dir>/helix/languages.toml
35−
3693[[grammar]]
37−name = "rust"
38−source = { git = "https://github.com/tree-sitter/tree-sitter-rust", rev = "a250c4582510ff34767ec3b7dcdd3c24e8c8aa68" }
39−
40−[[grammar]]
41−name = "c"
42−source = { path = "/path/to/tree-sitter-c" }
94+name = "mylang"
95+source = { git = "https://github.com/example/mylang", rev = "a250c4582510ff34767ec3b7dcdd3c24e8c8aa68" }
4396```
4497
45−You may use a top-level `use-grammars` key to control which grammars are fetched and built.
98+Grammar configuration takes these keys:
99+
100+| Key | Description |
101+| --- | ----------- |
102+| `name` | The name of the tree-sitter grammar |
103+| `source` | The method of fetching the grammar - a table with a schema defined below |
104+
105+Where `source` is a table with either these keys when using a grammar from a
106+git repository:
107+
108+| Key | Description |
109+| --- | ----------- |
110+| `git` | A git remote URL from which the grammar should be cloned |
111+| `rev` | The revision (commit hash or tag) which should be fetched |
112+| `subpath` | A path within the grammar directory which should be built. Some grammar repositories host multiple grammars (for example `tree-sitter-typescript` and `tree-sitter-ocaml`) in subdirectories. This key is used to point `hx --grammar build` to the correct path for compilation. When omitted, the root of repository is used |
113+
114+### Choosing grammars
115+
116+You may use a top-level `use-grammars` key to control which grammars are
117+fetched and built when using `hx --grammar fetch` and `hx --grammar build`.
46118
47119```toml
48120# Note: this key must come **before** the [[language]] and [[grammar]] sections
@@ -52,3 +124,5 @@ use-grammars = { except = [ "yaml", "json" ] }
52124```
53125
54126When omitted, all grammars are fetched and built.
127+
128+[treesitter-language-injection]: https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection
book/src/usage.md+1
@@ -143,6 +143,7 @@ Currently supported: `word`, `surround`, `function`, `class`, `parameter`.
143143| `c` | Class |
144144| `a` | Argument/parameter |
145145| `o` | Comment |
146+| `t` | Test |
146147
147148> NOTE: `f`, `c`, etc need a tree-sitter grammar active for the current
148149document and a special tree-sitter query file to work properly. [Only
helix-core/src/lib.rs+3−1
@@ -63,7 +63,9 @@ pub type Tendril = SmartString<smartstring::LazyCompact>;
6363pub use {regex, tree_sitter};
6464
6565pub use graphemes::RopeGraphemes;
66−pub use position::{coords_at_pos, pos_at_coords, visual_coords_at_pos, Position};
66+pub use position::{
67+ coords_at_pos, pos_at_coords, pos_at_visual_coords, visual_coords_at_pos, Position,
68+};
6769pub use selection::{Range, Selection};
6870pub use smallvec::{smallvec, SmallVec};
6971pub use syntax::Syntax;
helix-core/src/movement.rs+21−22
@@ -5,16 +5,15 @@ use tree_sitter::{Node, QueryCursor};
55
66use crate::{
77 chars::{categorize_char, char_is_line_ending, CharCategory},
8− coords_at_pos,
98 graphemes::{
109 next_grapheme_boundary, nth_next_grapheme_boundary, nth_prev_grapheme_boundary,
1110 prev_grapheme_boundary,
1211 },
1312 line_ending::rope_is_line_ending,
14− pos_at_coords,
13+ pos_at_visual_coords,
1514 syntax::LanguageConfiguration,
1615 textobject::TextObject,
17− Position, Range, RopeSlice,
16+ visual_coords_at_pos, Position, Range, RopeSlice,
1817};
1918
2019#[derive(Debug, Copy, Clone, PartialEq, Eq)]
@@ -35,6 +34,7 @@ pub fn move_horizontally(
3534 dir: Direction,
3635 count: usize,
3736 behaviour: Movement,
37+ _: usize,
3838) -> Range {
3939 let pos = range.cursor(slice);
4040
@@ -54,15 +54,12 @@ pub fn move_vertically(
5454 dir: Direction,
5555 count: usize,
5656 behaviour: Movement,
57+ tab_width: usize,
5758) -> Range {
5859 let pos = range.cursor(slice);
5960
6061 // Compute the current position's 2d coordinates.
61− // TODO: switch this to use `visual_coords_at_pos` rather than
62− // `coords_at_pos` as this will cause a jerky movement when the visual
63− // position does not match, like moving from a line with tabs/CJK to
64− // a line without
65− let Position { row, col } = coords_at_pos(slice, pos);
62+ let Position { row, col } = visual_coords_at_pos(slice, pos, tab_width);
6663 let horiz = range.horiz.unwrap_or(col as u32);
6764
6865 // Compute the new position.
@@ -71,7 +68,7 @@ pub fn move_vertically(
7168 Direction::Backward => row.saturating_sub(count),
7269 };
7370 let new_col = col.max(horiz as usize);
74− let new_pos = pos_at_coords(slice, Position::new(new_row, new_col), true);
71+ let new_pos = pos_at_visual_coords(slice, Position::new(new_row, new_col), tab_width);
7572
7673 // Special-case to avoid moving to the end of the last non-empty line.
7774 if behaviour == Movement::Extend && slice.line(new_row).len_chars() == 0 {
@@ -446,6 +443,8 @@ pub fn goto_treesitter_object(
446443mod test {
447444 use ropey::Rope;
448445
446+ use crate::{coords_at_pos, pos_at_coords};
447+
449448 use super::*;
450449
451450 const SINGLE_LINE_SAMPLE: &str = "This is a simple alphabetic line";
@@ -472,7 +471,7 @@ mod test {
472471 assert_eq!(
473472 coords_at_pos(
474473 slice,
475− move_vertically(slice, range, Direction::Forward, 1, Movement::Move).head
474+ move_vertically(slice, range, Direction::Forward, 1, Movement::Move, 4).head
476475 ),
477476 (1, 3).into()
478477 );
@@ -496,7 +495,7 @@ mod test {
496495 ];
497496
498497 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
499− range = move_horizontally(slice, range, direction, amount, Movement::Move);
498+ range = move_horizontally(slice, range, direction, amount, Movement::Move, 0);
500499 assert_eq!(coords_at_pos(slice, range.head), coordinates.into())
501500 }
502501 }
@@ -522,7 +521,7 @@ mod test {
522521 ];
523522
524523 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
525− range = move_horizontally(slice, range, direction, amount, Movement::Move);
524+ range = move_horizontally(slice, range, direction, amount, Movement::Move, 0);
526525 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
527526 assert_eq!(range.head, range.anchor);
528527 }
@@ -544,7 +543,7 @@ mod test {
544543 ];
545544
546545 for (direction, amount) in moves {
547− range = move_horizontally(slice, range, direction, amount, Movement::Extend);
546+ range = move_horizontally(slice, range, direction, amount, Movement::Extend, 0);
548547 assert_eq!(range.anchor, original_anchor);
549548 }
550549 }
@@ -568,7 +567,7 @@ mod test {
568567 ];
569568
570569 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
571− range = move_vertically(slice, range, direction, amount, Movement::Move);
570+ range = move_vertically(slice, range, direction, amount, Movement::Move, 4);
572571 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
573572 assert_eq!(range.head, range.anchor);
574573 }
@@ -602,8 +601,8 @@ mod test {
602601
603602 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
604603 range = match axis {
605− Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move),
606− Axis::V => move_vertically(slice, range, direction, amount, Movement::Move),
604+ Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move, 0),
605+ Axis::V => move_vertically(slice, range, direction, amount, Movement::Move, 4),
607606 };
608607 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
609608 assert_eq!(range.head, range.anchor);
@@ -627,18 +626,18 @@ mod test {
627626 let moves_and_expected_coordinates = [
628627 // Places cursor at the fourth kana.
629628 ((Axis::H, Direction::Forward, 4), (0, 4)),
630− // Descent places cursor at the 4th character.
631− ((Axis::V, Direction::Forward, 1usize), (1, 4)),
632− // Moving back 1 character.
633− ((Axis::H, Direction::Backward, 1usize), (1, 3)),
629+ // Descent places cursor at the 8th character.
630+ ((Axis::V, Direction::Forward, 1usize), (1, 8)),
631+ // Moving back 2 characters.
632+ ((Axis::H, Direction::Backward, 2usize), (1, 6)),
634633 // Jumping back up 1 line.
635634 ((Axis::V, Direction::Backward, 1usize), (0, 3)),
636635 ];
637636
638637 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
639638 range = match axis {
640− Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move),
641− Axis::V => move_vertically(slice, range, direction, amount, Movement::Move),
639+ Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move, 0),
640+ Axis::V => move_vertically(slice, range, direction, amount, Movement::Move, 4),
642641 };
643642 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
644643 assert_eq!(range.head, range.anchor);
helix-core/src/position.rs+103−3
@@ -109,9 +109,6 @@ pub fn visual_coords_at_pos(text: RopeSlice, pos: usize, tab_width: usize) -> Po
109109/// with left-side block-cursor positions, as this prevents the the block cursor
110110/// from jumping to the next line. Otherwise you typically want it to be `false`,
111111/// such as when dealing with raw anchor/head positions.
112−///
113−/// TODO: this should be changed to work in terms of visual row/column, not
114−/// graphemes.
115112pub fn pos_at_coords(text: RopeSlice, coords: Position, limit_before_line_ending: bool) -> usize {
116113 let Position { mut row, col } = coords;
117114 if limit_before_line_ending {
@@ -135,6 +132,43 @@ pub fn pos_at_coords(text: RopeSlice, coords: Position, limit_before_line_ending
135132 line_start + col_char_offset
136133}
137134
135+/// Convert visual (line, column) coordinates to a character index.
136+///
137+/// If the `line` coordinate is beyond the end of the file, the EOF
138+/// position will be returned.
139+///
140+/// If the `column` coordinate is past the end of the given line, the
141+/// line-end position (in this case, just before the line ending
142+/// character) will be returned.
143+pub fn pos_at_visual_coords(text: RopeSlice, coords: Position, tab_width: usize) -> usize {
144+ let Position { mut row, col } = coords;
145+ row = row.min(text.len_lines() - 1);
146+ let line_start = text.line_to_char(row);
147+ let line_end = line_end_char_index(&text, row);
148+
149+ let mut col_char_offset = 0;
150+ let mut cols_remaining = col;
151+ for grapheme in RopeGraphemes::new(text.slice(line_start..line_end)) {
152+ let grapheme_width = if grapheme == "\t" {
153+ tab_width - ((col - cols_remaining) % tab_width)
154+ } else {
155+ let grapheme = Cow::from(grapheme);
156+ grapheme_width(&grapheme)
157+ };
158+
159+ // If pos is in the middle of a wider grapheme (tab for example)
160+ // return the starting offset.
161+ if grapheme_width > cols_remaining {
162+ break;
163+ }
164+
165+ cols_remaining -= grapheme_width;
166+ col_char_offset += grapheme.chars().count();
167+ }
168+
169+ line_start + col_char_offset
170+}
171+
138172#[cfg(test)]
139173mod test {
140174 use super::*;
@@ -305,4 +339,70 @@ mod test {
305339 assert_eq!(pos_at_coords(slice, (0, 10).into(), true), 0);
306340 assert_eq!(pos_at_coords(slice, (10, 10).into(), true), 0);
307341 }
342+
343+ #[test]
344+ fn test_pos_at_visual_coords() {
345+ let text = Rope::from("ḧëḷḷö\nẅöṛḷḋ");
346+ let slice = text.slice(..);
347+ assert_eq!(pos_at_visual_coords(slice, (0, 0).into(), 4), 0);
348+ assert_eq!(pos_at_visual_coords(slice, (0, 5).into(), 4), 5); // position on \n
349+ assert_eq!(pos_at_visual_coords(slice, (0, 6).into(), 4), 5); // position after \n
350+ assert_eq!(pos_at_visual_coords(slice, (1, 0).into(), 4), 6); // position on w
351+ assert_eq!(pos_at_visual_coords(slice, (1, 1).into(), 4), 7); // position on o
352+ assert_eq!(pos_at_visual_coords(slice, (1, 4).into(), 4), 10); // position on d
353+
354+ // Test with wide characters.
355+ let text = Rope::from("今日はいい\n");
356+ let slice = text.slice(..);
357+ assert_eq!(pos_at_visual_coords(slice, (0, 0).into(), 4), 0);
358+ assert_eq!(pos_at_visual_coords(slice, (0, 1).into(), 4), 0);
359+ assert_eq!(pos_at_visual_coords(slice, (0, 2).into(), 4), 1);
360+ assert_eq!(pos_at_visual_coords(slice, (0, 3).into(), 4), 1);
361+ assert_eq!(pos_at_visual_coords(slice, (0, 4).into(), 4), 2);
362+ assert_eq!(pos_at_visual_coords(slice, (0, 5).into(), 4), 2);
363+ assert_eq!(pos_at_visual_coords(slice, (0, 6).into(), 4), 3);
364+ assert_eq!(pos_at_visual_coords(slice, (0, 7).into(), 4), 3);
365+ assert_eq!(pos_at_visual_coords(slice, (0, 8).into(), 4), 4);
366+ assert_eq!(pos_at_visual_coords(slice, (0, 9).into(), 4), 4);
367+ // assert_eq!(pos_at_visual_coords(slice, (0, 10).into(), 4, false), 5);
368+ // assert_eq!(pos_at_visual_coords(slice, (0, 10).into(), 4, true), 5);
369+ assert_eq!(pos_at_visual_coords(slice, (1, 0).into(), 4), 6);
370+
371+ // Test with grapheme clusters.
372+ let text = Rope::from("a̐éö̲\r\n");
373+ let slice = text.slice(..);
374+ assert_eq!(pos_at_visual_coords(slice, (0, 0).into(), 4), 0);
375+ assert_eq!(pos_at_visual_coords(slice, (0, 1).into(), 4), 2);
376+ assert_eq!(pos_at_visual_coords(slice, (0, 2).into(), 4), 4);
377+ assert_eq!(pos_at_visual_coords(slice, (0, 3).into(), 4), 7); // \r\n is one char here
378+ assert_eq!(pos_at_visual_coords(slice, (0, 4).into(), 4), 7);
379+ assert_eq!(pos_at_visual_coords(slice, (1, 0).into(), 4), 9);
380+
381+ // Test with wide-character grapheme clusters.
382+ let text = Rope::from("किमपि");
383+ // 2 - 1 - 2 codepoints
384+ // TODO: delete handling as per https://news.ycombinator.com/item?id=20058454
385+ let slice = text.slice(..);
386+ assert_eq!(pos_at_visual_coords(slice, (0, 0).into(), 4), 0);
387+ assert_eq!(pos_at_visual_coords(slice, (0, 1).into(), 4), 0);
388+ assert_eq!(pos_at_visual_coords(slice, (0, 2).into(), 4), 2);
389+ assert_eq!(pos_at_visual_coords(slice, (0, 3).into(), 4), 3);
390+
391+ // Test with tabs.
392+ let text = Rope::from("\tHello\n");
393+ let slice = text.slice(..);
394+ assert_eq!(pos_at_visual_coords(slice, (0, 0).into(), 4), 0);
395+ assert_eq!(pos_at_visual_coords(slice, (0, 1).into(), 4), 0);
396+ assert_eq!(pos_at_visual_coords(slice, (0, 2).into(), 4), 0);
397+ assert_eq!(pos_at_visual_coords(slice, (0, 3).into(), 4), 0);
398+ assert_eq!(pos_at_visual_coords(slice, (0, 4).into(), 4), 1);
399+ assert_eq!(pos_at_visual_coords(slice, (0, 5).into(), 4), 2);
400+
401+ // Test out of bounds.
402+ let text = Rope::new();
403+ let slice = text.slice(..);
404+ assert_eq!(pos_at_visual_coords(slice, (10, 0).into(), 4), 0);
405+ assert_eq!(pos_at_visual_coords(slice, (0, 10).into(), 4), 0);
406+ assert_eq!(pos_at_visual_coords(slice, (10, 10).into(), 4), 0);
407+ }
308408}
helix-term/src/commands.rs+26−12
@@ -16,14 +16,14 @@ use helix_core::{
1616 line_ending::{get_line_ending_of_str, line_end_char_index, str_is_line_ending},
1717 match_brackets,
1818 movement::{self, Direction},
19− object, pos_at_coords,
19+ object, pos_at_coords, pos_at_visual_coords,
2020 regex::{self, Regex, RegexBuilder},
2121 search::{self, CharMatcher},
2222 selection, shellwords, surround, textobject,
2323 tree_sitter::Node,
2424 unicode::width::UnicodeWidthChar,
25− LineEnding, Position, Range, Rope, RopeGraphemes, RopeSlice, Selection, SmallVec, Tendril,
26− Transaction,
25+ visual_coords_at_pos, LineEnding, Position, Range, Rope, RopeGraphemes, RopeSlice, Selection,
26+ SmallVec, Tendril, Transaction,
2727};
2828use helix_view::{
2929 clipboard::ClipboardType,
@@ -395,6 +395,8 @@ impl MappableCommand {
395395 goto_prev_parameter, "Goto previous parameter",
396396 goto_next_comment, "Goto next comment",
397397 goto_prev_comment, "Goto previous comment",
398+ goto_next_test, "Goto next test",
399+ goto_prev_test, "Goto previous test",
398400 goto_next_paragraph, "Goto next paragraph",
399401 goto_prev_paragraph, "Goto previous paragraph",
400402 dap_launch, "Launch debug target",
@@ -509,7 +511,7 @@ fn no_op(_cx: &mut Context) {}
509511
510512fn move_impl<F>(cx: &mut Context, move_fn: F, dir: Direction, behaviour: Movement)
511513where
512− F: Fn(RopeSlice, Range, Direction, usize, Movement) -> Range,
514+ F: Fn(RopeSlice, Range, Direction, usize, Movement, usize) -> Range,
513515{
514516 let count = cx.count();
515517 let (view, doc) = current!(cx.editor);
@@ -518,7 +520,7 @@ where
518520 let selection = doc
519521 .selection(view.id)
520522 .clone()
521− .transform(|range| move_fn(text, range, dir, count, behaviour));
523+ .transform(|range| move_fn(text, range, dir, count, behaviour, doc.tab_width()));
522524 doc.set_selection(view.id, selection);
523525}
524526
@@ -1410,9 +1412,10 @@ fn copy_selection_on_line(cx: &mut Context, direction: Direction) {
14101412 range.head
14111413 };
14121414
1413− // TODO: this should use visual offsets / pos_at_screen_coords
1414− let head_pos = coords_at_pos(text, head);
1415− let anchor_pos = coords_at_pos(text, range.anchor);
1415+ let tab_width = doc.tab_width();
1416+
1417+ let head_pos = visual_coords_at_pos(text, head, tab_width);
1418+ let anchor_pos = visual_coords_at_pos(text, range.anchor, tab_width);
14161419
14171420 let height = std::cmp::max(head_pos.row, anchor_pos.row)
14181421 - std::cmp::min(head_pos.row, anchor_pos.row)
@@ -1442,12 +1445,13 @@ fn copy_selection_on_line(cx: &mut Context, direction: Direction) {
14421445 break;
14431446 }
14441447
1445− let anchor = pos_at_coords(text, Position::new(anchor_row, anchor_pos.col), true);
1446− let head = pos_at_coords(text, Position::new(head_row, head_pos.col), true);
1448+ let anchor =
1449+ pos_at_visual_coords(text, Position::new(anchor_row, anchor_pos.col), tab_width);
1450+ let head = pos_at_visual_coords(text, Position::new(head_row, head_pos.col), tab_width);
14471451
14481452 // skip lines that are too short
1449− if coords_at_pos(text, anchor).col == anchor_pos.col
1450− && coords_at_pos(text, head).col == head_pos.col
1453+ if visual_coords_at_pos(text, anchor, tab_width).col == anchor_pos.col
1454+ && visual_coords_at_pos(text, head, tab_width).col == head_pos.col
14511455 {
14521456 if is_primary {
14531457 primary_index = ranges.len();
@@ -4105,6 +4109,14 @@ fn goto_prev_comment(cx: &mut Context) {
41054109 goto_ts_object_impl(cx, "comment", Direction::Backward)
41064110}
41074111
4112+fn goto_next_test(cx: &mut Context) {
4113+ goto_ts_object_impl(cx, "test", Direction::Forward)
4114+}
4115+
4116+fn goto_prev_test(cx: &mut Context) {
4117+ goto_ts_object_impl(cx, "test", Direction::Backward)
4118+}
4119+
41084120fn select_textobject_around(cx: &mut Context) {
41094121 select_textobject(cx, textobject::TextObject::Around);
41104122}
@@ -4148,6 +4160,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
41484160 'f' => textobject_treesitter("function", range),
41494161 'a' => textobject_treesitter("parameter", range),
41504162 'o' => textobject_treesitter("comment", range),
4163+ 't' => textobject_treesitter("test", range),
41514164 'p' => textobject::textobject_paragraph(text, range, objtype, count),
41524165 'm' => textobject::textobject_surround_closest(text, range, objtype, count),
41534166 // TODO: cancel new ranges if inconsistent surround matches across lines
@@ -4177,6 +4190,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
41774190 ("f", "Function (tree-sitter)"),
41784191 ("a", "Argument/parameter (tree-sitter)"),
41794192 ("o", "Comment (tree-sitter)"),
4193+ ("t", "Test (tree-sitter)"),
41804194 ("m", "Matching delimiter under cursor"),
41814195 (" ", "... or any character acting as a pair"),
41824196 ];
helix-term/src/health.rs+10−5
@@ -1,4 +1,7 @@
1−use crossterm::style::{Color, Print, Stylize};
1+use crossterm::{
2+ style::{Color, Print, Stylize},
3+ tty::IsTty,
4+};
25use helix_core::config::{default_syntax_loader, user_syntax_loader};
36use helix_loader::grammar::load_runtime_file;
47use std::io::Write;
@@ -106,17 +109,19 @@ pub fn languages_all() -> std::io::Result<()> {
106109
107110 let terminal_cols = crossterm::terminal::size().map(|(c, _)| c).unwrap_or(80);
108111 let column_width = terminal_cols as usize / headings.len();
112+ let is_terminal = std::io::stdout().is_tty();
109113
110114 let column = |item: &str, color: Color| {
111− let data = format!(
115+ let mut data = format!(
112116 "{:width$}",
113117 item.get(..column_width - 2)
114118 .map(|s| format!("{}…", s))
115119 .unwrap_or_else(|| item.to_string()),
116120 width = column_width,
117− )
118− .stylize()
119− .with(color);
121+ );
122+ if is_terminal {
123+ data = data.stylize().with(color).to_string();
124+ }
120125
121126 // We can't directly use println!() because of
122127 // https://github.com/crossterm-rs/crossterm/issues/589
helix-term/src/keymap/default.rs+2
@@ -104,6 +104,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
104104 "c" => goto_prev_class,
105105 "a" => goto_prev_parameter,
106106 "o" => goto_prev_comment,
107+ "t" => goto_prev_test,
107108 "p" => goto_prev_paragraph,
108109 "space" => add_newline_above,
109110 },
@@ -114,6 +115,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
114115 "c" => goto_next_class,
115116 "a" => goto_next_parameter,
116117 "o" => goto_next_comment,
118+ "t" => goto_next_test,
117119 "p" => goto_next_paragraph,
118120 "space" => add_newline_below,
119121 },
helix-term/src/ui/editor.rs+5−3
@@ -20,7 +20,7 @@ use helix_core::{
2020use helix_view::{
2121 document::{Mode, SCRATCH_BUFFER_NAME},
2222 editor::{CompleteAction, CursorShapeConfig},
23− graphics::{CursorKind, Modifier, Rect, Style},
23+ graphics::{Color, CursorKind, Modifier, Rect, Style},
2424 input::KeyEvent,
2525 keyboard::{KeyCode, KeyModifiers},
2626 Document, Editor, Theme, View,
@@ -170,7 +170,9 @@ impl EditorView {
170170 theme: &Theme,
171171 ) {
172172 let editor_rulers = &editor.config().rulers;
173− let ruler_theme = theme.get("ui.virtual.ruler");
173+ let ruler_theme = theme
174+ .try_get("ui.virtual.ruler")
175+ .unwrap_or_else(|| Style::default().bg(Color::Red));
174176
175177 let rulers = doc
176178 .language_config()
@@ -1046,7 +1048,7 @@ impl EditorView {
10461048
10471049 let mut selection = doc.selection(view.id).clone();
10481050 let primary = selection.primary_mut();
1049− *primary = Range::new(primary.anchor, pos);
1051+ *primary = primary.put_cursor(doc.text().slice(..), pos, true);
10501052 doc.set_selection(view.id, selection);
10511053 EventResult::Consumed(None)
10521054 }
helix-view/src/gutter.rs+12−1
@@ -26,7 +26,18 @@ pub fn diagnostic<'doc>(
2626 Box::new(move |line: usize, _selected: bool, out: &mut String| {
2727 use helix_core::diagnostic::Severity;
2828 if let Ok(index) = diagnostics.binary_search_by_key(&line, |d| d.line) {
29− let diagnostic = &diagnostics[index];
29+ let after = diagnostics[index..].iter().take_while(|d| d.line == line);
30+
31+ let before = diagnostics[..index]
32+ .iter()
33+ .rev()
34+ .take_while(|d| d.line == line);
35+
36+ let diagnostics_on_line = after.chain(before);
37+
38+ // This unwrap is safe because the iterator cannot be empty as it contains at least the item found by the binary search.
39+ let diagnostic = diagnostics_on_line.max_by_key(|d| d.severity).unwrap();
40+
3041 write!(out, "●").unwrap();
3142 return Some(match diagnostic.severity {
3243 Some(Severity::Error) => error,
helix-view/src/view.rs+12−41
@@ -1,15 +1,9 @@
1−use std::borrow::Cow;
2−
31use crate::{
42 graphics::Rect,
53 gutter::{self, Gutter},
64 Document, DocumentId, ViewId,
75};
8−use helix_core::{
9− graphemes::{grapheme_width, RopeGraphemes},
10− line_ending::line_end_char_index,
11− visual_coords_at_pos, Position, RopeSlice, Selection,
12−};
6+use helix_core::{pos_at_visual_coords, visual_coords_at_pos, Position, RopeSlice, Selection};
137
148use std::fmt;
159
@@ -251,44 +245,21 @@ impl View {
251245 return None;
252246 }
253247
254− let line_number = (row - inner.y) as usize + self.offset.row;
255−
256− if line_number > text.len_lines() - 1 {
248+ let text_row = (row - inner.y) as usize + self.offset.row;
249+ if text_row > text.len_lines() - 1 {
257250 return Some(text.len_chars());
258251 }
259252
260− let mut pos = text.line_to_char(line_number);
261−
262− let current_line = text.line(line_number);
263−
264− let target = (column - inner.x) as usize + self.offset.col;
265− let mut col = 0;
266−
267− // TODO: extract this part as pos_at_visual_coords
268− for grapheme in RopeGraphemes::new(current_line) {
269− if col >= target {
270− break;
271− }
272−
273− let width = if grapheme == "\t" {
274− tab_width - (col % tab_width)
275− } else {
276− let grapheme = Cow::from(grapheme);
277− grapheme_width(&grapheme)
278− };
279−
280− // If pos is in the middle of a wider grapheme (tab for example)
281− // return the starting offset.
282− if col + width > target {
283− break;
284− }
253+ let text_col = (column - inner.x) as usize + self.offset.col;
285254
286− col += width;
287− // TODO: use byte pos that converts back to char pos?
288− pos += grapheme.chars().count();
289− }
290−
291− Some(pos.min(line_end_char_index(&text.slice(..), line_number)))
255+ Some(pos_at_visual_coords(
256+ *text,
257+ Position {
258+ row: text_row,
259+ col: text_col,
260+ },
261+ tab_width,
262+ ))
292263 }
293264
294265 /// Translates a screen position to position in the text document.
runtime/queries/elixir/textobjects.scm+7−1
@@ -16,7 +16,7 @@
1616 (pair
1717 value: (_) @function.inside))?)?
1818 (do_block (_)* @function.inside)?)
19− (#match? @_keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp|test|describe|setup)$")) @function.around
19+ (#match? @_keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$")) @function.around
2020
2121(anonymous_function
2222 (stab_clause right: (body) @function.inside)) @function.around
@@ -25,3 +25,9 @@
2525 target: (identifier) @_keyword
2626 (do_block (_)* @class.inside))
2727 (#match? @_keyword "^(defmodule|defprotocol|defimpl)$")) @class.around
28+
29+((call
30+ target: (identifier) @_keyword
31+ (arguments ((string) . (_)?))
32+ (do_block (_)* @test.inside)?)
33+ (#match? @_keyword "^(test|describe)$")) @test.around
runtime/queries/erlang/textobjects.scm+8
@@ -6,3 +6,11 @@
66 (stab_clause body: (_) @function.inside)) @function.around
77
88(comment (comment_content) @comment.inside) @comment.around
9+
10+; EUnit test names.
11+; (CommonTest cases are not recognizable by syntax alone.)
12+((function_clause
13+ name: (atom) @_name
14+ pattern: (arguments (_)? @parameter.inside)
15+ body: (_) @test.inside) @test.around
16+ (#match? @_name "_test$"))
runtime/queries/gleam/textobjects.scm+5
@@ -4,3 +4,8 @@
44
55(anonymous_function
66 body: (function_body) @function.inside) @function.around
7+
8+((function
9+ name: (identifier) @_name
10+ body: (function_body) @test.inside) @test.around
11+ (#match? @_name "_test$"))
runtime/queries/go/textobjects.scm+5
@@ -26,3 +26,8 @@
2626(comment) @comment.inside
2727
2828(comment)+ @comment.around
29+
30+((function_declaration
31+ name: (identifier) @_name
32+ body: (block)? @test.inside) @test.around
33+ (#match? @_name "^Test"))
runtime/queries/javascript/injections.scm+10−2
@@ -22,7 +22,15 @@
2222((regex_pattern) @injection.content
2323 (#set! injection.language "regex"))
2424
25− ; Parse JSDoc annotations in comments
25+; Parse JSDoc annotations in multiline comments
2626
2727((comment) @injection.content
28− (#set! injection.language "jsdoc"))
28+ (#set! injection.language "jsdoc")
29+ (#match? @injection.content "^/\\*+"))
30+
31+; Parse general tags in single line comments
32+
33+((comment) @injection.content
34+ (#set! injection.language "comment")
35+ (#match? @injection.content "^//"))
36+
runtime/queries/jsdoc/injections.scmnew file+5
@@ -0,0 +1,5 @@
1+; Parse general comment tags
2+
3+((document) @injection.content
4+ (#set! injection.include-children)
5+ (#set! injection.language "comment"))
runtime/queries/python/textobjects.scm+5
@@ -16,3 +16,8 @@
1616(comment) @comment.inside
1717
1818(comment)+ @comment.around
19+
20+((function_definition
21+ name: (identifier) @_name
22+ body: (block)? @test.inside) @test.around
23+ (#match? @_name "^test_"))
runtime/queries/rust/textobjects.scm+14
@@ -77,3 +77,17 @@
7777(line_comment)+ @comment.around
7878
7979(block_comment) @comment.around
80+
81+(; #[test]
82+ (attribute_item
83+ (meta_item
84+ (identifier) @_test_attribute))
85+ ; allow other attributes like #[should_panic] and comments
86+ [
87+ (attribute_item)
88+ (line_comment)
89+ ]*
90+ ; the test function
91+ (function_item
92+ body: (_) @test.inside) @test.around
93+ (#eq? @_test_attribute "test"))
runtime/themes/base16_default_dark.toml+1−1
@@ -1,7 +1,7 @@
11# Author: RayGervais <raygervais@hotmail.ca>
22
33"ui.background" = { bg = "base00" }
4−"ui.virtual" = "base03"
4+"ui.virtual.whitespace" = "base03"
55"ui.menu" = { fg = "base05", bg = "base01" }
66"ui.menu.selected" = { fg = "base01", bg = "base04" }
77"ui.linenr" = { fg = "base03", bg = "base01" }
runtime/themes/base16_default_light.toml+1−1
@@ -12,7 +12,7 @@
1212"ui.statusline" = { fg = "base04", bg = "base01" }
1313"ui.cursor" = { fg = "base04", modifiers = ["reversed"] }
1414"ui.cursor.primary" = { fg = "base05", modifiers = ["reversed"] }
15−"ui.virtual" = "base03"
15+"ui.virtual.whitespace" = "base03"
1616"ui.text" = "base05"
1717"operator" = "base05"
1818"ui.text.focus" = "base05"
runtime/themes/base16_terminal.toml+1−1
@@ -13,7 +13,7 @@
1313"ui.help" = { fg = "white", bg = "black" }
1414"ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] }
1515"ui.cursor.primary" = { fg = "light-gray", modifiers = ["reversed"] }
16−"ui.virtual" = "light-gray"
16+"ui.virtual.whitespace" = "light-gray"
1717"variable" = "light-red"
1818"constant.numeric" = "yellow"
1919"constant" = "yellow"
runtime/themes/bogster.toml+1−1
@@ -53,7 +53,7 @@
5353
5454"ui.text" = { fg = "#e5ded6" }
5555"ui.text.focus" = { fg = "#e5ded6", modifiers= ["bold"] }
56−"ui.virtual" = "#627d9d"
56+"ui.virtual.whitespace" = "#627d9d"
5757
5858"ui.selection" = { bg = "#313f4e" }
5959# "ui.cursor.match" # TODO might want to override this because dimmed is not widely supported
runtime/themes/boo_berry.toml+1−1
@@ -44,7 +44,7 @@
4444"ui.menu" = { fg = "lilac", bg = "berry_saturated" }
4545"ui.menu.selected" = { fg = "mint", bg = "berry_saturated" }
4646"ui.selection" = { bg = "berry_saturated" }
47−"ui.virtual" = { fg = "berry_desaturated" }
47+"ui.virtual.whitespace" = { fg = "berry_desaturated" }
4848
4949"diff.plus" = { fg = "mint" }
5050"diff.delta" = { fg = "gold" }
runtime/themes/catppuccin.toml+1−1
@@ -48,7 +48,7 @@ label = "peach"
4848
4949"ui.text" = { fg = "pink" }
5050"ui.text.focus" = { fg = "white" }
51−"ui.virtual" = { fg = "gray_0" }
51+"ui.virtual.whitespace" = { fg = "gray_0" }
5252
5353"ui.selection" = { bg = "#540099" }
5454"ui.selection.primary" = { bg = "#540099" }
runtime/themes/dark_plus.toml+1−1
@@ -78,7 +78,7 @@
7878"ui.text" = { fg = "text" }
7979"ui.text.focus" = { fg = "white" }
8080
81−"ui.virtual" = { fg = "dark_gray" }
81+"ui.virtual.whitespace" = { fg = "dark_gray" }
8282"ui.virtual.ruler" = { bg = "borders" }
8383
8484"warning" = { fg = "gold2" }
runtime/themes/dracula.toml+1−1
@@ -36,7 +36,7 @@
3636"ui.text" = { fg = "foreground" }
3737"ui.text.focus" = { fg = "cyan" }
3838"ui.window" = { fg = "foreground" }
39−"ui.virtual" = { fg = "comment" }
39+"ui.virtual.whitespace" = { fg = "comment" }
4040
4141"error" = { fg = "red" }
4242"warning" = { fg = "cyan" }
runtime/themes/everforest_dark.toml+1−1
@@ -70,7 +70,7 @@
7070"ui.menu" = { fg = "fg", bg = "bg2" }
7171"ui.menu.selected" = { fg = "bg0", bg = "green" }
7272"ui.selection" = { bg = "bg3" }
73−"ui.virtual" = "grey0"
73+"ui.virtual.whitespace" = "grey0"
7474
7575"hint" = "blue"
7676"info" = "aqua"
runtime/themes/everforest_light.toml+1−1
@@ -70,7 +70,7 @@
7070"ui.menu" = { fg = "fg", bg = "bg2" }
7171"ui.menu.selected" = { fg = "bg0", bg = "green" }
7272"ui.selection" = { bg = "bg3" }
73−"ui.virtual" = "grey0"
73+"ui.virtual.whitespace" = "grey0"
7474
7575"hint" = "blue"
7676"info" = "aqua"
runtime/themes/gruvbox.toml+1−1
@@ -53,7 +53,7 @@
5353"ui.cursor.match" = { bg = "bg2" }
5454"ui.menu" = { fg = "fg1", bg = "bg2" }
5555"ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] }
56−"ui.virtual" = "bg2"
56+"ui.virtual.whitespace" = "bg2"
5757
5858"diagnostic" = { modifiers = ["underlined"] }
5959
runtime/themes/gruvbox_light.toml+1−1
@@ -54,7 +54,7 @@
5454"ui.cursor.match" = { bg = "bg2" }
5555"ui.menu" = { fg = "fg1", bg = "bg2" }
5656"ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] }
57−"ui.virtual" = "bg2"
57+"ui.virtual.whitespace" = "bg2"
5858
5959"diagnostic" = { modifiers = ["underlined"] }
6060
runtime/themes/ingrid.toml+1−1
@@ -53,7 +53,7 @@
5353
5454"ui.text" = { fg = "#7B91B3" }
5555"ui.text.focus" = { fg = "#250E07", modifiers= ["bold"] }
56−"ui.virtual" = "#A6B6CE"
56+"ui.virtual.whitespace" = "#A6B6CE"
5757
5858"ui.selection" = { bg = "#540099" }
5959# "ui.cursor.match" # TODO might want to override this because dimmed is not widely supported
runtime/themes/monokai.toml+1−1
@@ -32,7 +32,7 @@
3232"attribute" = { fg = "fn_declaration" }
3333
3434"comment" = { fg = "#88846F" }
35−"ui.virtual" = "#88846F"
35+"ui.virtual.whitespace" = "#88846F"
3636
3737"string" = { fg = "#e6db74" }
3838"constant.character" = { fg = "#e6db74" }
runtime/themes/monokai_pro.toml+1−1
@@ -6,7 +6,7 @@
66"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
77"ui.menu" = { fg = "base8", bg = "base3" }
88"ui.menu.selected" = { fg = "base2", bg = "yellow" }
9−"ui.virtual" = "base5"
9+"ui.virtual.whitespace" = "base5"
1010
1111"info" = "base8"
1212"hint" = "base8"
runtime/themes/monokai_pro_machine.toml+1−1
@@ -6,7 +6,7 @@
66"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
77"ui.menu" = { fg = "base8", bg = "base3" }
88"ui.menu.selected" = { fg = "base2", bg = "yellow" }
9−"ui.virtual" = "base5"
9+"ui.virtual.whitespace" = "base5"
1010
1111"info" = "base8"
1212"hint" = "base8"
runtime/themes/monokai_pro_octagon.toml+1−1
@@ -6,7 +6,7 @@
66"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
77"ui.menu" = { fg = "base8", bg = "base3" }
88"ui.menu.selected" = { fg = "base2", bg = "yellow" }
9−"ui.virtual" = "base5"
9+"ui.virtual.whitespace" = "base5"
1010
1111"info" = "base8"
1212"hint" = "base8"
runtime/themes/monokai_pro_ristretto.toml+1−1
@@ -6,7 +6,7 @@
66"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
77"ui.menu" = { fg = "base8", bg = "base3" }
88"ui.menu.selected" = { fg = "base2", bg = "yellow" }
9−"ui.virtual" = "base5"
9+"ui.virtual.whitespace" = "base5"
1010
1111"info" = "base8"
1212"hint" = "base8"
runtime/themes/monokai_pro_spectrum.toml+1−1
@@ -6,7 +6,7 @@
66"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
77"ui.menu" = { fg = "base8", bg = "base3" }
88"ui.menu.selected" = { fg = "base2", bg = "yellow" }
9−"ui.virtual" = "base5"
9+"ui.virtual.whitespace" = "base5"
1010
1111"info" = "base8"
1212"hint" = "base8"
runtime/themes/noctis_bordo.tomlnew file+80
@@ -0,0 +1,80 @@
1+# Author: Joseph Harrison-Lim <josephharrisonlim@gmail.com>
2+
3+"attributes" = { fg = "#7060eb", modifiers = ["bold"] }
4+"comment" = { fg = "base03", modifiers = ["italic"] }
5+"comment.block.documentation" = { fg = "base06", modifiers = ["italic"] }
6+"constant" = "base09"
7+"constant.character.escape" = "base0C"
8+"constant.numeric" = "#7060eb"
9+"constructor" = "base0D"
10+"function" = "base0D"
11+"keyword" = "base0E"
12+"keyword.control" = { fg = "base0E", modifiers = ["bold"] }
13+"keyword.directive" = "white"
14+"keyword.import" = { fg = "#df769b" }
15+"keyword.operator" = { fg = "base0E", modifiers = ["italic"] }
16+"label" = "base0E"
17+"namespace" = "base0E"
18+"operator" = "base05"
19+"string" = "base0B"
20+"type" = "base10"
21+"variable" = "base08"
22+"variable.other.member" = "base08"
23+"special" = "base0D"
24+
25+"ui.background" = { bg = "base00" }
26+"ui.virtual" = "base03"
27+"ui.menu" = { fg = "base05", bg = "base01" }
28+"ui.menu.selected" = { fg = "base0B", bg = "base01" }
29+"ui.popup" = { bg = "base01" }
30+"ui.window" = { bg = "base01" }
31+"ui.linenr" = { fg = "#715b63", bg = "base01" }
32+"ui.linenr.selected" = { fg = "base02", bg = "base01", modifiers = ["bold"] }
33+"ui.selection" = { fg = "base05", bg = "base02" }
34+"ui.statusline" = { fg = "base02", bg = "base01" }
35+"ui.cursor" = { fg = "base04", modifiers = ["reversed"] }
36+"ui.cursor.primary" = { fg = "base05", modifiers = ["reversed"] }
37+"ui.text" = "base05"
38+"ui.text.focus" = "base05"
39+"ui.cursor.match" = { fg = "base0A", modifiers = ["underlined"] }
40+"ui.help" = { fg = "base06", bg = "base01" }
41+
42+"markup.bold" = { fg = "base0A", modifiers = ["bold"] }
43+"markup.heading" = "base0D"
44+"markup.italic" = { fg = "base0E", modifiers = ["italic"] }
45+"markup.link.text" = "base08"
46+"markup.link.url" = { fg = "base09", modifiers = ["underlined"] }
47+"markup.list" = "base08"
48+"markup.quote" = "base0C"
49+"markup.raw" = "base0B"
50+
51+"diff.delta" = "base09"
52+"diff.plus" = "base0B"
53+"diff.minus" = "base08"
54+
55+"diagnostic" = { modifiers = ["underlined"] }
56+"ui.gutter" = { bg = "base01" }
57+"info" = "base0D"
58+"hint" = "base03"
59+"debug" = "base03"
60+"warning" = "base09"
61+"error" = "base08"
62+
63+[palette]
64+base00 = "#322a2d" # Default Background
65+base01 = "#2c2528" # Lighter Background (Used for status bars, line number and folding marks)
66+base02 = "#997582" # Selection Background
67+base03 = "#585858" # Comments, Invisibles, Line Highlighting
68+base04 = "#322a2d" # Dark Foreground (Used for status bars)
69+base05 = "#cbbec2" # Default Foreground, Caret, Delimiters, Operators
70+base06 = "#e8e8e8" # Light Foreground (Not often used)
71+base07 = "#f8f8f8" # Light Background (Not often used)
72+base08 = "#e4b781" # Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted
73+base09 = "#d5971a" # Integers, Boolean, Constants, XML Attributes, Markup Link Url
74+base0A = "#df769b" # Classes, Markup Bold, Search Text Background
75+base0B = "#49e9a6" # Strings, Inherited Class, Markup Code, Diff Inserted
76+base0C = "#16b673" # Support, Regular Expressions, Escape Characters, Markup Quotes
77+base0D = "#16a3b6" # Functions, Methods, Attribute IDs, Headings
78+base0E = "#ba8baf" # Keywords, Storage, Selector, Markup Italic, Diff Changed
79+base0F = "#d67e5c" # Deprecated, Opening/Closing Embedded Language Tags, e.g. <?php ?>
80+base10 = "#b0b0ff" # Types
runtime/themes/nord.toml+1−1
@@ -4,7 +4,7 @@
44"ui.text.focus" = { fg = "nord8", modifiers= ["bold"] }
55"ui.menu" = { fg = "nord6", bg = "#232d38" }
66"ui.menu.selected" = { fg = "nord8", bg = "nord2" }
7−"ui.virtual" = "gray"
7+"ui.virtual.whitespace" = "gray"
88
99"info" = "nord8"
1010"hint" = "nord8"
runtime/themes/rose_pine.toml+1−1
@@ -14,7 +14,7 @@
1414"ui.text" = { fg = "text" }
1515"ui.text.focus" = { fg = "foam", modifiers = ["bold"]}
1616"ui.text.info" = {fg = "pine", modifiers = ["bold"]}
17−"ui.virtual" = "highlight"
17+"ui.virtual.whitespace" = "highlight"
1818"operator" = "rose"
1919"variable" = "text"
2020"constant.numeric" = "iris"
runtime/themes/rose_pine_dawn.toml+1−1
@@ -14,7 +14,7 @@
1414"ui.text" = { fg = "text" }
1515"ui.text.focus" = { fg = "foam", modifiers = ["bold"]}
1616"ui.text.info" = {fg = "pine", modifiers = ["bold"]}
17−"ui.virtual" = "highlight"
17+"ui.virtual.whitespace" = "highlight"
1818"operator" = "rose"
1919"variable" = "text"
2020"number" = "iris"
runtime/themes/serika-dark.toml+1−1
@@ -50,7 +50,7 @@
5050"ui.menu" = { fg = "fg", bg = "bg2" }
5151"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
5252"ui.selection" = { bg = "bg3" }
53−"ui.virtual" = "grey2"
53+"ui.virtual.whitespace" = "grey2"
5454
5555"hint" = "blue"
5656"info" = "aqua"
runtime/themes/serika-light.toml+1−1
@@ -50,7 +50,7 @@
5050"ui.menu" = { fg = "bg0", bg = "bg3" }
5151"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
5252"ui.selection" = { fg = "bg0", bg = "bg3" }
53−"ui.virtual" = { fg = "bg2" }
53+"ui.virtual.whitespace" = { fg = "bg2" }
5454
5555"hint" = "blue"
5656"info" = "aqua"
runtime/themes/snazzy.toml+1−1
@@ -38,7 +38,7 @@
3838"ui.text" = { fg = "foreground" }
3939"ui.text.focus" = { fg = "cyan" }
4040"ui.window" = { fg = "foreground" }
41−"ui.virtual" = { fg = "comment" }
41+"ui.virtual.whitespace" = { fg = "comment" }
4242
4343"error" = { fg = "red" }
4444"warning" = { fg = "cyan" }
runtime/themes/solarized_dark.toml+1−1
@@ -39,7 +39,7 @@
3939# 背景
4040"ui.background" = { bg = "base03" }
4141
42−"ui.virtual" = { fg = "base01" }
42+"ui.virtual.whitespace" = { fg = "base01" }
4343
4444# 行号栏
4545"ui.linenr" = { fg = "base0", bg = "base02" }
runtime/themes/solarized_light.toml+1−1
@@ -40,7 +40,7 @@
4040# background
4141"ui.background" = { bg = "base03" }
4242
43−"ui.virtual" = { fg = "base01" }
43+"ui.virtual.whitespace" = { fg = "base01" }
4444
4545# 行号栏
4646# line number column
runtime/themes/spacebones_light.toml+1−1
@@ -64,7 +64,7 @@
6464"ui.cursor.match" = { bg = "bg3" }
6565"ui.menu" = { fg = "fg1", bg = "bg2" }
6666"ui.menu.selected" = { fg = "#655370", bg = "#d1dcdf", modifiers = ["bold"] }
67−"ui.virtual" = "bg2"
67+"ui.virtual.whitespace" = "bg2"
6868
6969"diagnostic" = { modifiers = ["underlined"] }
7070