Merge branch 'master' into test-harness

pull/2359/head
Blaž Hrastnik 2 years ago committed by GitHub
commit 458b89e21d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

4
Cargo.lock generated

@ -13,9 +13,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.53"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
[[package]]
name = "arc-swap"

@ -2,40 +2,8 @@
## Language configuration
To add a new language, you need to add a `language` entry to the
[`languages.toml`][languages.toml] found in the root of the repository;
this `languages.toml` file is included at compilation time, and is
distinct from the `languages.toml` file in the user's [configuration
directory](../configuration.md).
```toml
[[language]]
name = "mylang"
scope = "scope.mylang"
injection-regex = "^mylang$"
file-types = ["mylang", "myl"]
comment-token = "#"
indent = { tab-width = 2, unit = " " }
language-server = { command = "mylang-lsp", args = ["--stdio"] }
```
These are the available keys and descriptions for the file.
| Key | Description |
| ---- | ----------- |
| `name` | The name of the language |
| `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 |
| `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. |
| `file-types` | The filetypes of the language, for example `["yml", "yaml"]`. Extensions and full file names are supported. |
| `shebangs` | The interpreters from the shebang line, for example `["sh", "bash"]` |
| `roots` | A set of marker files to look for when trying to find the workspace root. For example `Cargo.lock`, `yarn.lock` |
| `auto-format` | Whether to autoformat this language when saving |
| `diagnostic-severity` | Minimal severity of diagnostic for it to be displayed. (Allowed values: `Error`, `Warning`, `Info`, `Hint`) |
| `comment-token` | The token to use as a comment-token |
| `indent` | The indent to use. Has sub keys `tab-width` and `unit` |
| `language-server` | The Language Server to run. Has sub keys `command` and `args` |
| `config` | Language Server configuration |
| `grammar` | The tree-sitter grammar to use (defaults to the value of `name`) |
To add a new language, you need to add a `[[language]]` entry to the
`languages.toml` (see the [language configuration section]).
When adding a new language or Language Server configuration for an existing
language, 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
## Grammar configuration
If a tree-sitter grammar is available for the language, add a new `grammar`
If a tree-sitter grammar is available for the language, add a new `[[grammar]]`
entry to `languages.toml`.
```toml
[[grammar]]
name = "mylang"
source = { git = "https://github.com/example/mylang", rev = "a250c4582510ff34767ec3b7dcdd3c24e8c8aa68" }
```
Grammar configuration takes these keys:
| Key | Description |
| --- | ----------- |
| `name` | The name of the tree-sitter grammar |
| `source` | The method of fetching the grammar - a table with a schema defined below |
Where `source` is a table with either these keys when using a grammar from a
git repository:
| Key | Description |
| --- | ----------- |
| `git` | A git remote URL from which the grammar should be cloned |
| `rev` | The revision (commit hash or tag) which should be fetched |
| `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 |
Or a `path` key with an absolute path to a locally available grammar directory.
You may use the `source.path` key rather than `source.git` with an absolute path
to a locally available grammar for testing, but switch to `source.git` before
submitting a pull request.
## Queries
@ -91,8 +39,7 @@ the last matching query supersedes the ones before it. See
- If a parser is segfaulting or you want to remove the parser, make sure to remove the compiled parser in `runtime/grammar/<name>.so`
[treesitter-language-injection]: https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection
[languages.toml]: https://github.com/helix-editor/helix/blob/master/languages.toml
[language configuration section]: ../languages.md
[neovim-query-precedence]: https://github.com/helix-editor/helix/pull/1170#issuecomment-997294090
[install-lsp-wiki]: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers
[lang-support]: ../lang-support.md

@ -20,6 +20,8 @@ The following [captures][tree-sitter-captures] are recognized:
| `function.around` |
| `class.inside` |
| `class.around` |
| `test.inside` |
| `test.around` |
| `parameter.inside` |
| `comment.inside` |
| `comment.around` |

@ -282,6 +282,8 @@ Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaire
| `[a` | Go to previous argument/parameter (**TS**) | `goto_prev_parameter` |
| `]o` | Go to next comment (**TS**) | `goto_next_comment` |
| `[o` | Go to previous comment (**TS**) | `goto_prev_comment` |
| `]t` | Go to next test (**TS**) | `goto_next_test` |
| `]t` | Go to previous test (**TS**) | `goto_prev_test` |
| `]p` | Go to next paragraph | `goto_next_paragraph` |
| `[p` | Go to previous paragraph | `goto_prev_paragraph` |
| `[space` | Add newline above | `add_newline_above` |

@ -1,10 +1,17 @@
# Languages
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.
Language-specific settings and settings for language servers are configured
in `languages.toml` files.
A local `languages.toml` can be created within a `.helix` directory. Its settings will be merged with both the global and default configs.
## `languages.toml` files
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:
There are three possible `languages.toml` files. The first is compiled into
Helix and lives in the [Helix repository](https://github.com/helix-editor/helix/blob/master/languages.toml).
This provides the default configurations for languages and language servers.
You may define a `languages.toml` in your [configuration directory](./configuration.md)
which overrides values from the built-in language configuration. For example
to disable auto-LSP-formatting in Rust:
```toml
# in <config_dir>/helix/languages.toml
@ -14,9 +21,60 @@ name = "rust"
auto-format = false
```
## LSP formatting options
Language configuration may also be overridden local to a project by creating
a `languages.toml` file under a `.helix` directory. Its settings will be merged
with the language configuration in the configuration directory and the built-in
configuration.
## Language configuration
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).
Each language is configured by adding a `[[language]]` section to a
`languages.toml` file. For example:
```toml
[[language]]
name = "mylang"
scope = "source.mylang"
injection-regex = "^mylang$"
file-types = ["mylang", "myl"]
comment-token = "#"
indent = { tab-width = 2, unit = " " }
language-server = { command = "mylang-lsp", args = ["--stdio"] }
```
These configuration keys are available:
| Key | Description |
| ---- | ----------- |
| `name` | The name of the language |
| `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 |
| `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. |
| `file-types` | The filetypes of the language, for example `["yml", "yaml"]`. Extensions and full file names are supported. |
| `shebangs` | The interpreters from the shebang line, for example `["sh", "bash"]` |
| `roots` | A set of marker files to look for when trying to find the workspace root. For example `Cargo.lock`, `yarn.lock` |
| `auto-format` | Whether to autoformat this language when saving |
| `diagnostic-severity` | Minimal severity of diagnostic for it to be displayed. (Allowed values: `Error`, `Warning`, `Info`, `Hint`) |
| `comment-token` | The token to use as a comment-token |
| `indent` | The indent to use. Has sub keys `tab-width` and `unit` |
| `language-server` | The Language Server to run. See the Language Server configuration section below. |
| `config` | Language Server configuration |
| `grammar` | The tree-sitter grammar to use (defaults to the value of `name`) |
### Language Server configuration
The `language-server` field takes the following keys:
| Key | Description |
| --- | ----------- |
| `command` | The name of the language server binary to execute. Binaries must be in `$PATH` |
| `args` | A list of arguments to pass to the language server binary |
| `timeout` | The maximum time a request to the language server may take, in seconds. Defaults to `20` |
| `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 |
The top-level `config` field is used to configure the LSP initialization options. A `format`
sub-table within `config` can be used 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).
For example with typescript:
```toml
[[language]]
@ -26,23 +84,37 @@ auto-format = true
config = { format = { "semicolons" = "insert", "insertSpaceBeforeFunctionParenthesis" = true } }
```
## Tree-sitter grammars
## Tree-sitter grammar configuration
Tree-sitter grammars can also be configured in `languages.toml`:
The source for a language's tree-sitter grammar is specified in a `[[grammar]]`
section in `languages.toml`. For example:
```toml
# in <config_dir>/helix/languages.toml
[[grammar]]
name = "rust"
source = { git = "https://github.com/tree-sitter/tree-sitter-rust", rev = "a250c4582510ff34767ec3b7dcdd3c24e8c8aa68" }
[[grammar]]
name = "c"
source = { path = "/path/to/tree-sitter-c" }
name = "mylang"
source = { git = "https://github.com/example/mylang", rev = "a250c4582510ff34767ec3b7dcdd3c24e8c8aa68" }
```
You may use a top-level `use-grammars` key to control which grammars are fetched and built.
Grammar configuration takes these keys:
| Key | Description |
| --- | ----------- |
| `name` | The name of the tree-sitter grammar |
| `source` | The method of fetching the grammar - a table with a schema defined below |
Where `source` is a table with either these keys when using a grammar from a
git repository:
| Key | Description |
| --- | ----------- |
| `git` | A git remote URL from which the grammar should be cloned |
| `rev` | The revision (commit hash or tag) which should be fetched |
| `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 |
### Choosing grammars
You may use a top-level `use-grammars` key to control which grammars are
fetched and built when using `hx --grammar fetch` and `hx --grammar build`.
```toml
# Note: this key must come **before** the [[language]] and [[grammar]] sections
@ -52,3 +124,5 @@ use-grammars = { except = [ "yaml", "json" ] }
```
When omitted, all grammars are fetched and built.
[treesitter-language-injection]: https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection

@ -143,6 +143,7 @@ Currently supported: `word`, `surround`, `function`, `class`, `parameter`.
| `c` | Class |
| `a` | Argument/parameter |
| `o` | Comment |
| `t` | Test |
> NOTE: `f`, `c`, etc need a tree-sitter grammar active for the current
document and a special tree-sitter query file to work properly. [Only

@ -63,7 +63,9 @@ pub type Tendril = SmartString<smartstring::LazyCompact>;
pub use {regex, tree_sitter};
pub use graphemes::RopeGraphemes;
pub use position::{coords_at_pos, pos_at_coords, visual_coords_at_pos, Position};
pub use position::{
coords_at_pos, pos_at_coords, pos_at_visual_coords, visual_coords_at_pos, Position,
};
pub use selection::{Range, Selection};
pub use smallvec::{smallvec, SmallVec};
pub use syntax::Syntax;

@ -5,16 +5,15 @@ use tree_sitter::{Node, QueryCursor};
use crate::{
chars::{categorize_char, char_is_line_ending, CharCategory},
coords_at_pos,
graphemes::{
next_grapheme_boundary, nth_next_grapheme_boundary, nth_prev_grapheme_boundary,
prev_grapheme_boundary,
},
line_ending::rope_is_line_ending,
pos_at_coords,
pos_at_visual_coords,
syntax::LanguageConfiguration,
textobject::TextObject,
Position, Range, RopeSlice,
visual_coords_at_pos, Position, Range, RopeSlice,
};
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
@ -35,6 +34,7 @@ pub fn move_horizontally(
dir: Direction,
count: usize,
behaviour: Movement,
_: usize,
) -> Range {
let pos = range.cursor(slice);
@ -54,15 +54,12 @@ pub fn move_vertically(
dir: Direction,
count: usize,
behaviour: Movement,
tab_width: usize,
) -> Range {
let pos = range.cursor(slice);
// Compute the current position's 2d coordinates.
// TODO: switch this to use `visual_coords_at_pos` rather than
// `coords_at_pos` as this will cause a jerky movement when the visual
// position does not match, like moving from a line with tabs/CJK to
// a line without
let Position { row, col } = coords_at_pos(slice, pos);
let Position { row, col } = visual_coords_at_pos(slice, pos, tab_width);
let horiz = range.horiz.unwrap_or(col as u32);
// Compute the new position.
@ -71,7 +68,7 @@ pub fn move_vertically(
Direction::Backward => row.saturating_sub(count),
};
let new_col = col.max(horiz as usize);
let new_pos = pos_at_coords(slice, Position::new(new_row, new_col), true);
let new_pos = pos_at_visual_coords(slice, Position::new(new_row, new_col), tab_width);
// Special-case to avoid moving to the end of the last non-empty line.
if behaviour == Movement::Extend && slice.line(new_row).len_chars() == 0 {
@ -446,6 +443,8 @@ pub fn goto_treesitter_object(
mod test {
use ropey::Rope;
use crate::{coords_at_pos, pos_at_coords};
use super::*;
const SINGLE_LINE_SAMPLE: &str = "This is a simple alphabetic line";
@ -472,7 +471,7 @@ mod test {
assert_eq!(
coords_at_pos(
slice,
move_vertically(slice, range, Direction::Forward, 1, Movement::Move).head
move_vertically(slice, range, Direction::Forward, 1, Movement::Move, 4).head
),
(1, 3).into()
);
@ -496,7 +495,7 @@ mod test {
];
for ((direction, amount), coordinates) in moves_and_expected_coordinates {
range = move_horizontally(slice, range, direction, amount, Movement::Move);
range = move_horizontally(slice, range, direction, amount, Movement::Move, 0);
assert_eq!(coords_at_pos(slice, range.head), coordinates.into())
}
}
@ -522,7 +521,7 @@ mod test {
];
for ((direction, amount), coordinates) in moves_and_expected_coordinates {
range = move_horizontally(slice, range, direction, amount, Movement::Move);
range = move_horizontally(slice, range, direction, amount, Movement::Move, 0);
assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
assert_eq!(range.head, range.anchor);
}
@ -544,7 +543,7 @@ mod test {
];
for (direction, amount) in moves {
range = move_horizontally(slice, range, direction, amount, Movement::Extend);
range = move_horizontally(slice, range, direction, amount, Movement::Extend, 0);
assert_eq!(range.anchor, original_anchor);
}
}
@ -568,7 +567,7 @@ mod test {
];
for ((direction, amount), coordinates) in moves_and_expected_coordinates {
range = move_vertically(slice, range, direction, amount, Movement::Move);
range = move_vertically(slice, range, direction, amount, Movement::Move, 4);
assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
assert_eq!(range.head, range.anchor);
}
@ -602,8 +601,8 @@ mod test {
for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
range = match axis {
Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move),
Axis::V => move_vertically(slice, range, direction, amount, Movement::Move),
Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move, 0),
Axis::V => move_vertically(slice, range, direction, amount, Movement::Move, 4),
};
assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
assert_eq!(range.head, range.anchor);
@ -627,18 +626,18 @@ mod test {
let moves_and_expected_coordinates = [
// Places cursor at the fourth kana.
((Axis::H, Direction::Forward, 4), (0, 4)),
// Descent places cursor at the 4th character.
((Axis::V, Direction::Forward, 1usize), (1, 4)),
// Moving back 1 character.
((Axis::H, Direction::Backward, 1usize), (1, 3)),
// Descent places cursor at the 8th character.
((Axis::V, Direction::Forward, 1usize), (1, 8)),
// Moving back 2 characters.
((Axis::H, Direction::Backward, 2usize), (1, 6)),
// Jumping back up 1 line.
((Axis::V, Direction::Backward, 1usize), (0, 3)),
];
for ((axis, direction, amount), coordinates) in moves_and_expected_coordinates {
range = match axis {
Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move),
Axis::V => move_vertically(slice, range, direction, amount, Movement::Move),
Axis::H => move_horizontally(slice, range, direction, amount, Movement::Move, 0),
Axis::V => move_vertically(slice, range, direction, amount, Movement::Move, 4),
};
assert_eq!(coords_at_pos(slice, range.head), coordinates.into());
assert_eq!(range.head, range.anchor);

@ -109,9 +109,6 @@ pub fn visual_coords_at_pos(text: RopeSlice, pos: usize, tab_width: usize) -> Po
/// with left-side block-cursor positions, as this prevents the the block cursor
/// from jumping to the next line. Otherwise you typically want it to be `false`,
/// such as when dealing with raw anchor/head positions.
///
/// TODO: this should be changed to work in terms of visual row/column, not
/// graphemes.
pub fn pos_at_coords(text: RopeSlice, coords: Position, limit_before_line_ending: bool) -> usize {
let Position { mut row, col } = coords;
if limit_before_line_ending {
@ -135,6 +132,43 @@ pub fn pos_at_coords(text: RopeSlice, coords: Position, limit_before_line_ending
line_start + col_char_offset
}
/// Convert visual (line, column) coordinates to a character index.
///
/// If the `line` coordinate is beyond the end of the file, the EOF
/// position will be returned.
///
/// If the `column` coordinate is past the end of the given line, the
/// line-end position (in this case, just before the line ending
/// character) will be returned.
pub fn pos_at_visual_coords(text: RopeSlice, coords: Position, tab_width: usize) -> usize {
let Position { mut row, col } = coords;
row = row.min(text.len_lines() - 1);
let line_start = text.line_to_char(row);
let line_end = line_end_char_index(&text, row);
let mut col_char_offset = 0;
let mut cols_remaining = col;
for grapheme in RopeGraphemes::new(text.slice(line_start..line_end)) {
let grapheme_width = if grapheme == "\t" {
tab_width - ((col - cols_remaining) % tab_width)
} else {
let grapheme = Cow::from(grapheme);
grapheme_width(&grapheme)
};
// If pos is in the middle of a wider grapheme (tab for example)
// return the starting offset.
if grapheme_width > cols_remaining {
break;
}
cols_remaining -= grapheme_width;
col_char_offset += grapheme.chars().count();
}
line_start + col_char_offset
}
#[cfg(test)]
mod test {
use super::*;
@ -305,4 +339,70 @@ mod test {
assert_eq!(pos_at_coords(slice, (0, 10).into(), true), 0);
assert_eq!(pos_at_coords(slice, (10, 10).into(), true), 0);
}
#[test]
fn test_pos_at_visual_coords() {
let text = Rope::from("ḧëḷḷö\nẅöṛḷḋ");
let slice = text.slice(..);
assert_eq!(pos_at_visual_coords(slice, (0, 0).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (0, 5).into(), 4), 5); // position on \n
assert_eq!(pos_at_visual_coords(slice, (0, 6).into(), 4), 5); // position after \n
assert_eq!(pos_at_visual_coords(slice, (1, 0).into(), 4), 6); // position on w
assert_eq!(pos_at_visual_coords(slice, (1, 1).into(), 4), 7); // position on o
assert_eq!(pos_at_visual_coords(slice, (1, 4).into(), 4), 10); // position on d
// Test with wide characters.
let text = Rope::from("今日はいい\n");
let slice = text.slice(..);
assert_eq!(pos_at_visual_coords(slice, (0, 0).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (0, 1).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (0, 2).into(), 4), 1);
assert_eq!(pos_at_visual_coords(slice, (0, 3).into(), 4), 1);
assert_eq!(pos_at_visual_coords(slice, (0, 4).into(), 4), 2);
assert_eq!(pos_at_visual_coords(slice, (0, 5).into(), 4), 2);
assert_eq!(pos_at_visual_coords(slice, (0, 6).into(), 4), 3);
assert_eq!(pos_at_visual_coords(slice, (0, 7).into(), 4), 3);
assert_eq!(pos_at_visual_coords(slice, (0, 8).into(), 4), 4);
assert_eq!(pos_at_visual_coords(slice, (0, 9).into(), 4), 4);
// assert_eq!(pos_at_visual_coords(slice, (0, 10).into(), 4, false), 5);
// assert_eq!(pos_at_visual_coords(slice, (0, 10).into(), 4, true), 5);
assert_eq!(pos_at_visual_coords(slice, (1, 0).into(), 4), 6);
// Test with grapheme clusters.
let text = Rope::from("a̐éö̲\r\n");
let slice = text.slice(..);
assert_eq!(pos_at_visual_coords(slice, (0, 0).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (0, 1).into(), 4), 2);
assert_eq!(pos_at_visual_coords(slice, (0, 2).into(), 4), 4);
assert_eq!(pos_at_visual_coords(slice, (0, 3).into(), 4), 7); // \r\n is one char here
assert_eq!(pos_at_visual_coords(slice, (0, 4).into(), 4), 7);
assert_eq!(pos_at_visual_coords(slice, (1, 0).into(), 4), 9);
// Test with wide-character grapheme clusters.
let text = Rope::from("किमपि");
// 2 - 1 - 2 codepoints
// TODO: delete handling as per https://news.ycombinator.com/item?id=20058454
let slice = text.slice(..);
assert_eq!(pos_at_visual_coords(slice, (0, 0).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (0, 1).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (0, 2).into(), 4), 2);
assert_eq!(pos_at_visual_coords(slice, (0, 3).into(), 4), 3);
// Test with tabs.
let text = Rope::from("\tHello\n");
let slice = text.slice(..);
assert_eq!(pos_at_visual_coords(slice, (0, 0).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (0, 1).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (0, 2).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (0, 3).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (0, 4).into(), 4), 1);
assert_eq!(pos_at_visual_coords(slice, (0, 5).into(), 4), 2);
// Test out of bounds.
let text = Rope::new();
let slice = text.slice(..);
assert_eq!(pos_at_visual_coords(slice, (10, 0).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (0, 10).into(), 4), 0);
assert_eq!(pos_at_visual_coords(slice, (10, 10).into(), 4), 0);
}
}

@ -16,14 +16,14 @@ use helix_core::{
line_ending::{get_line_ending_of_str, line_end_char_index, str_is_line_ending},
match_brackets,
movement::{self, Direction},
object, pos_at_coords,
object, pos_at_coords, pos_at_visual_coords,
regex::{self, Regex, RegexBuilder},
search::{self, CharMatcher},
selection, shellwords, surround, textobject,
tree_sitter::Node,
unicode::width::UnicodeWidthChar,
LineEnding, Position, Range, Rope, RopeGraphemes, RopeSlice, Selection, SmallVec, Tendril,
Transaction,
visual_coords_at_pos, LineEnding, Position, Range, Rope, RopeGraphemes, RopeSlice, Selection,
SmallVec, Tendril, Transaction,
};
use helix_view::{
clipboard::ClipboardType,
@ -395,6 +395,8 @@ impl MappableCommand {
goto_prev_parameter, "Goto previous parameter",
goto_next_comment, "Goto next comment",
goto_prev_comment, "Goto previous comment",
goto_next_test, "Goto next test",
goto_prev_test, "Goto previous test",
goto_next_paragraph, "Goto next paragraph",
goto_prev_paragraph, "Goto previous paragraph",
dap_launch, "Launch debug target",
@ -509,7 +511,7 @@ fn no_op(_cx: &mut Context) {}
fn move_impl<F>(cx: &mut Context, move_fn: F, dir: Direction, behaviour: Movement)
where
F: Fn(RopeSlice, Range, Direction, usize, Movement) -> Range,
F: Fn(RopeSlice, Range, Direction, usize, Movement, usize) -> Range,
{
let count = cx.count();
let (view, doc) = current!(cx.editor);
@ -518,7 +520,7 @@ where
let selection = doc
.selection(view.id)
.clone()
.transform(|range| move_fn(text, range, dir, count, behaviour));
.transform(|range| move_fn(text, range, dir, count, behaviour, doc.tab_width()));
doc.set_selection(view.id, selection);
}
@ -1410,9 +1412,10 @@ fn copy_selection_on_line(cx: &mut Context, direction: Direction) {
range.head
};
// TODO: this should use visual offsets / pos_at_screen_coords
let head_pos = coords_at_pos(text, head);
let anchor_pos = coords_at_pos(text, range.anchor);
let tab_width = doc.tab_width();
let head_pos = visual_coords_at_pos(text, head, tab_width);
let anchor_pos = visual_coords_at_pos(text, range.anchor, tab_width);
let height = std::cmp::max(head_pos.row, anchor_pos.row)
- std::cmp::min(head_pos.row, anchor_pos.row)
@ -1442,12 +1445,13 @@ fn copy_selection_on_line(cx: &mut Context, direction: Direction) {
break;
}
let anchor = pos_at_coords(text, Position::new(anchor_row, anchor_pos.col), true);
let head = pos_at_coords(text, Position::new(head_row, head_pos.col), true);
let anchor =
pos_at_visual_coords(text, Position::new(anchor_row, anchor_pos.col), tab_width);
let head = pos_at_visual_coords(text, Position::new(head_row, head_pos.col), tab_width);
// skip lines that are too short
if coords_at_pos(text, anchor).col == anchor_pos.col
&& coords_at_pos(text, head).col == head_pos.col
if visual_coords_at_pos(text, anchor, tab_width).col == anchor_pos.col
&& visual_coords_at_pos(text, head, tab_width).col == head_pos.col
{
if is_primary {
primary_index = ranges.len();
@ -4105,6 +4109,14 @@ fn goto_prev_comment(cx: &mut Context) {
goto_ts_object_impl(cx, "comment", Direction::Backward)
}
fn goto_next_test(cx: &mut Context) {
goto_ts_object_impl(cx, "test", Direction::Forward)
}
fn goto_prev_test(cx: &mut Context) {
goto_ts_object_impl(cx, "test", Direction::Backward)
}
fn select_textobject_around(cx: &mut Context) {
select_textobject(cx, textobject::TextObject::Around);
}
@ -4148,6 +4160,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
'f' => textobject_treesitter("function", range),
'a' => textobject_treesitter("parameter", range),
'o' => textobject_treesitter("comment", range),
't' => textobject_treesitter("test", range),
'p' => textobject::textobject_paragraph(text, range, objtype, count),
'm' => textobject::textobject_surround_closest(text, range, objtype, count),
// TODO: cancel new ranges if inconsistent surround matches across lines
@ -4177,6 +4190,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
("f", "Function (tree-sitter)"),
("a", "Argument/parameter (tree-sitter)"),
("o", "Comment (tree-sitter)"),
("t", "Test (tree-sitter)"),
("m", "Matching delimiter under cursor"),
(" ", "... or any character acting as a pair"),
];

@ -1,4 +1,7 @@
use crossterm::style::{Color, Print, Stylize};
use crossterm::{
style::{Color, Print, Stylize},
tty::IsTty,
};
use helix_core::config::{default_syntax_loader, user_syntax_loader};
use helix_loader::grammar::load_runtime_file;
use std::io::Write;
@ -106,17 +109,19 @@ pub fn languages_all() -> std::io::Result<()> {
let terminal_cols = crossterm::terminal::size().map(|(c, _)| c).unwrap_or(80);
let column_width = terminal_cols as usize / headings.len();
let is_terminal = std::io::stdout().is_tty();
let column = |item: &str, color: Color| {
let data = format!(
let mut data = format!(
"{:width$}",
item.get(..column_width - 2)
.map(|s| format!("{}…", s))
.unwrap_or_else(|| item.to_string()),
width = column_width,
)
.stylize()
.with(color);
);
if is_terminal {
data = data.stylize().with(color).to_string();
}
// We can't directly use println!() because of
// https://github.com/crossterm-rs/crossterm/issues/589

@ -104,6 +104,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
"c" => goto_prev_class,
"a" => goto_prev_parameter,
"o" => goto_prev_comment,
"t" => goto_prev_test,
"p" => goto_prev_paragraph,
"space" => add_newline_above,
},
@ -114,6 +115,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
"c" => goto_next_class,
"a" => goto_next_parameter,
"o" => goto_next_comment,
"t" => goto_next_test,
"p" => goto_next_paragraph,
"space" => add_newline_below,
},

@ -20,7 +20,7 @@ use helix_core::{
use helix_view::{
document::{Mode, SCRATCH_BUFFER_NAME},
editor::{CompleteAction, CursorShapeConfig},
graphics::{CursorKind, Modifier, Rect, Style},
graphics::{Color, CursorKind, Modifier, Rect, Style},
input::KeyEvent,
keyboard::{KeyCode, KeyModifiers},
Document, Editor, Theme, View,
@ -170,7 +170,9 @@ impl EditorView {
theme: &Theme,
) {
let editor_rulers = &editor.config().rulers;
let ruler_theme = theme.get("ui.virtual.ruler");
let ruler_theme = theme
.try_get("ui.virtual.ruler")
.unwrap_or_else(|| Style::default().bg(Color::Red));
let rulers = doc
.language_config()
@ -1046,7 +1048,7 @@ impl EditorView {
let mut selection = doc.selection(view.id).clone();
let primary = selection.primary_mut();
*primary = Range::new(primary.anchor, pos);
*primary = primary.put_cursor(doc.text().slice(..), pos, true);
doc.set_selection(view.id, selection);
EventResult::Consumed(None)
}

@ -26,7 +26,18 @@ pub fn diagnostic<'doc>(
Box::new(move |line: usize, _selected: bool, out: &mut String| {
use helix_core::diagnostic::Severity;
if let Ok(index) = diagnostics.binary_search_by_key(&line, |d| d.line) {
let diagnostic = &diagnostics[index];
let after = diagnostics[index..].iter().take_while(|d| d.line == line);
let before = diagnostics[..index]
.iter()
.rev()
.take_while(|d| d.line == line);
let diagnostics_on_line = after.chain(before);
// This unwrap is safe because the iterator cannot be empty as it contains at least the item found by the binary search.
let diagnostic = diagnostics_on_line.max_by_key(|d| d.severity).unwrap();
write!(out, "●").unwrap();
return Some(match diagnostic.severity {
Some(Severity::Error) => error,

@ -1,15 +1,9 @@
use std::borrow::Cow;
use crate::{
graphics::Rect,
gutter::{self, Gutter},
Document, DocumentId, ViewId,
};
use helix_core::{
graphemes::{grapheme_width, RopeGraphemes},
line_ending::line_end_char_index,
visual_coords_at_pos, Position, RopeSlice, Selection,
};
use helix_core::{pos_at_visual_coords, visual_coords_at_pos, Position, RopeSlice, Selection};
use std::fmt;
@ -251,44 +245,21 @@ impl View {
return None;
}
let line_number = (row - inner.y) as usize + self.offset.row;
if line_number > text.len_lines() - 1 {
let text_row = (row - inner.y) as usize + self.offset.row;
if text_row > text.len_lines() - 1 {
return Some(text.len_chars());
}
let mut pos = text.line_to_char(line_number);
let current_line = text.line(line_number);
let text_col = (column - inner.x) as usize + self.offset.col;
let target = (column - inner.x) as usize + self.offset.col;
let mut col = 0;
// TODO: extract this part as pos_at_visual_coords
for grapheme in RopeGraphemes::new(current_line) {
if col >= target {
break;
}
let width = if grapheme == "\t" {
tab_width - (col % tab_width)
} else {
let grapheme = Cow::from(grapheme);
grapheme_width(&grapheme)
};
// If pos is in the middle of a wider grapheme (tab for example)
// return the starting offset.
if col + width > target {
break;
}
col += width;
// TODO: use byte pos that converts back to char pos?
pos += grapheme.chars().count();
}
Some(pos.min(line_end_char_index(&text.slice(..), line_number)))
Some(pos_at_visual_coords(
*text,
Position {
row: text_row,
col: text_col,
},
tab_width,
))
}
/// Translates a screen position to position in the text document.

@ -16,7 +16,7 @@
(pair
value: (_) @function.inside))?)?
(do_block (_)* @function.inside)?)
(#match? @_keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp|test|describe|setup)$")) @function.around
(#match? @_keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$")) @function.around
(anonymous_function
(stab_clause right: (body) @function.inside)) @function.around
@ -25,3 +25,9 @@
target: (identifier) @_keyword
(do_block (_)* @class.inside))
(#match? @_keyword "^(defmodule|defprotocol|defimpl)$")) @class.around
((call
target: (identifier) @_keyword
(arguments ((string) . (_)?))
(do_block (_)* @test.inside)?)
(#match? @_keyword "^(test|describe)$")) @test.around

@ -6,3 +6,11 @@
(stab_clause body: (_) @function.inside)) @function.around
(comment (comment_content) @comment.inside) @comment.around
; EUnit test names.
; (CommonTest cases are not recognizable by syntax alone.)
((function_clause
name: (atom) @_name
pattern: (arguments (_)? @parameter.inside)
body: (_) @test.inside) @test.around
(#match? @_name "_test$"))

@ -4,3 +4,8 @@
(anonymous_function
body: (function_body) @function.inside) @function.around
((function
name: (identifier) @_name
body: (function_body) @test.inside) @test.around
(#match? @_name "_test$"))

@ -26,3 +26,8 @@
(comment) @comment.inside
(comment)+ @comment.around
((function_declaration
name: (identifier) @_name
body: (block)? @test.inside) @test.around
(#match? @_name "^Test"))

@ -22,7 +22,15 @@
((regex_pattern) @injection.content
(#set! injection.language "regex"))
; Parse JSDoc annotations in comments
; Parse JSDoc annotations in multiline comments
((comment) @injection.content
(#set! injection.language "jsdoc"))
(#set! injection.language "jsdoc")
(#match? @injection.content "^/\\*+"))
; Parse general tags in single line comments
((comment) @injection.content
(#set! injection.language "comment")
(#match? @injection.content "^//"))

@ -0,0 +1,5 @@
; Parse general comment tags
((document) @injection.content
(#set! injection.include-children)
(#set! injection.language "comment"))

@ -16,3 +16,8 @@
(comment) @comment.inside
(comment)+ @comment.around
((function_definition
name: (identifier) @_name
body: (block)? @test.inside) @test.around
(#match? @_name "^test_"))

@ -77,3 +77,17 @@
(line_comment)+ @comment.around
(block_comment) @comment.around
(; #[test]
(attribute_item
(meta_item
(identifier) @_test_attribute))
; allow other attributes like #[should_panic] and comments
[
(attribute_item)
(line_comment)
]*
; the test function
(function_item
body: (_) @test.inside) @test.around
(#eq? @_test_attribute "test"))

@ -1,7 +1,7 @@
# Author: RayGervais <raygervais@hotmail.ca>
"ui.background" = { bg = "base00" }
"ui.virtual" = "base03"
"ui.virtual.whitespace" = "base03"
"ui.menu" = { fg = "base05", bg = "base01" }
"ui.menu.selected" = { fg = "base01", bg = "base04" }
"ui.linenr" = { fg = "base03", bg = "base01" }

@ -12,7 +12,7 @@
"ui.statusline" = { fg = "base04", bg = "base01" }
"ui.cursor" = { fg = "base04", modifiers = ["reversed"] }
"ui.cursor.primary" = { fg = "base05", modifiers = ["reversed"] }
"ui.virtual" = "base03"
"ui.virtual.whitespace" = "base03"
"ui.text" = "base05"
"operator" = "base05"
"ui.text.focus" = "base05"

@ -13,7 +13,7 @@
"ui.help" = { fg = "white", bg = "black" }
"ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] }
"ui.cursor.primary" = { fg = "light-gray", modifiers = ["reversed"] }
"ui.virtual" = "light-gray"
"ui.virtual.whitespace" = "light-gray"
"variable" = "light-red"
"constant.numeric" = "yellow"
"constant" = "yellow"

@ -53,7 +53,7 @@
"ui.text" = { fg = "#e5ded6" }
"ui.text.focus" = { fg = "#e5ded6", modifiers= ["bold"] }
"ui.virtual" = "#627d9d"
"ui.virtual.whitespace" = "#627d9d"
"ui.selection" = { bg = "#313f4e" }
# "ui.cursor.match" # TODO might want to override this because dimmed is not widely supported

@ -44,7 +44,7 @@
"ui.menu" = { fg = "lilac", bg = "berry_saturated" }
"ui.menu.selected" = { fg = "mint", bg = "berry_saturated" }
"ui.selection" = { bg = "berry_saturated" }
"ui.virtual" = { fg = "berry_desaturated" }
"ui.virtual.whitespace" = { fg = "berry_desaturated" }
"diff.plus" = { fg = "mint" }
"diff.delta" = { fg = "gold" }

@ -48,7 +48,7 @@ label = "peach"
"ui.text" = { fg = "pink" }
"ui.text.focus" = { fg = "white" }
"ui.virtual" = { fg = "gray_0" }
"ui.virtual.whitespace" = { fg = "gray_0" }
"ui.selection" = { bg = "#540099" }
"ui.selection.primary" = { bg = "#540099" }

@ -78,7 +78,7 @@
"ui.text" = { fg = "text" }
"ui.text.focus" = { fg = "white" }
"ui.virtual" = { fg = "dark_gray" }
"ui.virtual.whitespace" = { fg = "dark_gray" }
"ui.virtual.ruler" = { bg = "borders" }
"warning" = { fg = "gold2" }

@ -36,7 +36,7 @@
"ui.text" = { fg = "foreground" }
"ui.text.focus" = { fg = "cyan" }
"ui.window" = { fg = "foreground" }
"ui.virtual" = { fg = "comment" }
"ui.virtual.whitespace" = { fg = "comment" }
"error" = { fg = "red" }
"warning" = { fg = "cyan" }

@ -70,7 +70,7 @@
"ui.menu" = { fg = "fg", bg = "bg2" }
"ui.menu.selected" = { fg = "bg0", bg = "green" }
"ui.selection" = { bg = "bg3" }
"ui.virtual" = "grey0"
"ui.virtual.whitespace" = "grey0"
"hint" = "blue"
"info" = "aqua"

@ -70,7 +70,7 @@
"ui.menu" = { fg = "fg", bg = "bg2" }
"ui.menu.selected" = { fg = "bg0", bg = "green" }
"ui.selection" = { bg = "bg3" }
"ui.virtual" = "grey0"
"ui.virtual.whitespace" = "grey0"
"hint" = "blue"
"info" = "aqua"

@ -53,7 +53,7 @@
"ui.cursor.match" = { bg = "bg2" }
"ui.menu" = { fg = "fg1", bg = "bg2" }
"ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] }
"ui.virtual" = "bg2"
"ui.virtual.whitespace" = "bg2"
"diagnostic" = { modifiers = ["underlined"] }

@ -54,7 +54,7 @@
"ui.cursor.match" = { bg = "bg2" }
"ui.menu" = { fg = "fg1", bg = "bg2" }
"ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] }
"ui.virtual" = "bg2"
"ui.virtual.whitespace" = "bg2"
"diagnostic" = { modifiers = ["underlined"] }

@ -53,7 +53,7 @@
"ui.text" = { fg = "#7B91B3" }
"ui.text.focus" = { fg = "#250E07", modifiers= ["bold"] }
"ui.virtual" = "#A6B6CE"
"ui.virtual.whitespace" = "#A6B6CE"
"ui.selection" = { bg = "#540099" }
# "ui.cursor.match" # TODO might want to override this because dimmed is not widely supported

@ -32,7 +32,7 @@
"attribute" = { fg = "fn_declaration" }
"comment" = { fg = "#88846F" }
"ui.virtual" = "#88846F"
"ui.virtual.whitespace" = "#88846F"
"string" = { fg = "#e6db74" }
"constant.character" = { fg = "#e6db74" }

@ -6,7 +6,7 @@
"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
"ui.menu" = { fg = "base8", bg = "base3" }
"ui.menu.selected" = { fg = "base2", bg = "yellow" }
"ui.virtual" = "base5"
"ui.virtual.whitespace" = "base5"
"info" = "base8"
"hint" = "base8"

@ -6,7 +6,7 @@
"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
"ui.menu" = { fg = "base8", bg = "base3" }
"ui.menu.selected" = { fg = "base2", bg = "yellow" }
"ui.virtual" = "base5"
"ui.virtual.whitespace" = "base5"
"info" = "base8"
"hint" = "base8"

@ -6,7 +6,7 @@
"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
"ui.menu" = { fg = "base8", bg = "base3" }
"ui.menu.selected" = { fg = "base2", bg = "yellow" }
"ui.virtual" = "base5"
"ui.virtual.whitespace" = "base5"
"info" = "base8"
"hint" = "base8"

@ -6,7 +6,7 @@
"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
"ui.menu" = { fg = "base8", bg = "base3" }
"ui.menu.selected" = { fg = "base2", bg = "yellow" }
"ui.virtual" = "base5"
"ui.virtual.whitespace" = "base5"
"info" = "base8"
"hint" = "base8"

@ -6,7 +6,7 @@
"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
"ui.menu" = { fg = "base8", bg = "base3" }
"ui.menu.selected" = { fg = "base2", bg = "yellow" }
"ui.virtual" = "base5"
"ui.virtual.whitespace" = "base5"
"info" = "base8"
"hint" = "base8"

@ -0,0 +1,80 @@
# Author: Joseph Harrison-Lim <josephharrisonlim@gmail.com>
"attributes" = { fg = "#7060eb", modifiers = ["bold"] }
"comment" = { fg = "base03", modifiers = ["italic"] }
"comment.block.documentation" = { fg = "base06", modifiers = ["italic"] }
"constant" = "base09"
"constant.character.escape" = "base0C"
"constant.numeric" = "#7060eb"
"constructor" = "base0D"
"function" = "base0D"
"keyword" = "base0E"
"keyword.control" = { fg = "base0E", modifiers = ["bold"] }
"keyword.directive" = "white"
"keyword.import" = { fg = "#df769b" }
"keyword.operator" = { fg = "base0E", modifiers = ["italic"] }
"label" = "base0E"
"namespace" = "base0E"
"operator" = "base05"
"string" = "base0B"
"type" = "base10"
"variable" = "base08"
"variable.other.member" = "base08"
"special" = "base0D"
"ui.background" = { bg = "base00" }
"ui.virtual" = "base03"
"ui.menu" = { fg = "base05", bg = "base01" }
"ui.menu.selected" = { fg = "base0B", bg = "base01" }
"ui.popup" = { bg = "base01" }
"ui.window" = { bg = "base01" }
"ui.linenr" = { fg = "#715b63", bg = "base01" }
"ui.linenr.selected" = { fg = "base02", bg = "base01", modifiers = ["bold"] }
"ui.selection" = { fg = "base05", bg = "base02" }
"ui.statusline" = { fg = "base02", bg = "base01" }
"ui.cursor" = { fg = "base04", modifiers = ["reversed"] }
"ui.cursor.primary" = { fg = "base05", modifiers = ["reversed"] }
"ui.text" = "base05"
"ui.text.focus" = "base05"
"ui.cursor.match" = { fg = "base0A", modifiers = ["underlined"] }
"ui.help" = { fg = "base06", bg = "base01" }
"markup.bold" = { fg = "base0A", modifiers = ["bold"] }
"markup.heading" = "base0D"
"markup.italic" = { fg = "base0E", modifiers = ["italic"] }
"markup.link.text" = "base08"
"markup.link.url" = { fg = "base09", modifiers = ["underlined"] }
"markup.list" = "base08"
"markup.quote" = "base0C"
"markup.raw" = "base0B"
"diff.delta" = "base09"
"diff.plus" = "base0B"
"diff.minus" = "base08"
"diagnostic" = { modifiers = ["underlined"] }
"ui.gutter" = { bg = "base01" }
"info" = "base0D"
"hint" = "base03"
"debug" = "base03"
"warning" = "base09"
"error" = "base08"
[palette]
base00 = "#322a2d" # Default Background
base01 = "#2c2528" # Lighter Background (Used for status bars, line number and folding marks)
base02 = "#997582" # Selection Background
base03 = "#585858" # Comments, Invisibles, Line Highlighting
base04 = "#322a2d" # Dark Foreground (Used for status bars)
base05 = "#cbbec2" # Default Foreground, Caret, Delimiters, Operators
base06 = "#e8e8e8" # Light Foreground (Not often used)
base07 = "#f8f8f8" # Light Background (Not often used)
base08 = "#e4b781" # Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted
base09 = "#d5971a" # Integers, Boolean, Constants, XML Attributes, Markup Link Url
base0A = "#df769b" # Classes, Markup Bold, Search Text Background
base0B = "#49e9a6" # Strings, Inherited Class, Markup Code, Diff Inserted
base0C = "#16b673" # Support, Regular Expressions, Escape Characters, Markup Quotes
base0D = "#16a3b6" # Functions, Methods, Attribute IDs, Headings
base0E = "#ba8baf" # Keywords, Storage, Selector, Markup Italic, Diff Changed
base0F = "#d67e5c" # Deprecated, Opening/Closing Embedded Language Tags, e.g. <?php ?>
base10 = "#b0b0ff" # Types

@ -4,7 +4,7 @@
"ui.text.focus" = { fg = "nord8", modifiers= ["bold"] }
"ui.menu" = { fg = "nord6", bg = "#232d38" }
"ui.menu.selected" = { fg = "nord8", bg = "nord2" }
"ui.virtual" = "gray"
"ui.virtual.whitespace" = "gray"
"info" = "nord8"
"hint" = "nord8"

@ -14,7 +14,7 @@
"ui.text" = { fg = "text" }
"ui.text.focus" = { fg = "foam", modifiers = ["bold"]}
"ui.text.info" = {fg = "pine", modifiers = ["bold"]}
"ui.virtual" = "highlight"
"ui.virtual.whitespace" = "highlight"
"operator" = "rose"
"variable" = "text"
"constant.numeric" = "iris"

@ -14,7 +14,7 @@
"ui.text" = { fg = "text" }
"ui.text.focus" = { fg = "foam", modifiers = ["bold"]}
"ui.text.info" = {fg = "pine", modifiers = ["bold"]}
"ui.virtual" = "highlight"
"ui.virtual.whitespace" = "highlight"
"operator" = "rose"
"variable" = "text"
"number" = "iris"

@ -50,7 +50,7 @@
"ui.menu" = { fg = "fg", bg = "bg2" }
"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
"ui.selection" = { bg = "bg3" }
"ui.virtual" = "grey2"
"ui.virtual.whitespace" = "grey2"
"hint" = "blue"
"info" = "aqua"

@ -50,7 +50,7 @@
"ui.menu" = { fg = "bg0", bg = "bg3" }
"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
"ui.selection" = { fg = "bg0", bg = "bg3" }
"ui.virtual" = { fg = "bg2" }
"ui.virtual.whitespace" = { fg = "bg2" }
"hint" = "blue"
"info" = "aqua"

@ -38,7 +38,7 @@
"ui.text" = { fg = "foreground" }
"ui.text.focus" = { fg = "cyan" }
"ui.window" = { fg = "foreground" }
"ui.virtual" = { fg = "comment" }
"ui.virtual.whitespace" = { fg = "comment" }
"error" = { fg = "red" }
"warning" = { fg = "cyan" }

@ -39,7 +39,7 @@
# 背景
"ui.background" = { bg = "base03" }
"ui.virtual" = { fg = "base01" }
"ui.virtual.whitespace" = { fg = "base01" }
# 行号栏
"ui.linenr" = { fg = "base0", bg = "base02" }

@ -40,7 +40,7 @@
# background
"ui.background" = { bg = "base03" }
"ui.virtual" = { fg = "base01" }
"ui.virtual.whitespace" = { fg = "base01" }
# 行号栏
# line number column

@ -64,7 +64,7 @@
"ui.cursor.match" = { bg = "bg3" }
"ui.menu" = { fg = "fg1", bg = "bg2" }
"ui.menu.selected" = { fg = "#655370", bg = "#d1dcdf", modifiers = ["bold"] }
"ui.virtual" = "bg2"
"ui.virtual.whitespace" = "bg2"
"diagnostic" = { modifiers = ["underlined"] }

Loading…
Cancel
Save