on master help sign in
Merge branch 'master' into test-harness
458b89eBlaž Hrastnik
Cargo.lock+2−2
@@ -13,9 +13,9 @@ dependencies = [
13
13
14[[package]]
14[[package]]
15name = "anyhow"
15name = "anyhow"
16−version = "1.0.53"
16+version = "1.0.58"
17source = "registry+https://github.com/rust-lang/crates.io-index"
17source = "registry+https://github.com/rust-lang/crates.io-index"
18−checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
18+checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
19
19
20[[package]]
20[[package]]
21name = "arc-swap"
21name = "arc-swap"
book/src/guides/adding_languages.md+7−60
@@ -2,40 +2,8 @@
2
2
3## Language configuration
3## Language configuration
4
4
5−To add a new language, you need to add a `language` entry to the
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;
6+`languages.toml` (see the [language configuration section]).
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`) |
39
7
40When adding a new language or Language Server configuration for an existing
8When adding a new language or Language Server configuration for an existing
41language, run `cargo xtask docgen` to add the new configuration to the
9language, 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
45
13
46## Grammar configuration
14## Grammar configuration
47
15
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]]`
49entry to `languages.toml`.
17entry to `languages.toml`.
50
18
51−```toml
19+You may use the `source.path` key rather than `source.git` with an absolute path
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.
20+to a locally available grammar for testing, but switch to `source.git` before
21+submitting a pull request.
74
22
75## Queries
23## Queries
76
24
@@ -91,8 +39,7 @@ the last matching query supersedes the ones before it. See
91
39
92- If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so`
40- If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so`
93
41
94−[treesitter-language-injection]: https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection
42+[language configuration section]: ../languages.md
95−[languages.toml]: https://github.com/helix-editor/helix/blob/master/languages.toml
96[neovim-query-precedence]: https://github.com/helix-editor/helix/pull/1170#issuecomment-997294090
43[neovim-query-precedence]: https://github.com/helix-editor/helix/pull/1170#issuecomment-997294090
97[install-lsp-wiki]: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers
44[install-lsp-wiki]: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers
98[lang-support]: ../lang-support.md
45[lang-support]: ../lang-support.md
book/src/guides/textobject.md+2
@@ -20,6 +20,8 @@ The following [captures][tree-sitter-captures] are recognized:
20| `function.around` |
20| `function.around` |
21| `class.inside` |
21| `class.inside` |
22| `class.around` |
22| `class.around` |
23+| `test.inside` |
24+| `test.around` |
23| `parameter.inside` |
25| `parameter.inside` |
24| `comment.inside` |
26| `comment.inside` |
25| `comment.around` |
27| `comment.around` |
book/src/keymap.md+2
@@ -282,6 +282,8 @@ Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaire
282| `[a` | Go to previous argument/parameter (**TS**) | `goto_prev_parameter` |
282| `[a` | Go to previous argument/parameter (**TS**) | `goto_prev_parameter` |
283| `]o` | Go to next comment (**TS**) | `goto_next_comment` |
283| `]o` | Go to next comment (**TS**) | `goto_next_comment` |
284| `[o` | Go to previous comment (**TS**) | `goto_prev_comment` |
284| `[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` |
285| `]p` | Go to next paragraph | `goto_next_paragraph` |
287| `]p` | Go to next paragraph | `goto_next_paragraph` |
286| `[p` | Go to previous paragraph | `goto_prev_paragraph` |
288| `[p` | Go to previous paragraph | `goto_prev_paragraph` |
287| `[space` | Add newline above | `add_newline_above` |
289| `[space` | Add newline above | `add_newline_above` |
book/src/languages.md+90−16
@@ -1,10 +1,17 @@
1# Languages
1# Languages
2
2
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.
4
5
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
6
7
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:
8
15
9```toml
16```toml
10# in <config_dir>/helix/languages.toml
17# in <config_dir>/helix/languages.toml
@@ -14,9 +21,60 @@ name = "rust"
14auto-format = false
21auto-format = false
15```
22```
16
23
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
18
30
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
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).
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:
20
78
21```toml
79```toml
22[[language]]
80[[language]]
@@ -26,23 +84,37 @@ auto-format = true
26config = { format = { "semicolons" = "insert", "insertSpaceBeforeFunctionParenthesis" = true } }
84config = { format = { "semicolons" = "insert", "insertSpaceBeforeFunctionParenthesis" = true } }
27```
85```
28
86
29−## Tree-sitter grammars
87+## Tree-sitter grammar configuration
30
88
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:
32
91
33```toml
92```toml
34−# in <config_dir>/helix/languages.toml
35−
36[[grammar]]
93[[grammar]]
37−name = "rust"
94+name = "mylang"
38−source = { git = "https://github.com/tree-sitter/tree-sitter-rust", rev = "a250c4582510ff34767ec3b7dcdd3c24e8c8aa68" }
95+source = { git = "https://github.com/example/mylang", rev = "a250c4582510ff34767ec3b7dcdd3c24e8c8aa68" }
39−
40−[[grammar]]
41−name = "c"
42−source = { path = "/path/to/tree-sitter-c" }
43```
96```
44
97
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+
45−You may use a top-level `use-grammars` key to control which grammars are fetched and built.
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`.
46
118
47```toml
119```toml
48# Note: this key must come **before** the [[language]] and [[grammar]] sections
120# Note: this key must come **before** the [[language]] and [[grammar]] sections
@@ -52,3 +124,5 @@ use-grammars = { except = [ "yaml", "json" ] }
52```
124```
53
125
54When omitted, all grammars are fetched and built.
126When 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`.
143| `c` | Class |
143| `c` | Class |
144| `a` | Argument/parameter |
144| `a` | Argument/parameter |
145| `o` | Comment |
145| `o` | Comment |
146+| `t` | Test |
146
147
147> NOTE: `f`, `c`, etc need a tree-sitter grammar active for the current
148> NOTE: `f`, `c`, etc need a tree-sitter grammar active for the current
148document and a special tree-sitter query file to work properly. [Only
149document 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>;
63pub use {regex, tree_sitter};
63pub use {regex, tree_sitter};
64
64
65pub use graphemes::RopeGraphemes;
65pub use graphemes::RopeGraphemes;
66+pub use position::{
66−pub use position::{coords_at_pos, pos_at_coords, visual_coords_at_pos, Position};
67+ coords_at_pos, pos_at_coords, pos_at_visual_coords, visual_coords_at_pos, Position,
68+};
67pub use selection::{Range, Selection};
69pub use selection::{Range, Selection};
68pub use smallvec::{smallvec, SmallVec};
70pub use smallvec::{smallvec, SmallVec};
69pub use syntax::Syntax;
71pub use syntax::Syntax;
helix-core/src/movement.rs+21−22
@@ -5,16 +5,15 @@ use tree_sitter::{Node, QueryCursor};
5
5
6use crate::{
6use crate::{
7 chars::{categorize_char, char_is_line_ending, CharCategory},
7 chars::{categorize_char, char_is_line_ending, CharCategory},
8− coords_at_pos,
9 graphemes::{
8 graphemes::{
10 next_grapheme_boundary, nth_next_grapheme_boundary, nth_prev_grapheme_boundary,
9 next_grapheme_boundary, nth_next_grapheme_boundary, nth_prev_grapheme_boundary,
11 prev_grapheme_boundary,
10 prev_grapheme_boundary,
12 },
11 },
13 line_ending::rope_is_line_ending,
12 line_ending::rope_is_line_ending,
14− pos_at_coords,
13+ pos_at_visual_coords,
15 syntax::LanguageConfiguration,
14 syntax::LanguageConfiguration,
16 textobject::TextObject,
15 textobject::TextObject,
17− Position, Range, RopeSlice,
16+ visual_coords_at_pos, Position, Range, RopeSlice,
18};
17};
19
18
20#[derive(Debug, Copy, Clone, PartialEq, Eq)]
19#[derive(Debug, Copy, Clone, PartialEq, Eq)]
@@ -35,6 +34,7 @@ pub fn move_horizontally(
35 dir: Direction,
34 dir: Direction,
36 count: usize,
35 count: usize,
37 behaviour: Movement,
36 behaviour: Movement,
37+ _: usize,
38) -> Range {
38) -> Range {
39 let pos = range.cursor(slice);
39 let pos = range.cursor(slice);
40
40
@@ -54,15 +54,12 @@ pub fn move_vertically(
54 dir: Direction,
54 dir: Direction,
55 count: usize,
55 count: usize,
56 behaviour: Movement,
56 behaviour: Movement,
57+ tab_width: usize,
57) -> Range {
58) -> Range {
58 let pos = range.cursor(slice);
59 let pos = range.cursor(slice);
59
60
60 // Compute the current position's 2d coordinates.
61 // 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);
66 let horiz = range.horiz.unwrap_or(col as u32);
63 let horiz = range.horiz.unwrap_or(col as u32);
67
64
68 // Compute the new position.
65 // Compute the new position.
@@ -71,7 +68,7 @@ pub fn move_vertically(
71 Direction::Backward => row.saturating_sub(count),
68 Direction::Backward => row.saturating_sub(count),
72 };
69 };
73 let new_col = col.max(horiz as usize);
70 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);
75
72
76 // Special-case to avoid moving to the end of the last non-empty line.
73 // Special-case to avoid moving to the end of the last non-empty line.
77 if behaviour == Movement::Extend && slice.line(new_row).len_chars() == 0 {
74 if behaviour == Movement::Extend && slice.line(new_row).len_chars() == 0 {
@@ -446,6 +443,8 @@ pub fn goto_treesitter_object(
446mod test {
443mod test {
447 use ropey::Rope;
444 use ropey::Rope;
448
445
446+ use crate::{coords_at_pos, pos_at_coords};
447+
449 use super::*;
448 use super::*;
450
449
451 const SINGLE_LINE_SAMPLE: &str = "This is a simple alphabetic line";
450 const SINGLE_LINE_SAMPLE: &str = "This is a simple alphabetic line";
@@ -472,7 +471,7 @@ mod test {
472 assert_eq!(
471 assert_eq!(
473 coords_at_pos(
472 coords_at_pos(
474 slice,
473 slice,
475− move_vertically(slice, range, Direction::Forward, 1, Movement::Move).head
474+ move_vertically(slice, range, Direction::Forward, 1, Movement::Move, 4).head
476 ),
475 ),
477 (1, 3).into()
476 (1, 3).into()
478 );
477 );
@@ -496,7 +495,7 @@ mod test {
496 ];
495 ];
497
496
498 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
497 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);
500 assert_eq!(coords_at_pos(slice, range.head), coordinates.into())
499 assert_eq!(coords_at_pos(slice, range.head), coordinates.into())
501 }
500 }
502 }
501 }
@@ -522,7 +521,7 @@ mod test {
522 ];
521 ];
523
522
524 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
523 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);
526 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
525 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
527 assert_eq!(range.head, range.anchor);
526 assert_eq!(range.head, range.anchor);
528 }
527 }
@@ -544,7 +543,7 @@ mod test {
544 ];
543 ];
545
544
546 for (direction, amount) in moves {
545 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);
548 assert_eq!(range.anchor, original_anchor);
547 assert_eq!(range.anchor, original_anchor);
549 }
548 }
550 }
549 }
@@ -568,7 +567,7 @@ mod test {
568 ];
567 ];
569
568
570 for ((direction, amount), coordinates) in moves_and_expected_coordinates {
569 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);
572 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
571 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
573 assert_eq!(range.head, range.anchor);
572 assert_eq!(range.head, range.anchor);
574 }
573 }
@@ -602,8 +601,8 @@ mod test {
602
601
603 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
602 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
604 range = match axis {
603 range = match axis {
605− Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move),
604+ Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move, 0),
606− Axis::V => move_vertically(slice, range, direction, amount, Movement::Move),
605+ Axis::V => move_vertically(slice, range, direction, amount, Movement::Move, 4),
607 };
606 };
608 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
607 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
609 assert_eq!(range.head, range.anchor);
608 assert_eq!(range.head, range.anchor);
@@ -627,18 +626,18 @@ mod test {
627 let moves_and_expected_coordinates = [
626 let moves_and_expected_coordinates = [
628 // Places cursor at the fourth kana.
627 // Places cursor at the fourth kana.
629 ((Axis::H, Direction::Forward, 4), (0, 4)),
628 ((Axis::H, Direction::Forward, 4), (0, 4)),
630− // Descent places cursor at the 4th character.
629+ // Descent places cursor at the 8th character.
631− ((Axis::V, Direction::Forward, 1usize), (1, 4)),
630+ ((Axis::V, Direction::Forward, 1usize), (1, 8)),
632− // Moving back 1 character.
631+ // Moving back 2 characters.
633− ((Axis::H, Direction::Backward, 1usize), (1, 3)),
632+ ((Axis::H, Direction::Backward, 2usize), (1, 6)),
634 // Jumping back up 1 line.
633 // Jumping back up 1 line.
635 ((Axis::V, Direction::Backward, 1usize), (0, 3)),
634 ((Axis::V, Direction::Backward, 1usize), (0, 3)),
636 ];
635 ];
637
636
638 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
637 for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
639 range = match axis {
638 range = match axis {
640− Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move),
639+ Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move, 0),
641− Axis::V => move_vertically(slice, range, direction, amount, Movement::Move),
640+ Axis::V => move_vertically(slice, range, direction, amount, Movement::Move, 4),
642 };
641 };
643 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
642 assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
644 assert_eq!(range.head, range.anchor);
643 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
109/// with left-side block-cursor positions, as this prevents the the block cursor
109/// with left-side block-cursor positions, as this prevents the the block cursor
110/// from jumping to the next line. Otherwise you typically want it to be `false`,
110/// from jumping to the next line. Otherwise you typically want it to be `false`,
111/// such as when dealing with raw anchor/head positions.
111/// 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.
115pub fn pos_at_coords(text: RopeSlice, coords: Position, limit_before_line_ending: bool) -> usize {
112pub fn pos_at_coords(text: RopeSlice, coords: Position, limit_before_line_ending: bool) -> usize {
116 let Position { mut row, col } = coords;
113 let Position { mut row, col } = coords;
117 if limit_before_line_ending {
114 if limit_before_line_ending {
@@ -135,6 +132,43 @@ pub fn pos_at_coords(text: RopeSlice, coords: Position, limit_before_line_ending
135 line_start + col_char_offset
132 line_start + col_char_offset
136}
133}
137
134
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+
138#[cfg(test)]
172#[cfg(test)]
139mod test {
173mod test {
140 use super::*;
174 use super::*;
@@ -305,4 +339,70 @@ mod test {
305 assert_eq!(pos_at_coords(slice, (0, 10).into(), true), 0);
339 assert_eq!(pos_at_coords(slice, (0, 10).into(), true), 0);
306 assert_eq!(pos_at_coords(slice, (10, 10).into(), true), 0);
340 assert_eq!(pos_at_coords(slice, (10, 10).into(), true), 0);
307 }
341 }
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+ }
308}
408}
helix-term/src/commands.rs+26−12
@@ -16,14 +16,14 @@ use helix_core::{
16 line_ending::{get_line_ending_of_str, line_end_char_index, str_is_line_ending},
16 line_ending::{get_line_ending_of_str, line_end_char_index, str_is_line_ending},
17 match_brackets,
17 match_brackets,
18 movement::{self, Direction},
18 movement::{self, Direction},
19− object, pos_at_coords,
19+ object, pos_at_coords, pos_at_visual_coords,
20 regex::{self, Regex, RegexBuilder},
20 regex::{self, Regex, RegexBuilder},
21 search::{self, CharMatcher},
21 search::{self, CharMatcher},
22 selection, shellwords, surround, textobject,
22 selection, shellwords, surround, textobject,
23 tree_sitter::Node,
23 tree_sitter::Node,
24 unicode::width::UnicodeWidthChar,
24 unicode::width::UnicodeWidthChar,
25− LineEnding, Position, Range, Rope, RopeGraphemes, RopeSlice, Selection, SmallVec, Tendril,
25+ visual_coords_at_pos, LineEnding, Position, Range, Rope, RopeGraphemes, RopeSlice, Selection,
26− Transaction,
26+ SmallVec, Tendril, Transaction,
27};
27};
28use helix_view::{
28use helix_view::{
29 clipboard::ClipboardType,
29 clipboard::ClipboardType,
@@ -395,6 +395,8 @@ impl MappableCommand {
395 goto_prev_parameter, "Goto previous parameter",
395 goto_prev_parameter, "Goto previous parameter",
396 goto_next_comment, "Goto next comment",
396 goto_next_comment, "Goto next comment",
397 goto_prev_comment, "Goto previous comment",
397 goto_prev_comment, "Goto previous comment",
398+ goto_next_test, "Goto next test",
399+ goto_prev_test, "Goto previous test",
398 goto_next_paragraph, "Goto next paragraph",
400 goto_next_paragraph, "Goto next paragraph",
399 goto_prev_paragraph, "Goto previous paragraph",
401 goto_prev_paragraph, "Goto previous paragraph",
400 dap_launch, "Launch debug target",
402 dap_launch, "Launch debug target",
@@ -509,7 +511,7 @@ fn no_op(_cx: &mut Context) {}
509
511
510fn move_impl<F>(cx: &mut Context, move_fn: F, dir: Direction, behaviour: Movement)
512fn move_impl<F>(cx: &mut Context, move_fn: F, dir: Direction, behaviour: Movement)
511where
513where
512− F: Fn(RopeSlice, Range, Direction, usize, Movement) -> Range,
514+ F: Fn(RopeSlice, Range, Direction, usize, Movement, usize) -> Range,
513{
515{
514 let count = cx.count();
516 let count = cx.count();
515 let (view, doc) = current!(cx.editor);
517 let (view, doc) = current!(cx.editor);
@@ -518,7 +520,7 @@ where
518 let selection = doc
520 let selection = doc
519 .selection(view.id)
521 .selection(view.id)
520 .clone()
522 .clone()
521− .transform(|range| move_fn(text, range, dir, count, behaviour));
523+ .transform(|range| move_fn(text, range, dir, count, behaviour, doc.tab_width()));
522 doc.set_selection(view.id, selection);
524 doc.set_selection(view.id, selection);
523}
525}
524
526
@@ -1410,9 +1412,10 @@ fn copy_selection_on_line(cx: &mut Context, direction: Direction) {
1410 range.head
1412 range.head
1411 };
1413 };
1412
1414
1413− // TODO: this should use visual offsets / pos_at_screen_coords
1415+ let tab_width = doc.tab_width();
1416+
1414− let head_pos = coords_at_pos(text, head);
1417+ let head_pos = visual_coords_at_pos(text, head, tab_width);
1415− let anchor_pos = coords_at_pos(text, range.anchor);
1418+ let anchor_pos = visual_coords_at_pos(text, range.anchor, tab_width);
1416
1419
1417 let height = std::cmp::max(head_pos.row, anchor_pos.row)
1420 let height = std::cmp::max(head_pos.row, anchor_pos.row)
1418 - std::cmp::min(head_pos.row, anchor_pos.row)
1421 - std::cmp::min(head_pos.row, anchor_pos.row)
@@ -1442,12 +1445,13 @@ fn copy_selection_on_line(cx: &mut Context, direction: Direction) {
1442 break;
1445 break;
1443 }
1446 }
1444
1447
1448+ let anchor =
1445− let anchor = pos_at_coords(text, Position::new(anchor_row, anchor_pos.col), true);
1449+ pos_at_visual_coords(text, Position::new(anchor_row, anchor_pos.col), tab_width);
1446− let head = pos_at_coords(text, Position::new(head_row, head_pos.col), true);
1450+ let head = pos_at_visual_coords(text, Position::new(head_row, head_pos.col), tab_width);
1447
1451
1448 // skip lines that are too short
1452 // skip lines that are too short
1449− if coords_at_pos(text, anchor).col == anchor_pos.col
1453+ if visual_coords_at_pos(text, anchor, tab_width).col == anchor_pos.col
1450− && coords_at_pos(text, head).col == head_pos.col
1454+ && visual_coords_at_pos(text, head, tab_width).col == head_pos.col
1451 {
1455 {
1452 if is_primary {
1456 if is_primary {
1453 primary_index = ranges.len();
1457 primary_index = ranges.len();
@@ -4105,6 +4109,14 @@ fn goto_prev_comment(cx: &mut Context) {
4105 goto_ts_object_impl(cx, "comment", Direction::Backward)
4109 goto_ts_object_impl(cx, "comment", Direction::Backward)
4106}
4110}
4107
4111
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+
4108fn select_textobject_around(cx: &mut Context) {
4120fn select_textobject_around(cx: &mut Context) {
4109 select_textobject(cx, textobject::TextObject::Around);
4121 select_textobject(cx, textobject::TextObject::Around);
4110}
4122}
@@ -4148,6 +4160,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
4148 'f' => textobject_treesitter("function", range),
4160 'f' => textobject_treesitter("function", range),
4149 'a' => textobject_treesitter("parameter", range),
4161 'a' => textobject_treesitter("parameter", range),
4150 'o' => textobject_treesitter("comment", range),
4162 'o' => textobject_treesitter("comment", range),
4163+ 't' => textobject_treesitter("test", range),
4151 'p' => textobject::textobject_paragraph(text, range, objtype, count),
4164 'p' => textobject::textobject_paragraph(text, range, objtype, count),
4152 'm' => textobject::textobject_surround_closest(text, range, objtype, count),
4165 'm' => textobject::textobject_surround_closest(text, range, objtype, count),
4153 // TODO: cancel new ranges if inconsistent surround matches across lines
4166 // TODO: cancel new ranges if inconsistent surround matches across lines
@@ -4177,6 +4190,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
4177 ("f", "Function (tree-sitter)"),
4190 ("f", "Function (tree-sitter)"),
4178 ("a", "Argument/parameter (tree-sitter)"),
4191 ("a", "Argument/parameter (tree-sitter)"),
4179 ("o", "Comment (tree-sitter)"),
4192 ("o", "Comment (tree-sitter)"),
4193+ ("t", "Test (tree-sitter)"),
4180 ("m", "Matching delimiter under cursor"),
4194 ("m", "Matching delimiter under cursor"),
4181 (" ", "... or any character acting as a pair"),
4195 (" ", "... or any character acting as a pair"),
4182 ];
4196 ];
helix-term/src/health.rs+10−5
@@ -1,4 +1,7 @@
1+use crossterm::{
1−use crossterm::style::{Color, Print, Stylize};
2+ style::{Color, Print, Stylize},
3+ tty::IsTty,
4+};
2use helix_core::config::{default_syntax_loader, user_syntax_loader};
5use helix_core::config::{default_syntax_loader, user_syntax_loader};
3use helix_loader::grammar::load_runtime_file;
6use helix_loader::grammar::load_runtime_file;
4use std::io::Write;
7use std::io::Write;
@@ -106,17 +109,19 @@ pub fn languages_all() -> std::io::Result<()> {
106
109
107 let terminal_cols = crossterm::terminal::size().map(|(c, _)| c).unwrap_or(80);
110 let terminal_cols = crossterm::terminal::size().map(|(c, _)| c).unwrap_or(80);
108 let column_width = terminal_cols as usize / headings.len();
111 let column_width = terminal_cols as usize / headings.len();
112+ let is_terminal = std::io::stdout().is_tty();
109
113
110 let column = |item: &str, color: Color| {
114 let column = |item: &str, color: Color| {
111− let data = format!(
115+ let mut data = format!(
112 "{:width$}",
116 "{:width$}",
113 item.get(..column_width - 2)
117 item.get(..column_width - 2)
114 .map(|s| format!("{}…", s))
118 .map(|s| format!("{}…", s))
115 .unwrap_or_else(|| item.to_string()),
119 .unwrap_or_else(|| item.to_string()),
116 width = column_width,
120 width = column_width,
117− )
121+ );
118− .stylize()
122+ if is_terminal {
119− .with(color);
123+ data = data.stylize().with(color).to_string();
124+ }
120
125
121 // We can't directly use println!() because of
126 // We can't directly use println!() because of
122 // https://github.com/crossterm-rs/crossterm/issues/589
127 // 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> {
104 "c" => goto_prev_class,
104 "c" => goto_prev_class,
105 "a" => goto_prev_parameter,
105 "a" => goto_prev_parameter,
106 "o" => goto_prev_comment,
106 "o" => goto_prev_comment,
107+ "t" => goto_prev_test,
107 "p" => goto_prev_paragraph,
108 "p" => goto_prev_paragraph,
108 "space" => add_newline_above,
109 "space" => add_newline_above,
109 },
110 },
@@ -114,6 +115,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
114 "c" => goto_next_class,
115 "c" => goto_next_class,
115 "a" => goto_next_parameter,
116 "a" => goto_next_parameter,
116 "o" => goto_next_comment,
117 "o" => goto_next_comment,
118+ "t" => goto_next_test,
117 "p" => goto_next_paragraph,
119 "p" => goto_next_paragraph,
118 "space" => add_newline_below,
120 "space" => add_newline_below,
119 },
121 },
helix-term/src/ui/editor.rs+5−3
@@ -20,7 +20,7 @@ use helix_core::{
20use helix_view::{
20use helix_view::{
21 document::{Mode, SCRATCH_BUFFER_NAME},
21 document::{Mode, SCRATCH_BUFFER_NAME},
22 editor::{CompleteAction, CursorShapeConfig},
22 editor::{CompleteAction, CursorShapeConfig},
23− graphics::{CursorKind, Modifier, Rect, Style},
23+ graphics::{Color, CursorKind, Modifier, Rect, Style},
24 input::KeyEvent,
24 input::KeyEvent,
25 keyboard::{KeyCode, KeyModifiers},
25 keyboard::{KeyCode, KeyModifiers},
26 Document, Editor, Theme, View,
26 Document, Editor, Theme, View,
@@ -170,7 +170,9 @@ impl EditorView {
170 theme: &Theme,
170 theme: &Theme,
171 ) {
171 ) {
172 let editor_rulers = &editor.config().rulers;
172 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));
174
176
175 let rulers = doc
177 let rulers = doc
176 .language_config()
178 .language_config()
@@ -1046,7 +1048,7 @@ impl EditorView {
1046
1048
1047 let mut selection = doc.selection(view.id).clone();
1049 let mut selection = doc.selection(view.id).clone();
1048 let primary = selection.primary_mut();
1050 let primary = selection.primary_mut();
1049− *primary = Range::new(primary.anchor, pos);
1051+ *primary = primary.put_cursor(doc.text().slice(..), pos, true);
1050 doc.set_selection(view.id, selection);
1052 doc.set_selection(view.id, selection);
1051 EventResult::Consumed(None)
1053 EventResult::Consumed(None)
1052 }
1054 }
helix-view/src/gutter.rs+12−1
@@ -26,7 +26,18 @@ pub fn diagnostic<'doc>(
26 Box::new(move |line: usize, _selected: bool, out: &mut String| {
26 Box::new(move |line: usize, _selected: bool, out: &mut String| {
27 use helix_core::diagnostic::Severity;
27 use helix_core::diagnostic::Severity;
28 if let Ok(index) = diagnostics.binary_search_by_key(&line, |d| d.line) {
28 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+
30 write!(out, "●").unwrap();
41 write!(out, "●").unwrap();
31 return Some(match diagnostic.severity {
42 return Some(match diagnostic.severity {
32 Some(Severity::Error) => error,
43 Some(Severity::Error) => error,
helix-view/src/view.rs+12−41
@@ -1,15 +1,9 @@
1−use std::borrow::Cow;
2−
3use crate::{
1use crate::{
4 graphics::Rect,
2 graphics::Rect,
5 gutter::{self, Gutter},
3 gutter::{self, Gutter},
6 Document, DocumentId, ViewId,
4 Document, DocumentId, ViewId,
7};
5};
8−use helix_core::{
9− graphemes::{grapheme_width, RopeGraphemes},
10− line_ending::line_end_char_index,
11− visual_coords_at_pos, Position, RopeSlice, Selection,
6+use helix_core::{pos_at_visual_coords, visual_coords_at_pos, Position, RopeSlice, Selection};
12−};
13
7
14use std::fmt;
8use std::fmt;
15
9
@@ -251,44 +245,21 @@ impl View {
251 return None;
245 return None;
252 }
246 }
253
247
254− let line_number = (row - inner.y) as usize + self.offset.row;
248+ let text_row = (row - inner.y) as usize + self.offset.row;
255−
256− if line_number > text.len_lines() - 1 {
249+ if text_row > text.len_lines() - 1 {
257 return Some(text.len_chars());
250 return Some(text.len_chars());
258 }
251 }
259
252
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;
253+ let text_col = (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− }
285
254
286− col += width;
255+ Some(pos_at_visual_coords(
287− // TODO: use byte pos that converts back to char pos?
256+ *text,
288− pos += grapheme.chars().count();
257+ Position {
289− }
258+ row: text_row,
290−
259+ col: text_col,
291− Some(pos.min(line_end_char_index(&text.slice(..), line_number)))
260+ },
261+ tab_width,
262+ ))
292 }
263 }
293
264
294 /// Translates a screen position to position in the text document.
265 /// Translates a screen position to position in the text document.
runtime/queries/elixir/textobjects.scm+7−1
@@ -16,7 +16,7 @@
16 (pair
16 (pair
17 value: (_) @function.inside))?)?
17 value: (_) @function.inside))?)?
18 (do_block (_)* @function.inside)?)
18 (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
20
20
21(anonymous_function
21(anonymous_function
22 (stab_clause right: (body) @function.inside)) @function.around
22 (stab_clause right: (body) @function.inside)) @function.around
@@ -25,3 +25,9 @@
25 target: (identifier) @_keyword
25 target: (identifier) @_keyword
26 (do_block (_)* @class.inside))
26 (do_block (_)* @class.inside))
27 (#match? @_keyword "^(defmodule|defprotocol|defimpl)$")) @class.around
27 (#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 @@
6 (stab_clause body: (_) @function.inside)) @function.around
6 (stab_clause body: (_) @function.inside)) @function.around
7
7
8(comment (comment_content) @comment.inside) @comment.around
8(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 @@
4
4
5(anonymous_function
5(anonymous_function
6 body: (function_body) @function.inside) @function.around
6 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 @@
26(comment) @comment.inside
26(comment) @comment.inside
27
27
28(comment)+ @comment.around
28(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 @@
22((regex_pattern) @injection.content
22((regex_pattern) @injection.content
23 (#set! injection.language "regex"))
23 (#set! injection.language "regex"))
24
24
25− ; Parse JSDoc annotations in comments
25+; Parse JSDoc annotations in multiline comments
26
26
27((comment) @injection.content
27((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 @@
16(comment) @comment.inside
16(comment) @comment.inside
17
17
18(comment)+ @comment.around
18(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 @@
77(line_comment)+ @comment.around
77(line_comment)+ @comment.around
78
78
79(block_comment) @comment.around
79(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 @@
1# Author: RayGervais <raygervais@hotmail.ca>
1# Author: RayGervais <raygervais@hotmail.ca>
2
2
3"ui.background" = { bg = "base00" }
3"ui.background" = { bg = "base00" }
4−"ui.virtual" = "base03"
4+"ui.virtual.whitespace" = "base03"
5"ui.menu" = { fg = "base05", bg = "base01" }
5"ui.menu" = { fg = "base05", bg = "base01" }
6"ui.menu.selected" = { fg = "base01", bg = "base04" }
6"ui.menu.selected" = { fg = "base01", bg = "base04" }
7"ui.linenr" = { fg = "base03", bg = "base01" }
7"ui.linenr" = { fg = "base03", bg = "base01" }
runtime/themes/base16_default_light.toml+1−1
@@ -12,7 +12,7 @@
12"ui.statusline" = { fg = "base04", bg = "base01" }
12"ui.statusline" = { fg = "base04", bg = "base01" }
13"ui.cursor" = { fg = "base04", modifiers = ["reversed"] }
13"ui.cursor" = { fg = "base04", modifiers = ["reversed"] }
14"ui.cursor.primary" = { fg = "base05", modifiers = ["reversed"] }
14"ui.cursor.primary" = { fg = "base05", modifiers = ["reversed"] }
15−"ui.virtual" = "base03"
15+"ui.virtual.whitespace" = "base03"
16"ui.text" = "base05"
16"ui.text" = "base05"
17"operator" = "base05"
17"operator" = "base05"
18"ui.text.focus" = "base05"
18"ui.text.focus" = "base05"
runtime/themes/base16_terminal.toml+1−1
@@ -13,7 +13,7 @@
13"ui.help" = { fg = "white", bg = "black" }
13"ui.help" = { fg = "white", bg = "black" }
14"ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] }
14"ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] }
15"ui.cursor.primary" = { fg = "light-gray", modifiers = ["reversed"] }
15"ui.cursor.primary" = { fg = "light-gray", modifiers = ["reversed"] }
16−"ui.virtual" = "light-gray"
16+"ui.virtual.whitespace" = "light-gray"
17"variable" = "light-red"
17"variable" = "light-red"
18"constant.numeric" = "yellow"
18"constant.numeric" = "yellow"
19"constant" = "yellow"
19"constant" = "yellow"
runtime/themes/bogster.toml+1−1
@@ -53,7 +53,7 @@
53
53
54"ui.text" = { fg = "#e5ded6" }
54"ui.text" = { fg = "#e5ded6" }
55"ui.text.focus" = { fg = "#e5ded6", modifiers= ["bold"] }
55"ui.text.focus" = { fg = "#e5ded6", modifiers= ["bold"] }
56−"ui.virtual" = "#627d9d"
56+"ui.virtual.whitespace" = "#627d9d"
57
57
58"ui.selection" = { bg = "#313f4e" }
58"ui.selection" = { bg = "#313f4e" }
59# "ui.cursor.match" # TODO might want to override this because dimmed is not widely supported
59# "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 @@
44"ui.menu" = { fg = "lilac", bg = "berry_saturated" }
44"ui.menu" = { fg = "lilac", bg = "berry_saturated" }
45"ui.menu.selected" = { fg = "mint", bg = "berry_saturated" }
45"ui.menu.selected" = { fg = "mint", bg = "berry_saturated" }
46"ui.selection" = { bg = "berry_saturated" }
46"ui.selection" = { bg = "berry_saturated" }
47−"ui.virtual" = { fg = "berry_desaturated" }
47+"ui.virtual.whitespace" = { fg = "berry_desaturated" }
48
48
49"diff.plus" = { fg = "mint" }
49"diff.plus" = { fg = "mint" }
50"diff.delta" = { fg = "gold" }
50"diff.delta" = { fg = "gold" }
runtime/themes/catppuccin.toml+1−1
@@ -48,7 +48,7 @@ label = "peach"
48
48
49"ui.text" = { fg = "pink" }
49"ui.text" = { fg = "pink" }
50"ui.text.focus" = { fg = "white" }
50"ui.text.focus" = { fg = "white" }
51−"ui.virtual" = { fg = "gray_0" }
51+"ui.virtual.whitespace" = { fg = "gray_0" }
52
52
53"ui.selection" = { bg = "#540099" }
53"ui.selection" = { bg = "#540099" }
54"ui.selection.primary" = { bg = "#540099" }
54"ui.selection.primary" = { bg = "#540099" }
runtime/themes/dark_plus.toml+1−1
@@ -78,7 +78,7 @@
78"ui.text" = { fg = "text" }
78"ui.text" = { fg = "text" }
79"ui.text.focus" = { fg = "white" }
79"ui.text.focus" = { fg = "white" }
80
80
81−"ui.virtual" = { fg = "dark_gray" }
81+"ui.virtual.whitespace" = { fg = "dark_gray" }
82"ui.virtual.ruler" = { bg = "borders" }
82"ui.virtual.ruler" = { bg = "borders" }
83
83
84"warning" = { fg = "gold2" }
84"warning" = { fg = "gold2" }
runtime/themes/dracula.toml+1−1
@@ -36,7 +36,7 @@
36"ui.text" = { fg = "foreground" }
36"ui.text" = { fg = "foreground" }
37"ui.text.focus" = { fg = "cyan" }
37"ui.text.focus" = { fg = "cyan" }
38"ui.window" = { fg = "foreground" }
38"ui.window" = { fg = "foreground" }
39−"ui.virtual" = { fg = "comment" }
39+"ui.virtual.whitespace" = { fg = "comment" }
40
40
41"error" = { fg = "red" }
41"error" = { fg = "red" }
42"warning" = { fg = "cyan" }
42"warning" = { fg = "cyan" }
runtime/themes/everforest_dark.toml+1−1
@@ -70,7 +70,7 @@
70"ui.menu" = { fg = "fg", bg = "bg2" }
70"ui.menu" = { fg = "fg", bg = "bg2" }
71"ui.menu.selected" = { fg = "bg0", bg = "green" }
71"ui.menu.selected" = { fg = "bg0", bg = "green" }
72"ui.selection" = { bg = "bg3" }
72"ui.selection" = { bg = "bg3" }
73−"ui.virtual" = "grey0"
73+"ui.virtual.whitespace" = "grey0"
74
74
75"hint" = "blue"
75"hint" = "blue"
76"info" = "aqua"
76"info" = "aqua"
runtime/themes/everforest_light.toml+1−1
@@ -70,7 +70,7 @@
70"ui.menu" = { fg = "fg", bg = "bg2" }
70"ui.menu" = { fg = "fg", bg = "bg2" }
71"ui.menu.selected" = { fg = "bg0", bg = "green" }
71"ui.menu.selected" = { fg = "bg0", bg = "green" }
72"ui.selection" = { bg = "bg3" }
72"ui.selection" = { bg = "bg3" }
73−"ui.virtual" = "grey0"
73+"ui.virtual.whitespace" = "grey0"
74
74
75"hint" = "blue"
75"hint" = "blue"
76"info" = "aqua"
76"info" = "aqua"
runtime/themes/gruvbox.toml+1−1
@@ -53,7 +53,7 @@
53"ui.cursor.match" = { bg = "bg2" }
53"ui.cursor.match" = { bg = "bg2" }
54"ui.menu" = { fg = "fg1", bg = "bg2" }
54"ui.menu" = { fg = "fg1", bg = "bg2" }
55"ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] }
55"ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] }
56−"ui.virtual" = "bg2"
56+"ui.virtual.whitespace" = "bg2"
57
57
58"diagnostic" = { modifiers = ["underlined"] }
58"diagnostic" = { modifiers = ["underlined"] }
59
59
runtime/themes/gruvbox_light.toml+1−1
@@ -54,7 +54,7 @@
54"ui.cursor.match" = { bg = "bg2" }
54"ui.cursor.match" = { bg = "bg2" }
55"ui.menu" = { fg = "fg1", bg = "bg2" }
55"ui.menu" = { fg = "fg1", bg = "bg2" }
56"ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] }
56"ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] }
57−"ui.virtual" = "bg2"
57+"ui.virtual.whitespace" = "bg2"
58
58
59"diagnostic" = { modifiers = ["underlined"] }
59"diagnostic" = { modifiers = ["underlined"] }
60
60
runtime/themes/ingrid.toml+1−1
@@ -53,7 +53,7 @@
53
53
54"ui.text" = { fg = "#7B91B3" }
54"ui.text" = { fg = "#7B91B3" }
55"ui.text.focus" = { fg = "#250E07", modifiers= ["bold"] }
55"ui.text.focus" = { fg = "#250E07", modifiers= ["bold"] }
56−"ui.virtual" = "#A6B6CE"
56+"ui.virtual.whitespace" = "#A6B6CE"
57
57
58"ui.selection" = { bg = "#540099" }
58"ui.selection" = { bg = "#540099" }
59# "ui.cursor.match" # TODO might want to override this because dimmed is not widely supported
59# "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 @@
32"attribute" = { fg = "fn_declaration" }
32"attribute" = { fg = "fn_declaration" }
33
33
34"comment" = { fg = "#88846F" }
34"comment" = { fg = "#88846F" }
35−"ui.virtual" = "#88846F"
35+"ui.virtual.whitespace" = "#88846F"
36
36
37"string" = { fg = "#e6db74" }
37"string" = { fg = "#e6db74" }
38"constant.character" = { fg = "#e6db74" }
38"constant.character" = { fg = "#e6db74" }
runtime/themes/monokai_pro.toml+1−1
@@ -6,7 +6,7 @@
6"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
6"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
7"ui.menu" = { fg = "base8", bg = "base3" }
7"ui.menu" = { fg = "base8", bg = "base3" }
8"ui.menu.selected" = { fg = "base2", bg = "yellow" }
8"ui.menu.selected" = { fg = "base2", bg = "yellow" }
9−"ui.virtual" = "base5"
9+"ui.virtual.whitespace" = "base5"
10
10
11"info" = "base8"
11"info" = "base8"
12"hint" = "base8"
12"hint" = "base8"
runtime/themes/monokai_pro_machine.toml+1−1
@@ -6,7 +6,7 @@
6"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
6"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
7"ui.menu" = { fg = "base8", bg = "base3" }
7"ui.menu" = { fg = "base8", bg = "base3" }
8"ui.menu.selected" = { fg = "base2", bg = "yellow" }
8"ui.menu.selected" = { fg = "base2", bg = "yellow" }
9−"ui.virtual" = "base5"
9+"ui.virtual.whitespace" = "base5"
10
10
11"info" = "base8"
11"info" = "base8"
12"hint" = "base8"
12"hint" = "base8"
runtime/themes/monokai_pro_octagon.toml+1−1
@@ -6,7 +6,7 @@
6"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
6"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
7"ui.menu" = { fg = "base8", bg = "base3" }
7"ui.menu" = { fg = "base8", bg = "base3" }
8"ui.menu.selected" = { fg = "base2", bg = "yellow" }
8"ui.menu.selected" = { fg = "base2", bg = "yellow" }
9−"ui.virtual" = "base5"
9+"ui.virtual.whitespace" = "base5"
10
10
11"info" = "base8"
11"info" = "base8"
12"hint" = "base8"
12"hint" = "base8"
runtime/themes/monokai_pro_ristretto.toml+1−1
@@ -6,7 +6,7 @@
6"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
6"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
7"ui.menu" = { fg = "base8", bg = "base3" }
7"ui.menu" = { fg = "base8", bg = "base3" }
8"ui.menu.selected" = { fg = "base2", bg = "yellow" }
8"ui.menu.selected" = { fg = "base2", bg = "yellow" }
9−"ui.virtual" = "base5"
9+"ui.virtual.whitespace" = "base5"
10
10
11"info" = "base8"
11"info" = "base8"
12"hint" = "base8"
12"hint" = "base8"
runtime/themes/monokai_pro_spectrum.toml+1−1
@@ -6,7 +6,7 @@
6"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
6"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
7"ui.menu" = { fg = "base8", bg = "base3" }
7"ui.menu" = { fg = "base8", bg = "base3" }
8"ui.menu.selected" = { fg = "base2", bg = "yellow" }
8"ui.menu.selected" = { fg = "base2", bg = "yellow" }
9−"ui.virtual" = "base5"
9+"ui.virtual.whitespace" = "base5"
10
10
11"info" = "base8"
11"info" = "base8"
12"hint" = "base8"
12"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 @@
4"ui.text.focus" = { fg = "nord8", modifiers= ["bold"] }
4"ui.text.focus" = { fg = "nord8", modifiers= ["bold"] }
5"ui.menu" = { fg = "nord6", bg = "#232d38" }
5"ui.menu" = { fg = "nord6", bg = "#232d38" }
6"ui.menu.selected" = { fg = "nord8", bg = "nord2" }
6"ui.menu.selected" = { fg = "nord8", bg = "nord2" }
7−"ui.virtual" = "gray"
7+"ui.virtual.whitespace" = "gray"
8
8
9"info" = "nord8"
9"info" = "nord8"
10"hint" = "nord8"
10"hint" = "nord8"
runtime/themes/rose_pine.toml+1−1
@@ -14,7 +14,7 @@
14"ui.text" = { fg = "text" }
14"ui.text" = { fg = "text" }
15"ui.text.focus" = { fg = "foam", modifiers = ["bold"]}
15"ui.text.focus" = { fg = "foam", modifiers = ["bold"]}
16"ui.text.info" = {fg = "pine", modifiers = ["bold"]}
16"ui.text.info" = {fg = "pine", modifiers = ["bold"]}
17−"ui.virtual" = "highlight"
17+"ui.virtual.whitespace" = "highlight"
18"operator" = "rose"
18"operator" = "rose"
19"variable" = "text"
19"variable" = "text"
20"constant.numeric" = "iris"
20"constant.numeric" = "iris"
runtime/themes/rose_pine_dawn.toml+1−1
@@ -14,7 +14,7 @@
14"ui.text" = { fg = "text" }
14"ui.text" = { fg = "text" }
15"ui.text.focus" = { fg = "foam", modifiers = ["bold"]}
15"ui.text.focus" = { fg = "foam", modifiers = ["bold"]}
16"ui.text.info" = {fg = "pine", modifiers = ["bold"]}
16"ui.text.info" = {fg = "pine", modifiers = ["bold"]}
17−"ui.virtual" = "highlight"
17+"ui.virtual.whitespace" = "highlight"
18"operator" = "rose"
18"operator" = "rose"
19"variable" = "text"
19"variable" = "text"
20"number" = "iris"
20"number" = "iris"
runtime/themes/serika-dark.toml+1−1
@@ -50,7 +50,7 @@
50"ui.menu" = { fg = "fg", bg = "bg2" }
50"ui.menu" = { fg = "fg", bg = "bg2" }
51"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
51"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
52"ui.selection" = { bg = "bg3" }
52"ui.selection" = { bg = "bg3" }
53−"ui.virtual" = "grey2"
53+"ui.virtual.whitespace" = "grey2"
54
54
55"hint" = "blue"
55"hint" = "blue"
56"info" = "aqua"
56"info" = "aqua"
runtime/themes/serika-light.toml+1−1
@@ -50,7 +50,7 @@
50"ui.menu" = { fg = "bg0", bg = "bg3" }
50"ui.menu" = { fg = "bg0", bg = "bg3" }
51"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
51"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
52"ui.selection" = { fg = "bg0", bg = "bg3" }
52"ui.selection" = { fg = "bg0", bg = "bg3" }
53−"ui.virtual" = { fg = "bg2" }
53+"ui.virtual.whitespace" = { fg = "bg2" }
54
54
55"hint" = "blue"
55"hint" = "blue"
56"info" = "aqua"
56"info" = "aqua"
runtime/themes/snazzy.toml+1−1
@@ -38,7 +38,7 @@
38"ui.text" = { fg = "foreground" }
38"ui.text" = { fg = "foreground" }
39"ui.text.focus" = { fg = "cyan" }
39"ui.text.focus" = { fg = "cyan" }
40"ui.window" = { fg = "foreground" }
40"ui.window" = { fg = "foreground" }
41−"ui.virtual" = { fg = "comment" }
41+"ui.virtual.whitespace" = { fg = "comment" }
42
42
43"error" = { fg = "red" }
43"error" = { fg = "red" }
44"warning" = { fg = "cyan" }
44"warning" = { fg = "cyan" }
runtime/themes/solarized_dark.toml+1−1
@@ -39,7 +39,7 @@
39# 背景
39# 背景
40"ui.background" = { bg = "base03" }
40"ui.background" = { bg = "base03" }
41
41
42−"ui.virtual" = { fg = "base01" }
42+"ui.virtual.whitespace" = { fg = "base01" }
43
43
44# 行号栏
44# 行号栏
45"ui.linenr" = { fg = "base0", bg = "base02" }
45"ui.linenr" = { fg = "base0", bg = "base02" }
runtime/themes/solarized_light.toml+1−1
@@ -40,7 +40,7 @@
40# background
40# background
41"ui.background" = { bg = "base03" }
41"ui.background" = { bg = "base03" }
42
42
43−"ui.virtual" = { fg = "base01" }
43+"ui.virtual.whitespace" = { fg = "base01" }
44
44
45# 行号栏
45# 行号栏
46# line number column
46# line number column
runtime/themes/spacebones_light.toml+1−1
@@ -64,7 +64,7 @@
64"ui.cursor.match" = { bg = "bg3" }
64"ui.cursor.match" = { bg = "bg3" }
65"ui.menu" = { fg = "fg1", bg = "bg2" }
65"ui.menu" = { fg = "fg1", bg = "bg2" }
66"ui.menu.selected" = { fg = "#655370", bg = "#d1dcdf", modifiers = ["bold"] }
66"ui.menu.selected" = { fg = "#655370", bg = "#d1dcdf", modifiers = ["bold"] }
67−"ui.virtual" = "bg2"
67+"ui.virtual.whitespace" = "bg2"
68
68
69"diagnostic" = { modifiers = ["underlined"] }
69"diagnostic" = { modifiers = ["underlined"] }
70
70