on master help sign in
Merge remote-tracking branch 'origin/master' into debug
commit9ed930b2335b86d03e871b52a958d4e9768e0d34 authorBlaž Hrastnik <blaz@mxxn.io> dateTue 30 Nov 2021, 13:06 (5 years ago) parent72576829429622
34 files changed+1098−506
.github/ISSUE_TEMPLATE/bug_report.md+1−1 .github/workflows/build.yml+9−9 .gitmodules+8 Cargo.lock+18−19 README.md+1−1 book/src/configuration.md+12 book/src/install.md+1−3 book/src/keymap.md+42−36 book/src/remapping.md+2−1 book/src/themes.md+3−2 book/src/usage.md+2 helix-core/src/diagnostic.rs+2−2 helix-core/src/match_brackets.rs+66−29 helix-core/src/register.rs+11−3 helix-core/src/selection.rs+3−3 helix-core/src/surround.rs+83−65 helix-core/src/textobject.rs+6−4 helix-lsp/Cargo.toml+1−1 helix-syntax/languages/tree-sitter-wgsl+1 helix-term/src/application.rs+2−2 helix-term/src/commands.rs+265−63 helix-term/src/keymap.rs+8−3 helix-term/src/ui/editor.rs+127−162 helix-term/src/ui/markdown.rs+5−2 helix-term/src/ui/mod.rs+10−1 helix-view/src/editor.rs+128−76 helix-view/src/gutter.rs+95 helix-view/src/lib.rs+13−2 helix-view/src/view.rs+20−4 languages.toml+25 runtime/queries/llvm/highlights.scm+14 runtime/queries/wgsl/highlights.scm+102 runtime/themes/solarized_dark.toml+6−6 runtime/themes/solarized_light.toml+6−6
.github/ISSUE_TEMPLATE/bug_report.md+1−1
@@ -17,7 +17,7 @@ Please search on the issue tracker before creating one. -->
1717### Environment
1818
1919- Platform: <!-- macOS / Windows / Linux -->
20−- Helix version: <!-- 'hx -v' if using a release, 'git describe' if building from master -->
20+- Helix version: <!-- 'hx -V' if using a release, 'git describe' if building from master -->
2121
2222<details><summary>~/.cache/helix/helix.log</summary>
2323
.github/workflows/build.yml+9−9
@@ -25,19 +25,19 @@ jobs:
2525 override: true
2626
2727 - name: Cache cargo registry
28− uses: actions/cache@v2.1.6
28+ uses: actions/cache@v2.1.7
2929 with:
3030 path: ~/.cargo/registry
3131 key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
3232
3333 - name: Cache cargo index
34− uses: actions/cache@v2.1.6
34+ uses: actions/cache@v2.1.7
3535 with:
3636 path: ~/.cargo/git
3737 key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
3838
3939 - name: Cache cargo target dir
40− uses: actions/cache@v2.1.6
40+ uses: actions/cache@v2.1.7
4141 with:
4242 path: target
4343 key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
@@ -64,19 +64,19 @@ jobs:
6464 override: true
6565
6666 - name: Cache cargo registry
67− uses: actions/cache@v2.1.6
67+ uses: actions/cache@v2.1.7
6868 with:
6969 path: ~/.cargo/registry
7070 key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
7171
7272 - name: Cache cargo index
73− uses: actions/cache@v2.1.6
73+ uses: actions/cache@v2.1.7
7474 with:
7575 path: ~/.cargo/git
7676 key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
7777
7878 - name: Cache cargo target dir
79− uses: actions/cache@v2.1.6
79+ uses: actions/cache@v2.1.7
8080 with:
8181 path: target
8282 key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
@@ -109,19 +109,19 @@ jobs:
109109 components: rustfmt, clippy
110110
111111 - name: Cache cargo registry
112− uses: actions/cache@v2.1.6
112+ uses: actions/cache@v2.1.7
113113 with:
114114 path: ~/.cargo/registry
115115 key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
116116
117117 - name: Cache cargo index
118− uses: actions/cache@v2.1.6
118+ uses: actions/cache@v2.1.7
119119 with:
120120 path: ~/.cargo/git
121121 key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
122122
123123 - name: Cache cargo target dir
124− uses: actions/cache@v2.1.6
124+ uses: actions/cache@v2.1.7
125125 with:
126126 path: target
127127 key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
.gitmodules+8
@@ -142,3 +142,11 @@
142142 path = helix-syntax/languages/tree-sitter-perl
143143 url = https://github.com/ganezdragon/tree-sitter-perl
144144 shallow = true
145+[submodule "helix-syntax/languages/tree-sitter-wgsl"]
146+ path = helix-syntax/languages/tree-sitter-wgsl
147+ url = https://github.com/szebniok/tree-sitter-wgsl
148+ shallow = true
149+[submodule "helix-syntax/tree-sitter-llvm"]
150+ path = helix-syntax/languages/tree-sitter-llvm
151+ url = https://github.com/benwilliamgraham/tree-sitter-llvm
152+ shallow = true
Cargo.lock+18−19
@@ -13,9 +13,9 @@ dependencies = [
1313
1414[[package]]
1515name = "anyhow"
16−version = "1.0.46"
16+version = "1.0.51"
1717source = "registry+https://github.com/rust-lang/crates.io-index"
18−checksum = "3aa828229c44c0293dd7d4d2300bdfc4d2883ffdba934c069a6b968957a81f70"
18+checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203"
1919
2020[[package]]
2121name = "arc-swap"
@@ -258,15 +258,15 @@ dependencies = [
258258
259259[[package]]
260260name = "futures-core"
261−version = "0.3.17"
261+version = "0.3.18"
262262source = "registry+https://github.com/rust-lang/crates.io-index"
263−checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d"
263+checksum = "629316e42fe7c2a0b9a65b47d159ceaa5453ab14e8f0a3c5eedbb8cd55b4a445"
264264
265265[[package]]
266266name = "futures-executor"
267−version = "0.3.17"
267+version = "0.3.18"
268268source = "registry+https://github.com/rust-lang/crates.io-index"
269−checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c"
269+checksum = "7b808bf53348a36cab739d7e04755909b9fcaaa69b7d7e588b37b6ec62704c97"
270270dependencies = [
271271 "futures-core",
272272 "futures-task",
@@ -275,17 +275,16 @@ dependencies = [
275275
276276[[package]]
277277name = "futures-task"
278−version = "0.3.17"
278+version = "0.3.18"
279279source = "registry+https://github.com/rust-lang/crates.io-index"
280−checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99"
280+checksum = "dabf1872aaab32c886832f2276d2f5399887e2bd613698a02359e4ea83f8de12"
281281
282282[[package]]
283283name = "futures-util"
284−version = "0.3.17"
284+version = "0.3.18"
285285source = "registry+https://github.com/rust-lang/crates.io-index"
286−checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481"
286+checksum = "41d22213122356472061ac0f1ab2cee28d2bac8491410fd68c2af53d1cedb83e"
287287dependencies = [
288− "autocfg",
289288 "futures-core",
290289 "futures-task",
291290 "pin-project-lite",
@@ -914,9 +913,9 @@ dependencies = [
914913
915914[[package]]
916915name = "serde_json"
917−version = "1.0.70"
916+version = "1.0.72"
918917source = "registry+https://github.com/rust-lang/crates.io-index"
919−checksum = "e277c495ac6cd1a01a58d0a0c574568b4d1ddf14f59965c6a58b8d96400b54f3"
918+checksum = "d0ffa0837f2dfa6fb90868c2b5468cad482e175f7dad97e7421951e663f2b527"
920919dependencies = [
921920 "itoa",
922921 "ryu",
@@ -1086,9 +1085,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
10861085
10871086[[package]]
10881087name = "tokio"
1089−version = "1.13.1"
1088+version = "1.14.0"
10901089source = "registry+https://github.com/rust-lang/crates.io-index"
1091−checksum = "52963f91310c08d91cb7bff5786dfc8b79642ab839e188187e92105dbfb9d2c8"
1090+checksum = "70e992e41e0d2fb9f755b37446f20900f64446ef54874f40a60c78f021ac6144"
10921091dependencies = [
10931092 "autocfg",
10941093 "bytes",
@@ -1106,9 +1105,9 @@ dependencies = [
11061105
11071106[[package]]
11081107name = "tokio-macros"
1109−version = "1.5.0"
1108+version = "1.6.0"
11101109source = "registry+https://github.com/rust-lang/crates.io-index"
1111−checksum = "b2dd85aeaba7b68df939bd357c6afb36c87951be9e80bf9c859f2fc3e9fca0fd"
1110+checksum = "c9efc1aba077437943f7515666aa2b882dfabfbfdf89c819ea75a8d6e9eaba5e"
11121111dependencies = [
11131112 "proc-macro2",
11141113 "quote",
@@ -1137,9 +1136,9 @@ dependencies = [
11371136
11381137[[package]]
11391138name = "tree-sitter"
1140−version = "0.20.0"
1139+version = "0.20.1"
11411140source = "registry+https://github.com/rust-lang/crates.io-index"
1142−checksum = "63ec02a07a782abef91279b72fe8fd2bee4c168a22112cedec5d3b0d49b9e4f9"
1141+checksum = "9394e9dbfe967b5f3d6ab79e302e78b5fb7b530c368d634ff3b8d67ede138bf1"
11431142dependencies = [
11441143 "cc",
11451144 "regex",
README.md+1−1
@@ -69,7 +69,7 @@ Contributors are very welcome! **No contribution is too small and all contributi
6969
7070Some suggestions to get started:
7171
72−- You can look at the [good first issue](https://github.com/helix-editor/helix/labels/E-easy) label on the issue tracker.
72+- You can look at the [good first issue](https://github.com/helix-editor/helix/issues?q=is%3Aopen+label%3AE-easy+label%3AE-good-first-issue) label on the issue tracker.
7373- Help with packaging on various distributions needed!
7474- To use print debugging to the [Helix log file](https://github.com/helix-editor/helix/wiki/FAQ#access-the-log-file), you must:
7575 * Print using `log::info!`, `warn!`, or `error!`. (`log::info!("helix!")`)
book/src/configuration.md+12
@@ -24,6 +24,18 @@ To override global configuration parameters, create a `config.toml` file located
2424| `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` |
2525| `auto-info` | Whether to display infoboxes | `true` |
2626
27+`[editor.filepicker]` section of the config. Sets options for file picker and global search. All but the last key listed in the default file-picker configuration below are IgnoreOptions: whether hidden files and files listed within ignore files are ignored by (not visible in) the helix file picker and global search. There is also one other key, `max-depth` available, which is not defined by default.
28+
29+| Key | Description | Default |
30+|--|--|---------|
31+|`hidden` | Enables ignoring hidden files. | true
32+|`parents` | Enables reading ignore files from parent directories. | true
33+|`ignore` | Enables reading `.ignore` files. | true
34+|`git-ignore` | Enables reading `.gitignore` files. | true
35+|`git-global` | Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option. | true
36+|`git-exclude` | Enables reading `.git/info/exclude` files. | true
37+|`max-depth` | Set with an integer value for maximum depth to recurse. | Defaults to `None`.
38+
2739## LSP
2840
2941To display all language server messages in the status line add the following to your `config.toml`:
book/src/install.md+1−3
@@ -25,9 +25,7 @@ shell for working on Helix.
2525
2626Releases are available in the `community` repository.
2727
28−Packages are also available on AUR:
29−- [helix-bin](https://aur.archlinux.org/packages/helix-bin/) contains the pre-built release
30−- [helix-git](https://aur.archlinux.org/packages/helix-git/) builds the master branch
28+A [helix-git](https://aur.archlinux.org/packages/helix-git/) package is also available on the AUR, which builds the master branch.
3129
3230## Build from source
3331
book/src/keymap.md+42−36
@@ -45,44 +45,46 @@
4545
4646### Changes
4747
48−| Key | Description | Command |
49−| ----- | ----------- | ------- |
50−| `r` | Replace with a character | `replace` |
51−| `R` | Replace with yanked text | `replace_with_yanked` |
52−| `~` | Switch case of the selected text | `switch_case` |
53−| `` ` `` | Set the selected text to lower case | `switch_to_lowercase` |
54−| `` Alt-` `` | Set the selected text to upper case | `switch_to_uppercase` |
55−| `i` | Insert before selection | `insert_mode` |
56−| `a` | Insert after selection (append) | `append_mode` |
57−| `I` | Insert at the start of the line | `prepend_to_line` |
58−| `A` | Insert at the end of the line | `append_to_line` |
59−| `o` | Open new line below selection | `open_below` |
60−| `O` | Open new line above selection | `open_above` |
61−| `.` | Repeat last change | N/A |
62−| `u` | Undo change | `undo` |
63−| `U` | Redo change | `redo` |
64−| `Alt-u` | Move backward in history | `earlier` |
65−| `Alt-U` | Move forward in history | `later` |
66−| `y` | Yank selection | `yank` |
67−| `p` | Paste after selection | `paste_after` |
68−| `P` | Paste before selection | `paste_before` |
69−| `"` `<reg>` | Select a register to yank to or paste from | `select_register` |
70−| `>` | Indent selection | `indent` |
71−| `<` | Unindent selection | `unindent` |
72−| `=` | Format selection (**LSP**) | `format_selections` |
73−| `d` | Delete selection | `delete_selection` |
74−| `c` | Change selection (delete and enter insert mode) | `change_selection` |
75−| `Ctrl-a` | Increment object (number) under cursor | `increment` |
76−| `Ctrl-x` | Decrement object (number) under cursor | `decrement` |
48+| Key | Description | Command |
49+| ----- | ----------- | ------- |
50+| `r` | Replace with a character | `replace` |
51+| `R` | Replace with yanked text | `replace_with_yanked` |
52+| `~` | Switch case of the selected text | `switch_case` |
53+| `` ` `` | Set the selected text to lower case | `switch_to_lowercase` |
54+| `` Alt-` `` | Set the selected text to upper case | `switch_to_uppercase` |
55+| `i` | Insert before selection | `insert_mode` |
56+| `a` | Insert after selection (append) | `append_mode` |
57+| `I` | Insert at the start of the line | `prepend_to_line` |
58+| `A` | Insert at the end of the line | `append_to_line` |
59+| `o` | Open new line below selection | `open_below` |
60+| `O` | Open new line above selection | `open_above` |
61+| `.` | Repeat last change | N/A |
62+| `u` | Undo change | `undo` |
63+| `U` | Redo change | `redo` |
64+| `Alt-u` | Move backward in history | `earlier` |
65+| `Alt-U` | Move forward in history | `later` |
66+| `y` | Yank selection | `yank` |
67+| `p` | Paste after selection | `paste_after` |
68+| `P` | Paste before selection | `paste_before` |
69+| `"` `<reg>` | Select a register to yank to or paste from | `select_register` |
70+| `>` | Indent selection | `indent` |
71+| `<` | Unindent selection | `unindent` |
72+| `=` | Format selection (**LSP**) | `format_selections` |
73+| `d` | Delete selection | `delete_selection` |
74+| `Alt-d` | Delete selection, without yanking | `delete_selection_noyank` |
75+| `c` | Change selection (delete and enter insert mode) | `change_selection` |
76+| `Alt-c` | Change selection (delete and enter insert mode, without yanking) | `change_selection_noyank` |
77+| `Ctrl-a` | Increment object (number) under cursor | `increment` |
78+| `Ctrl-x` | Decrement object (number) under cursor | `decrement` |
7779
7880#### Shell
7981
80−| Key | Description | Command |
81−| ------ | ----------- | ------- |
82−| <code>&#124;</code> | Pipe each selection through shell command, replacing with output | `shell_pipe` |
83−| <code>A-&#124;</code> | Pipe each selection into shell command, ignoring output | `shell_pipe_to` |
84−| `!` | Run shell command, inserting output before each selection | `shell_insert_output` |
85−| `A-!` | Run shell command, appending output after each selection | `shell_append_output` |
82+| Key | Description | Command |
83+| ------ | ----------- | ------- |
84+| <code>&#124;</code> | Pipe each selection through shell command, replacing with output | `shell_pipe` |
85+| <code>Alt-&#124;</code> | Pipe each selection into shell command, ignoring output | `shell_pipe_to` |
86+| `!` | Run shell command, inserting output before each selection | `shell_insert_output` |
87+| `Alt-!` | Run shell command, appending output after each selection | `shell_append_output` |
8688
8789
8890### Selection manipulation
@@ -92,6 +94,7 @@
9294| `s` | Select all regex matches inside selections | `select_regex` |
9395| `S` | Split selection into subselections on regex matches | `split_selection` |
9496| `Alt-s` | Split selection on newlines | `split_selection_on_newline` |
97+| `&` | Align selection in columns | `align_selections` |
9598| `_` | Trim whitespace from the selection | `trim_selections` |
9699| `;` | Collapse selection onto a single cursor | `collapse_selection` |
97100| `Alt-;` | Flip selection cursor and anchor | `flip_selections` |
@@ -157,6 +160,7 @@ Jumps to various locations.
157160| ----- | ----------- | ------- |
158161| `g` | Go to the start of the file | `goto_file_start` |
159162| `e` | Go to the end of the file | `goto_last_line` |
163+| `f` | Go to files in the selection | `goto_file` |
160164| `h` | Go to the start of the line | `goto_line_start` |
161165| `l` | Go to the end of the line | `goto_line_end` |
162166| `s` | Go to first non-whitespace character of the line | `goto_first_nonwhitespace` |
@@ -199,6 +203,8 @@ This layer is similar to vim keybindings as kakoune does not support window.
199203| `v`, `Ctrl-v` | Vertical right split | `vsplit` |
200204| `s`, `Ctrl-s` | Horizontal bottom split | `hsplit` |
201205| `h`, `Ctrl-h`, `left` | Move to left split | `jump_view_left` |
206+| `f` | Go to files in the selection in horizontal splits | `goto_file` |
207+| `F` | Go to files in the selection in vertical splits | `goto_file` |
202208| `j`, `Ctrl-j`, `down` | Move to split below | `jump_view_down` |
203209| `k`, `Ctrl-k`, `up` | Move to split above | `jump_view_up` |
204210| `l`, `Ctrl-l`, `right` | Move to right split | `jump_view_right` |
@@ -314,7 +320,7 @@ Keys to use within prompt, Remapping currently not supported.
314320| `Ctrl-u` | Delete to start of line |
315321| `Ctrl-k` | Delete to end of line |
316322| `backspace`, `Ctrl-h` | Delete previous char |
317−| `delete`, `Ctrl-d` | Delete previous char |
323+| `delete`, `Ctrl-d` | Delete next char |
318324| `Ctrl-s` | Insert a word under doc cursor, may be changed to Ctrl-r Ctrl-w later |
319325| `Ctrl-p`, `Up` | Select previous history |
320326| `Ctrl-n`, `Down` | Select next history |
book/src/remapping.md+2−1
@@ -53,4 +53,5 @@ Control, Shift and Alt modifiers are encoded respectively with the prefixes
5353
5454Keys can be disabled by binding them to the `no_op` command.
5555
56−Commands can be found in the source code at [`helix-term/src/commands.rs`](https://github.com/helix-editor/helix/blob/master/helix-term/src/commands.rs)
56+Commands can be found at [Keymap](https://docs.helix-editor.com/keymap.html) Commands.
57+> Commands can also be found in the source code at [`helix-term/src/commands.rs`](https://github.com/helix-editor/helix/blob/master/helix-term/src/commands.rs) at the invocation of `commands!` macro.
book/src/themes.md+3−2
@@ -145,11 +145,12 @@ We use a similar set of scopes as
145145 - `conditional` - `if`, `else`
146146 - `repeat` - `for`, `while`, `loop`
147147 - `import` - `import`, `export`
148− - (TODO: return?)
148+ - `return`
149+ - `operator` - `or`, `in`
149150 - `directive` - Preprocessor directives (`#if` in C)
150151 - `function` - `fn`, `func`
151152
152−- `operator` - `||`, `+=`, `>`, `or`
153+- `operator` - `||`, `+=`, `>`
153154
154155- `function`
155156 - `builtin`
book/src/usage.md+2
@@ -23,8 +23,10 @@ If there is a selected register before invoking a change or delete command, the
2323| `/` | Last search |
2424| `:` | Last executed command |
2525| `"` | Last yanked text |
26+| `_` | Black hole |
2627
2728> There is no special register for copying to system clipboard, instead special commands and keybindings are provided. See the [keymap](keymap.md#space-mode) for the specifics.
29+> The black hole register works as a no-op register, meaning no data will be written to / read from it.
2830
2931## Surround
3032
helix-core/src/diagnostic.rs+2−2
@@ -1,7 +1,7 @@
11//! LSP diagnostic utility types.
22
33/// Describes the severity level of a [`Diagnostic`].
4−#[derive(Debug, Eq, PartialEq)]
4+#[derive(Debug, Clone, Copy, Eq, PartialEq)]
55pub enum Severity {
66 Error,
77 Warning,
@@ -17,7 +17,7 @@ pub struct Range {
1717}
1818
1919/// Corresponds to [`lsp_types::Diagnostic`](https://docs.rs/lsp-types/0.91.0/lsp_types/struct.Diagnostic.html)
20−#[derive(Debug)]
20+#[derive(Debug, Clone)]
2121pub struct Diagnostic {
2222 pub range: Range,
2323 pub line: usize,
helix-core/src/match_brackets.rs+66−29
@@ -1,3 +1,5 @@
1+use tree_sitter::Node;
2+
13use crate::{Rope, Syntax};
24
35const PAIRS: &[(char, char)] = &[
@@ -6,50 +8,85 @@ const PAIRS: &[(char, char)] = &[
68 ('[', ']'),
79 ('<', '>'),
810 ('\'', '\''),
9− ('"', '"'),
11+ ('\"', '\"'),
1012];
13+
1114// limit matching pairs to only ( ) { } [ ] < >
1215
16+// Returns the position of the matching bracket under cursor.
17+//
18+// If the cursor is one the opening bracket, the position of
19+// the closing bracket is returned. If the cursor in the closing
20+// bracket, the position of the opening bracket is returned.
21+//
22+// If the cursor is not on a bracket, `None` is returned.
23+#[must_use]
24+pub fn find_matching_bracket(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
25+ if pos >= doc.len_chars() || !is_valid_bracket(doc.char(pos)) {
26+ return None;
27+ }
28+ find_pair(syntax, doc, pos, false)
29+}
30+
31+// Returns the position of the bracket that is closing the current scope.
32+//
33+// If the cursor is on an opening or closing bracket, the function
34+// behaves equivalent to [`find_matching_bracket`].
35+//
36+// If the cursor position is within a scope, the function searches
37+// for the surrounding scope that is surrounded by brackets and
38+// returns the position of the closing bracket for that scope.
39+//
40+// If no surrounding scope is found, the function returns `None`.
1341#[must_use]
14−pub fn find(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
42+pub fn find_matching_bracket_fuzzy(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
43+ find_pair(syntax, doc, pos, true)
44+}
45+
46+fn find_pair(syntax: &Syntax, doc: &Rope, pos: usize, traverse_parents: bool) -> Option<usize> {
1547 let tree = syntax.tree();
48+ let pos = doc.char_to_byte(pos);
1649
17− let byte_pos = doc.char_to_byte(pos);
50+ let mut node = tree.root_node().named_descendant_for_byte_range(pos, pos)?;
1851
19− // most naive implementation: find the innermost syntax node, if we're at the edge of a node,
20− // return the other edge.
52+ loop {
53+ let (start_byte, end_byte) = surrounding_bytes(doc, &node)?;
54+ let (start_char, end_char) = (doc.byte_to_char(start_byte), doc.byte_to_char(end_byte));
2155
22− let node = match tree
23− .root_node()
24− .named_descendant_for_byte_range(byte_pos, byte_pos)
25− {
26− Some(node) => node,
27− None => return None,
28− };
56+ if is_valid_pair(doc, start_char, end_char) {
57+ if end_byte == pos {
58+ return Some(start_char);
59+ }
60+ // We return the end char if the cursor is either on the start char
61+ // or at some arbitrary position between start and end char.
62+ return Some(end_char);
63+ }
2964
30− if node.is_error() {
31− return None;
65+ if traverse_parents {
66+ node = node.parent()?;
67+ } else {
68+ return None;
69+ }
3270 }
71+}
3372
73+fn is_valid_bracket(c: char) -> bool {
74+ PAIRS.iter().any(|(l, r)| *l == c || *r == c)
75+}
76+
77+fn is_valid_pair(doc: &Rope, start_char: usize, end_char: usize) -> bool {
78+ PAIRS.contains(&(doc.char(start_char), doc.char(end_char)))
79+}
80+
81+fn surrounding_bytes(doc: &Rope, node: &Node) -> Option<(usize, usize)> {
3482 let len = doc.len_bytes();
83+
3584 let start_byte = node.start_byte();
36− let end_byte = node.end_byte().saturating_sub(1); // it's end exclusive
85+ let end_byte = node.end_byte().saturating_sub(1);
86+
3787 if start_byte >= len || end_byte >= len {
3888 return None;
3989 }
4090
41− let start_char = doc.byte_to_char(start_byte);
42− let end_char = doc.byte_to_char(end_byte);
43−
44− if PAIRS.contains(&(doc.char(start_char), doc.char(end_char))) {
45− if start_byte == byte_pos {
46− return Some(end_char);
47− }
48−
49− if end_byte == byte_pos {
50− return Some(start_char);
51− }
52− }
53−
54− None
91+ Some((start_byte, end_byte))
5592}
helix-core/src/register.rs+11−3
@@ -15,7 +15,11 @@ impl Register {
1515 }
1616
1717 pub fn new_with_values(name: char, values: Vec<String>) -> Self {
18− Self { name, values }
18+ if name == '_' {
19+ Self::new(name)
20+ } else {
21+ Self { name, values }
22+ }
1923 }
2024
2125 pub const fn name(&self) -> char {
@@ -27,11 +31,15 @@ impl Register {
2731 }
2832
2933 pub fn write(&mut self, values: Vec<String>) {
30− self.values = values;
34+ if self.name != '_' {
35+ self.values = values;
36+ }
3137 }
3238
3339 pub fn push(&mut self, value: String) {
34− self.values.push(value);
40+ if self.name != '_' {
41+ self.values.push(value);
42+ }
3543 }
3644}
3745
helix-core/src/selection.rs+3−3
@@ -308,10 +308,10 @@ impl Range {
308308}
309309
310310impl From<(usize, usize)> for Range {
311− fn from(tuple: (usize, usize)) -> Self {
311+ fn from((anchor, head): (usize, usize)) -> Self {
312312 Self {
313− anchor: tuple.0,
314− head: tuple.1,
313+ anchor,
314+ head,
315315 horiz: None,
316316 }
317317 }
helix-core/src/surround.rs+83−65
@@ -1,4 +1,4 @@
1−use crate::{search, Selection};
1+use crate::{search, Range, Selection};
22use ropey::RopeSlice;
33
44pub const PAIRS: &[(char, char)] = &[
@@ -35,33 +35,27 @@ pub fn get_pair(ch: char) -> (char, char) {
3535pub fn find_nth_pairs_pos(
3636 text: RopeSlice,
3737 ch: char,
38− pos: usize,
38+ range: Range,
3939 n: usize,
4040) -> Option<(usize, usize)> {
41− let (open, close) = get_pair(ch);
42−
43− if text.len_chars() < 2 || pos >= text.len_chars() {
41+ if text.len_chars() < 2 || range.to() >= text.len_chars() {
4442 return None;
4543 }
4644
45+ let (open, close) = get_pair(ch);
46+ let pos = range.cursor(text);
47+
4748 if open == close {
4849 if Some(open) == text.get_char(pos) {
49− // Special case: cursor is directly on a matching char.
50− match pos {
51− 0 => Some((pos, search::find_nth_next(text, close, pos + 1, n)?)),
52− _ if (pos + 1) == text.len_chars() => {
53− Some((search::find_nth_prev(text, open, pos, n)?, pos))
54− }
55− // We return no match because there's no way to know which
56− // side of the char we should be searching on.
57− _ => None,
58− }
59− } else {
60− Some((
61− search::find_nth_prev(text, open, pos, n)?,
62− search::find_nth_next(text, close, pos, n)?,
63− ))
50+ // Cursor is directly on match char. We return no match
51+ // because there's no way to know which side of the char
52+ // we should be searching on.
53+ return None;
6454 }
55+ Some((
56+ search::find_nth_prev(text, open, pos, n)?,
57+ search::find_nth_next(text, close, pos, n)?,
58+ ))
6559 } else {
6660 Some((
6761 find_nth_open_pair(text, open, close, pos, n)?,
@@ -160,8 +154,8 @@ pub fn get_surround_pos(
160154) -> Option<Vec<usize>> {
161155 let mut change_pos = Vec::new();
162156
163− for range in selection {
164− let (open_pos, close_pos) = find_nth_pairs_pos(text, ch, range.head, skip)?;
157+ for &range in selection {
158+ let (open_pos, close_pos) = find_nth_pairs_pos(text, ch, range, skip)?;
165159 if change_pos.contains(&open_pos) || change_pos.contains(&close_pos) {
166160 return None;
167161 }
@@ -178,67 +172,91 @@ mod test {
178172 use ropey::Rope;
179173 use smallvec::SmallVec;
180174
181− #[test]
182− fn test_find_nth_pairs_pos() {
183− let doc = Rope::from("some (text) here");
175+ fn check_find_nth_pair_pos(
176+ text: &str,
177+ cases: Vec<(usize, char, usize, Option<(usize, usize)>)>,
178+ ) {
179+ let doc = Rope::from(text);
184180 let slice = doc.slice(..);
185181
186− // cursor on [t]ext
187− assert_eq!(find_nth_pairs_pos(slice, '(', 6, 1), Some((5, 10)));
188− assert_eq!(find_nth_pairs_pos(slice, ')', 6, 1), Some((5, 10)));
189− // cursor on so[m]e
190− assert_eq!(find_nth_pairs_pos(slice, '(', 2, 1), None);
191− // cursor on bracket itself
192− assert_eq!(find_nth_pairs_pos(slice, '(', 5, 1), Some((5, 10)));
193− assert_eq!(find_nth_pairs_pos(slice, '(', 10, 1), Some((5, 10)));
182+ for (cursor_pos, ch, n, expected_range) in cases {
183+ let range = find_nth_pairs_pos(slice, ch, (cursor_pos, cursor_pos + 1).into(), n);
184+ assert_eq!(
185+ range, expected_range,
186+ "Expected {:?}, got {:?}",
187+ expected_range, range
188+ );
189+ }
194190 }
195191
196192 #[test]
197− fn test_find_nth_pairs_pos_skip() {
198− let doc = Rope::from("(so (many (good) text) here)");
199− let slice = doc.slice(..);
193+ fn test_find_nth_pairs_pos() {
194+ check_find_nth_pair_pos(
195+ "some (text) here",
196+ vec![
197+ // cursor on [t]ext
198+ (6, '(', 1, Some((5, 10))),
199+ (6, ')', 1, Some((5, 10))),
200+ // cursor on so[m]e
201+ (2, '(', 1, None),
202+ // cursor on bracket itself
203+ (5, '(', 1, Some((5, 10))),
204+ (10, '(', 1, Some((5, 10))),
205+ ],
206+ );
207+ }
200208
201− // cursor on go[o]d
202− assert_eq!(find_nth_pairs_pos(slice, '(', 13, 1), Some((10, 15)));
203− assert_eq!(find_nth_pairs_pos(slice, '(', 13, 2), Some((4, 21)));
204− assert_eq!(find_nth_pairs_pos(slice, '(', 13, 3), Some((0, 27)));
209+ #[test]
210+ fn test_find_nth_pairs_pos_skip() {
211+ check_find_nth_pair_pos(
212+ "(so (many (good) text) here)",
213+ vec![
214+ // cursor on go[o]d
215+ (13, '(', 1, Some((10, 15))),
216+ (13, '(', 2, Some((4, 21))),
217+ (13, '(', 3, Some((0, 27))),
218+ ],
219+ );
205220 }
206221
207222 #[test]
208223 fn test_find_nth_pairs_pos_same() {
209− let doc = Rope::from("'so 'many 'good' text' here'");
210− let slice = doc.slice(..);
211−
212− // cursor on go[o]d
213− assert_eq!(find_nth_pairs_pos(slice, '\'', 13, 1), Some((10, 15)));
214− assert_eq!(find_nth_pairs_pos(slice, '\'', 13, 2), Some((4, 21)));
215− assert_eq!(find_nth_pairs_pos(slice, '\'', 13, 3), Some((0, 27)));
216− // cursor on the quotes
217− assert_eq!(find_nth_pairs_pos(slice, '\'', 10, 1), None);
218− // this is the best we can do since opening and closing pairs are same
219− assert_eq!(find_nth_pairs_pos(slice, '\'', 0, 1), Some((0, 4)));
220− assert_eq!(find_nth_pairs_pos(slice, '\'', 27, 1), Some((21, 27)));
224+ check_find_nth_pair_pos(
225+ "'so 'many 'good' text' here'",
226+ vec![
227+ // cursor on go[o]d
228+ (13, '\'', 1, Some((10, 15))),
229+ (13, '\'', 2, Some((4, 21))),
230+ (13, '\'', 3, Some((0, 27))),
231+ // cursor on the quotes
232+ (10, '\'', 1, None),
233+ ],
234+ )
221235 }
222236
223237 #[test]
224238 fn test_find_nth_pairs_pos_step() {
225− let doc = Rope::from("((so)((many) good (text))(here))");
226− let slice = doc.slice(..);
227−
228− // cursor on go[o]d
229− assert_eq!(find_nth_pairs_pos(slice, '(', 15, 1), Some((5, 24)));
230− assert_eq!(find_nth_pairs_pos(slice, '(', 15, 2), Some((0, 31)));
239+ check_find_nth_pair_pos(
240+ "((so)((many) good (text))(here))",
241+ vec![
242+ // cursor on go[o]d
243+ (15, '(', 1, Some((5, 24))),
244+ (15, '(', 2, Some((0, 31))),
245+ ],
246+ )
231247 }
232248
233249 #[test]
234250 fn test_find_nth_pairs_pos_mixed() {
235− let doc = Rope::from("(so [many {good} text] here)");
236− let slice = doc.slice(..);
237−
238− // cursor on go[o]d
239− assert_eq!(find_nth_pairs_pos(slice, '{', 13, 1), Some((10, 15)));
240− assert_eq!(find_nth_pairs_pos(slice, '[', 13, 1), Some((4, 21)));
241− assert_eq!(find_nth_pairs_pos(slice, '(', 13, 1), Some((0, 27)));
251+ check_find_nth_pair_pos(
252+ "(so [many {good} text] here)",
253+ vec![
254+ // cursor on go[o]d
255+ (13, '{', 1, Some((10, 15))),
256+ (13, '[', 1, Some((4, 21))),
257+ (13, '(', 1, Some((0, 27))),
258+ ],
259+ )
242260 }
243261
244262 #[test]
helix-core/src/textobject.rs+6−4
@@ -114,7 +114,7 @@ pub fn textobject_surround(
114114 ch: char,
115115 count: usize,
116116) -> Range {
117− surround::find_nth_pairs_pos(slice, ch, range.head, count)
117+ surround::find_nth_pairs_pos(slice, ch, range, count)
118118 .map(|(anchor, head)| match textobject {
119119 TextObject::Inside => Range::new(next_grapheme_boundary(slice, anchor), head),
120120 TextObject::Around => Range::new(anchor, next_grapheme_boundary(slice, head)),
@@ -170,7 +170,7 @@ mod test {
170170
171171 #[test]
172172 fn test_textobject_word() {
173− // (text, [(cursor position, textobject, final range), ...])
173+ // (text, [(char position, textobject, final range), ...])
174174 let tests = &[
175175 (
176176 "cursor at beginning of doc",
@@ -269,7 +269,9 @@ mod test {
269269 let slice = doc.slice(..);
270270 for &case in scenario {
271271 let (pos, objtype, expected_range) = case;
272− let result = textobject_word(slice, Range::point(pos), objtype, 1, false);
272+ // cursor is a single width selection
273+ let range = Range::new(pos, pos + 1);
274+ let result = textobject_word(slice, range, objtype, 1, false);
273275 assert_eq!(
274276 result,
275277 expected_range.into(),
@@ -283,7 +285,7 @@ mod test {
283285
284286 #[test]
285287 fn test_textobject_surround() {
286− // (text, [(cursor position, textobject, final range, count), ...])
288+ // (text, [(cursor position, textobject, final range, surround char, count), ...])
287289 let tests = &[
288290 (
289291 "simple (single) surround pairs",
helix-lsp/Cargo.toml+1−1
@@ -23,5 +23,5 @@ lsp-types = { version = "0.91", features = ["proposed"] }
2323serde = { version = "1.0", features = ["derive"] }
2424serde_json = "1.0"
2525thiserror = "1.0"
26−tokio = { version = "1.13", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] }
26+tokio = { version = "1.14", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] }
2727tokio-stream = "0.1.8"
helix-syntax/languages/tree-sitter-wgslnew file+1

Submodule changed.

helix-term/src/application.rs+2−2
@@ -122,7 +122,7 @@ impl Application {
122122 if first.is_dir() {
123123 std::env::set_current_dir(&first)?;
124124 editor.new_file(Action::VerticalSplit);
125− compositor.push(Box::new(ui::file_picker(".".into())));
125+ compositor.push(Box::new(ui::file_picker(".".into(), &config.editor)));
126126 } else {
127127 let nr_of_files = args.files.len();
128128 editor.open(first.to_path_buf(), Action::VerticalSplit)?;
@@ -270,7 +270,7 @@ impl Application {
270270 use crate::commands::{insert::idle_completion, Context};
271271 use helix_view::document::Mode;
272272
273− if doc_mut!(self.editor).mode != Mode::Insert || !self.config.editor.auto_completion {
273+ if doc!(self.editor).mode != Mode::Insert || !self.config.editor.auto_completion {
274274 return;
275275 }
276276 let editor_view = self
helix-term/src/commands.rs+265−63
@@ -13,7 +13,6 @@ use helix_core::{
1313 numbers::NumberIncrementor,
1414 object, pos_at_coords,
1515 regex::{self, Regex, RegexBuilder},
16− register::Register,
1716 search, selection, surround, textobject,
1817 unicode::width::UnicodeWidthChar,
1918 LineEnding, Position, Range, Rope, RopeGraphemes, RopeSlice, Selection, SmallVec, Tendril,
@@ -236,7 +235,9 @@ impl Command {
236235 extend_line, "Select current line, if already selected, extend to next line",
237236 extend_to_line_bounds, "Extend selection to line bounds (line-wise selection)",
238237 delete_selection, "Delete selection",
238+ delete_selection_noyank, "Delete selection, without yanking",
239239 change_selection, "Change selection (delete and enter insert mode)",
240+ change_selection_noyank, "Change selection (delete and enter insert mode, without yanking)",
240241 collapse_selection, "Collapse selection onto a single cursor",
241242 flip_selections, "Flip selection cursor and anchor",
242243 insert_mode, "Insert before selection",
@@ -262,6 +263,9 @@ impl Command {
262263 goto_implementation, "Goto implementation",
263264 goto_file_start, "Goto file start/line",
264265 goto_file_end, "Goto file end",
266+ goto_file, "Goto files in the selection",
267+ goto_file_hsplit, "Goto files in the selection in horizontal splits",
268+ goto_file_vsplit, "Goto files in the selection in vertical splits",
265269 goto_reference, "Goto references",
266270 goto_window_top, "Goto window top",
267271 goto_window_middle, "Goto window middle",
@@ -318,6 +322,7 @@ impl Command {
318322 join_selections, "Join lines inside selection",
319323 keep_selections, "Keep selections matching regex",
320324 remove_selections, "Remove selections matching regex",
325+ align_selections, "Align selections in column",
321326 keep_primary_selection, "Keep primary selection",
322327 remove_primary_selection, "Remove primary selection",
323328 completion, "Invoke completion popup",
@@ -676,11 +681,83 @@ fn trim_selections(cx: &mut Context) {
676681 };
677682}
678683
684+// align text in selection
685+fn align_selections(cx: &mut Context) {
686+ let align_style = cx.count();
687+ if align_style > 3 {
688+ cx.editor.set_error(
689+ "align only accept 1,2,3 as count to set left/center/right align".to_string(),
690+ );
691+ return;
692+ }
693+
694+ let (view, doc) = current!(cx.editor);
695+ let text = doc.text().slice(..);
696+ let selection = doc.selection(view.id);
697+ let mut column_widths = vec![];
698+ let mut last_line = text.len_lines();
699+ let mut column = 0;
700+ // first of all, we need compute all column's width, let use max width of the selections in a column
701+ for sel in selection {
702+ let (l1, l2) = sel.line_range(text);
703+ if l1 != l2 {
704+ cx.editor
705+ .set_error("align cannot work with multi line selections".to_string());
706+ return;
707+ }
708+ // if the selection is not in the same line with last selection, we set the column to 0
709+ column = if l1 != last_line { 0 } else { column + 1 };
710+ last_line = l1;
711+
712+ if column < column_widths.len() {
713+ if sel.to() - sel.from() > column_widths[column] {
714+ column_widths[column] = sel.to() - sel.from();
715+ }
716+ } else {
717+ // a new column, current selection width is the temp width of the column
718+ column_widths.push(sel.to() - sel.from());
719+ }
720+ }
721+ last_line = text.len_lines();
722+ // once we get the with of each column, we transform each selection with to it's column width based on the align style
723+ let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
724+ let l = range.cursor_line(text);
725+ column = if l != last_line { 0 } else { column + 1 };
726+ last_line = l;
727+
728+ (
729+ range.from(),
730+ range.to(),
731+ Some(
732+ align_fragment_to_width(&range.fragment(text), column_widths[column], align_style)
733+ .into(),
734+ ),
735+ )
736+ });
737+
738+ doc.apply(&transaction, view.id);
739+ doc.append_changes_to_history(view.id);
740+}
741+
742+fn align_fragment_to_width(fragment: &str, width: usize, align_style: usize) -> String {
743+ let trimed = fragment.trim_matches(|c| c == ' ');
744+ let mut s = " ".repeat(width - trimed.chars().count());
745+ match align_style {
746+ 1 => s.insert_str(0, trimed), // left align
747+ 2 => s.insert_str(s.len() / 2, trimed), // center align
748+ 3 => s.push_str(trimed), // right align
749+ n => unimplemented!("{}", n),
750+ }
751+ s
752+}
753+
679754fn goto_window(cx: &mut Context, align: Align) {
755+ let count = cx.count() - 1;
680756 let (view, doc) = current!(cx.editor);
681757
682758 let height = view.inner_area().height as usize;
683759
760+ // respect user given count if any
684761 // - 1 so we have at least one gap in the middle.
685762 // a height of 6 with padding of 3 on each side will keep shifting the view back and forth
686763 // as we type
@@ -689,11 +766,12 @@ fn goto_window(cx: &mut Context, align: Align) {
689766 let last_line = view.last_line(doc);
690767
691768 let line = match align {
692− Align::Top => (view.offset.row + scrolloff),
693− Align::Center => (view.offset.row + (height / 2)),
694− Align::Bottom => last_line.saturating_sub(scrolloff),
769+ Align::Top => (view.offset.row + scrolloff + count),
770+ Align::Center => (view.offset.row + ((last_line - view.offset.row) / 2)),
771+ Align::Bottom => last_line.saturating_sub(scrolloff + count),
695772 }
696− .min(last_line.saturating_sub(scrolloff));
773+ .min(last_line.saturating_sub(scrolloff))
774+ .max(view.offset.row + scrolloff);
697775
698776 let pos = doc.text().line_to_char(line);
699777
@@ -782,6 +860,49 @@ fn goto_file_end(cx: &mut Context) {
782860 doc.set_selection(view.id, selection);
783861}
784862
863+fn goto_file(cx: &mut Context) {
864+ goto_file_impl(cx, Action::Replace);
865+}
866+
867+fn goto_file_hsplit(cx: &mut Context) {
868+ goto_file_impl(cx, Action::HorizontalSplit);
869+}
870+
871+fn goto_file_vsplit(cx: &mut Context) {
872+ goto_file_impl(cx, Action::VerticalSplit);
873+}
874+
875+fn goto_file_impl(cx: &mut Context, action: Action) {
876+ let (view, doc) = current_ref!(cx.editor);
877+ let text = doc.text();
878+ let selections = doc.selection(view.id);
879+ let mut paths: Vec<_> = selections
880+ .iter()
881+ .map(|r| text.slice(r.from()..r.to()).to_string())
882+ .collect();
883+ let primary = selections.primary();
884+ if selections.len() == 1 && primary.to() - primary.from() == 1 {
885+ let current_word = movement::move_next_long_word_start(
886+ text.slice(..),
887+ movement::move_prev_long_word_start(text.slice(..), primary, 1),
888+ 1,
889+ );
890+ paths.clear();
891+ paths.push(
892+ text.slice(current_word.from()..current_word.to())
893+ .to_string(),
894+ );
895+ }
896+ for sel in paths {
897+ let p = sel.trim();
898+ if !p.is_empty() {
899+ if let Err(e) = cx.editor.open(PathBuf::from(p), action) {
900+ cx.editor.set_error(format!("Open file failed: {:?}", e));
901+ }
902+ }
903+ }
904+}
905+
785906fn extend_word_impl<F>(cx: &mut Context, extend_fn: F)
786907where
787908 F: Fn(RopeSlice, Range, usize) -> Range,
@@ -1459,6 +1580,7 @@ fn global_search(cx: &mut Context) {
14591580 let (all_matches_sx, all_matches_rx) =
14601581 tokio::sync::mpsc::unbounded_channel::<(usize, PathBuf)>();
14611582 let smart_case = cx.editor.config.smart_case;
1583+ let file_picker_config = cx.editor.config.file_picker.clone();
14621584
14631585 let completions = search_completions(cx, None);
14641586 let prompt = ui::regex_prompt(
@@ -1487,41 +1609,55 @@ fn global_search(cx: &mut Context) {
14871609
14881610 let search_root = std::env::current_dir()
14891611 .expect("Global search error: Failed to get current dir");
1490− WalkBuilder::new(search_root).build_parallel().run(|| {
1491− let mut searcher_cl = searcher.clone();
1492− let matcher_cl = matcher.clone();
1493− let all_matches_sx_cl = all_matches_sx.clone();
1494− Box::new(move |dent: Result<DirEntry, ignore::Error>| -> WalkState {
1495− let dent = match dent {
1496− Ok(dent) => dent,
1497− Err(_) => return WalkState::Continue,
1498− };
1499−
1500− match dent.file_type() {
1501− Some(fi) => {
1502− if !fi.is_file() {
1503− return WalkState::Continue;
1612+ WalkBuilder::new(search_root)
1613+ .hidden(file_picker_config.hidden)
1614+ .parents(file_picker_config.parents)
1615+ .ignore(file_picker_config.ignore)
1616+ .git_ignore(file_picker_config.git_ignore)
1617+ .git_global(file_picker_config.git_global)
1618+ .git_exclude(file_picker_config.git_exclude)
1619+ .max_depth(file_picker_config.max_depth)
1620+ .build_parallel()
1621+ .run(|| {
1622+ let mut searcher_cl = searcher.clone();
1623+ let matcher_cl = matcher.clone();
1624+ let all_matches_sx_cl = all_matches_sx.clone();
1625+ Box::new(move |dent: Result<DirEntry, ignore::Error>| -> WalkState {
1626+ let dent = match dent {
1627+ Ok(dent) => dent,
1628+ Err(_) => return WalkState::Continue,
1629+ };
1630+
1631+ match dent.file_type() {
1632+ Some(fi) => {
1633+ if !fi.is_file() {
1634+ return WalkState::Continue;
1635+ }
15041636 }
1637+ None => return WalkState::Continue,
15051638 }
1506− None => return WalkState::Continue,
1507− }
15081639
1509− let result_sink = sinks::UTF8(|line_num, _| {
1510− match all_matches_sx_cl
1511− .send((line_num as usize - 1, dent.path().to_path_buf()))
1512− {
1513− Ok(_) => Ok(true),
1514− Err(_) => Ok(false),
1640+ let result_sink = sinks::UTF8(|line_num, _| {
1641+ match all_matches_sx_cl
1642+ .send((line_num as usize - 1, dent.path().to_path_buf()))
1643+ {
1644+ Ok(_) => Ok(true),
1645+ Err(_) => Ok(false),
1646+ }
1647+ });
1648+ let result =
1649+ searcher_cl.search_path(&matcher_cl, dent.path(), result_sink);
1650+
1651+ if let Err(err) = result {
1652+ log::error!(
1653+ "Global search error: {}, {}",
1654+ dent.path().display(),
1655+ err
1656+ );
15151657 }
1516− });
1517− let result = searcher_cl.search_path(&matcher_cl, dent.path(), result_sink);
1518−
1519− if let Err(err) = result {
1520− log::error!("Global search error: {}, {}", dent.path().display(), err);
1521− }
1522− WalkState::Continue
1523− })
1524− });
1658+ WalkState::Continue
1659+ })
1660+ });
15251661 } else {
15261662 // Otherwise do nothing
15271663 // log::warn!("Global Search Invalid Pattern")
@@ -1626,19 +1762,42 @@ fn extend_to_line_bounds(cx: &mut Context) {
16261762 );
16271763}
16281764
1629−fn delete_selection_impl(reg: &mut Register, doc: &mut Document, view_id: ViewId) {
1765+enum Operation {
1766+ Delete,
1767+ Change,
1768+}
1769+
1770+fn delete_selection_impl(cx: &mut Context, op: Operation) {
1771+ let (view, doc) = current!(cx.editor);
1772+
16301773 let text = doc.text().slice(..);
1631− let selection = doc.selection(view_id);
1774+ let selection = doc.selection(view.id);
16321775
1633− // first yank the selection
1634− let values: Vec<String> = selection.fragments(text).map(Cow::into_owned).collect();
1635− reg.write(values);
1776+ if cx.register != Some('_') {
1777+ // first yank the selection
1778+ let values: Vec<String> = selection.fragments(text).map(Cow::into_owned).collect();
1779+ let reg_name = cx.register.unwrap_or('"');
1780+ let registers = &mut cx.editor.registers;
1781+ let reg = registers.get_mut(reg_name);
1782+ reg.write(values);
1783+ };
16361784
16371785 // then delete
16381786 let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
16391787 (range.from(), range.to(), None)
16401788 });
1641− doc.apply(&transaction, view_id);
1789+ doc.apply(&transaction, view.id);
1790+
1791+ match op {
1792+ Operation::Delete => {
1793+ doc.append_changes_to_history(view.id);
1794+ // exit select mode, if currently in select mode
1795+ exit_select_mode(cx);
1796+ }
1797+ Operation::Change => {
1798+ enter_insert_mode(doc);
1799+ }
1800+ }
16421801}
16431802
16441803#[inline]
@@ -1653,25 +1812,21 @@ fn delete_selection_insert_mode(doc: &mut Document, view: &View, selection: &Sel
16531812}
16541813
16551814fn delete_selection(cx: &mut Context) {
1656− let reg_name = cx.register.unwrap_or('"');
1657− let (view, doc) = current!(cx.editor);
1658− let registers = &mut cx.editor.registers;
1659− let reg = registers.get_mut(reg_name);
1660− delete_selection_impl(reg, doc, view.id);
1661−
1662− doc.append_changes_to_history(view.id);
1815+ delete_selection_impl(cx, Operation::Delete);
1816+}
16631817
1664− // exit select mode, if currently in select mode
1665− exit_select_mode(cx);
1818+fn delete_selection_noyank(cx: &mut Context) {
1819+ cx.register = Some('_');
1820+ delete_selection_impl(cx, Operation::Delete);
16661821}
16671822
16681823fn change_selection(cx: &mut Context) {
1669− let reg_name = cx.register.unwrap_or('"');
1670− let (view, doc) = current!(cx.editor);
1671− let registers = &mut cx.editor.registers;
1672− let reg = registers.get_mut(reg_name);
1673− delete_selection_impl(reg, doc, view.id);
1674− enter_insert_mode(doc);
1824+ delete_selection_impl(cx, Operation::Change);
1825+}
1826+
1827+fn change_selection_noyank(cx: &mut Context) {
1828+ cx.register = Some('_');
1829+ delete_selection_impl(cx, Operation::Change);
16751830}
16761831
16771832fn collapse_selection(cx: &mut Context) {
@@ -1820,7 +1975,7 @@ mod cmd {
18201975 let jobs = &mut cx.jobs;
18211976 let (_, doc) = current!(cx.editor);
18221977
1823− if let Some(path) = path {
1978+ if let Some(ref path) = path {
18241979 doc.set_path(Some(path.as_ref()))
18251980 .context("invalid filepath")?;
18261981 }
@@ -1840,6 +1995,11 @@ mod cmd {
18401995 });
18411996 let future = doc.format_and_save(fmt);
18421997 cx.jobs.add(Job::new(future).wait_before_exiting());
1998+
1999+ if path.is_some() {
2000+ let id = doc.id();
2001+ let _ = cx.editor.refresh_language_server(id);
2002+ }
18432003 Ok(())
18442004 }
18452005
@@ -2466,6 +2626,26 @@ mod cmd {
24662626 Ok(())
24672627 }
24682628
2629+ pub(super) fn goto_line_number(
2630+ cx: &mut compositor::Context,
2631+ args: &[&str],
2632+ _event: PromptEvent,
2633+ ) -> anyhow::Result<()> {
2634+ if args.is_empty() {
2635+ bail!("Line number required");
2636+ }
2637+
2638+ let line = args[0].parse::<usize>()?;
2639+
2640+ goto_line_impl(&mut cx.editor, NonZeroUsize::new(line));
2641+
2642+ let (view, doc) = current!(cx.editor);
2643+
2644+ view.ensure_cursor_in_view(doc, line);
2645+
2646+ Ok(())
2647+ }
2648+
24692649 pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
24702650 TypableCommand {
24712651 name: "quit",
@@ -2768,6 +2948,13 @@ mod cmd {
27682948 fun: tutor,
27692949 completer: None,
27702950 },
2951+ TypableCommand {
2952+ name: "goto",
2953+ aliases: &["g"],
2954+ doc: "Go to line number.",
2955+ fun: goto_line_number,
2956+ completer: None,
2957+ }
27712958 ];
27722959
27732960 pub static COMMANDS: Lazy<HashMap<&'static str, &'static TypableCommand>> = Lazy::new(|| {
@@ -2830,6 +3017,15 @@ fn command_mode(cx: &mut Context) {
28303017 return;
28313018 }
28323019
3020+ // If command is numeric, interpret as line number and go there.
3021+ if parts.len() == 1 && parts[0].parse::<usize>().ok().is_some() {
3022+ if let Err(e) = cmd::goto_line_number(cx, &parts[0..], event) {
3023+ cx.editor.set_error(format!("{}", e));
3024+ }
3025+ return;
3026+ }
3027+
3028+ // Handle typable commands
28333029 if let Some(cmd) = cmd::COMMANDS.get(parts[0]) {
28343030 if let Err(e) = (cmd.fun)(cx, &parts[1..], event) {
28353031 cx.editor.set_error(format!("{}", e));
@@ -2855,7 +3051,7 @@ fn command_mode(cx: &mut Context) {
28553051
28563052fn file_picker(cx: &mut Context) {
28573053 let root = find_root(None).unwrap_or_else(|| PathBuf::from("./"));
2858− let picker = ui::file_picker(root);
3054+ let picker = ui::file_picker(root, &cx.editor.config);
28593055 cx.push_layer(Box::new(picker));
28603056}
28613057
@@ -3463,10 +3659,14 @@ fn push_jump(editor: &mut Editor) {
34633659}
34643660
34653661fn goto_line(cx: &mut Context) {
3466− if let Some(count) = cx.count {
3467− push_jump(cx.editor);
3662+ goto_line_impl(&mut cx.editor, cx.count)
3663+}
34683664
3469− let (view, doc) = current!(cx.editor);
3665+fn goto_line_impl(editor: &mut Editor, count: Option<NonZeroUsize>) {
3666+ if let Some(count) = count {
3667+ push_jump(editor);
3668+
3669+ let (view, doc) = current!(editor);
34703670 let max_line = if doc.text().line(doc.text().len_lines() - 1).len_chars() == 0 {
34713671 // If the last line is blank, don't jump to it.
34723672 doc.text().len_lines().saturating_sub(2)
@@ -5065,7 +5265,9 @@ fn match_brackets(cx: &mut Context) {
50655265 if let Some(syntax) = doc.syntax() {
50665266 let text = doc.text().slice(..);
50675267 let selection = doc.selection(view.id).clone().transform(|range| {
5068− if let Some(pos) = match_brackets::find(syntax, doc.text(), range.anchor) {
5268+ if let Some(pos) =
5269+ match_brackets::find_matching_bracket_fuzzy(syntax, doc.text(), range.anchor)
5270+ {
50695271 range.put_cursor(text, pos, doc.mode == Mode::Select)
50705272 } else {
50715273 range
helix-term/src/keymap.rs+8−3
@@ -512,6 +512,7 @@ impl Default for Keymaps {
512512 "g" => { "Goto"
513513 "g" => goto_file_start,
514514 "e" => goto_last_line,
515+ "f" => goto_file,
515516 "h" => goto_line_start,
516517 "l" => goto_line_end,
517518 "s" => goto_first_nonwhitespace,
@@ -537,9 +538,9 @@ impl Default for Keymaps {
537538 "O" => open_above,
538539
539540 "d" => delete_selection,
540− // TODO: also delete without yanking
541+ "A-d" => delete_selection_noyank,
541542 "c" => change_selection,
542− // TODO: also change delete without yanking
543+ "A-c" => change_selection_noyank,
543544
544545 "C" => copy_selection_on_next_line,
545546 "A-C" => copy_selection_on_prev_line,
@@ -604,7 +605,7 @@ impl Default for Keymaps {
604605 // "q" => record_macro,
605606 // "Q" => replay_macro,
606607
607− // & align selections
608+ "&" => align_selections,
608609 "_" => trim_selections,
609610
610611 "(" => rotate_selections_backward,
@@ -622,6 +623,8 @@ impl Default for Keymaps {
622623 "C-w" | "w" => rotate_view,
623624 "C-s" | "s" => hsplit,
624625 "C-v" | "v" => vsplit,
626+ "f" => goto_file_hsplit,
627+ "F" => goto_file_vsplit,
625628 "C-q" | "q" => wclose,
626629 "C-o" | "o" => wonly,
627630 "C-h" | "h" | "left" => jump_view_left,
@@ -670,6 +673,8 @@ impl Default for Keymaps {
670673 "C-w" | "w" => rotate_view,
671674 "C-s" | "s" => hsplit,
672675 "C-v" | "v" => vsplit,
676+ "f" => goto_file_hsplit,
677+ "F" => goto_file_vsplit,
673678 "C-q" | "q" => wclose,
674679 "C-o" | "o" => wonly,
675680 "C-h" | "h" | "left" => jump_view_left,
helix-term/src/ui/editor.rs+127−162
@@ -18,7 +18,6 @@ use helix_core::{
1818use helix_dap::{Breakpoint, SourceBreakpoint, StackFrame};
1919use helix_view::{
2020 document::{Mode, SCRATCH_BUFFER_NAME},
21− editor::LineNumber,
2221 graphics::{Color, CursorKind, Modifier, Rect, Style},
2322 info::Info,
2423 input::KeyEvent,
@@ -392,7 +391,7 @@ impl EditorView {
392391 use helix_core::match_brackets;
393392 let pos = doc.selection(view.id).primary().cursor(text);
394393
395− let pos = match_brackets::find(syntax, doc.text(), pos)
394+ let pos = match_brackets::find_matching_bracket(syntax, doc.text(), pos)
396395 .and_then(|pos| view.screen_coords_at_pos(doc, text, pos));
397396
398397 if let Some(pos) = pos {
@@ -430,22 +429,6 @@ impl EditorView {
430429 let text = doc.text().slice(..);
431430 let last_line = view.last_line(doc);
432431
433− let linenr = theme.get("ui.linenr");
434− let linenr_select: Style = theme.try_get("ui.linenr.selected").unwrap_or(linenr);
435−
436− let warning = theme.get("warning");
437− let error = theme.get("error");
438− let info = theme.get("info");
439− let hint = theme.get("hint");
440−
441− // Whether to draw the line number for the last line of the
442− // document or not. We only draw it if it's not an empty line.
443− let draw_last = text.line_to_byte(last_line) < text.len_bytes();
444−
445− let current_line = doc
446− .text()
447− .char_to_line(doc.selection(view.id).primary().cursor(text));
448−
449432 // it's used inside an iterator so the collect isn't needless:
450433 // https://github.com/rust-lang/rust-clippy/issues/6164
451434 #[allow(clippy::needless_collect)]
@@ -455,146 +438,137 @@ impl EditorView {
455438 .map(|range| range.cursor_line(text))
456439 .collect();
457440
458− let mut breakpoints: Option<&Vec<SourceBreakpoint>> = None;
459− let mut stack_frame: Option<&StackFrame> = None;
460− if let Some(path) = doc.path() {
461− breakpoints = all_breakpoints.get(path);
462− if let Some(debugger) = debugger {
463− // if we have a frame, and the frame path matches document
464− if let (Some(frame), Some(thread_id)) = (debugger.active_frame, debugger.thread_id)
465− {
466− let frame = debugger
467− .stack_frames
468− .get(&thread_id)
469− .and_then(|bt| bt.get(frame)); // TODO: drop the clone..
470− if let Some(StackFrame {
471− source: Some(source),
472− ..
473− }) = &frame
474− {
475− if source.path.as_ref() == Some(path) {
476− stack_frame = frame;
477− }
478− };
479− };
480− }
441+ use helix_view::gutter::GutterFn;
442+ fn breakpoints<'doc>(
443+ doc: &'doc Document,
444+ _view: &View,
445+ theme: &Theme,
446+ _config: &Config,
447+ _is_focused: bool,
448+ _width: usize,
449+ ) -> GutterFn<'doc> {
450+ Box::new(move |line: usize, _selected: bool, out: &mut String| {
451+ //
452+ })
481453 }
482−
483− for (i, line) in (view.offset.row..(last_line + 1)).enumerate() {
484− use helix_core::diagnostic::Severity;
485− if let Ok(diagnostic) = doc.diagnostics().binary_search_by_key(&line, |d| d.line) {
486− let diagnostic = &doc.diagnostics()[diagnostic];
487− surface.set_stringn(
488− viewport.x,
489− viewport.y + i as u16,
490− "●",
491− 1,
492− match diagnostic.severity {
493− Some(Severity::Error) => error,
494− Some(Severity::Warning) | None => warning,
495− Some(Severity::Info) => info,
496− Some(Severity::Hint) => hint,
497− },
498− );
499− }
500−
501− let selected = cursors.contains(&line);
502−
503− // TODO: debugger should translate received breakpoints to 0-indexing
504−
505− if let Some(user) = breakpoints.as_ref() {
506− let debugger_breakpoint = if let Some(debugger) = dbg_breakpoints.as_ref() {
507− debugger.iter().find(|breakpoint| {
508− if breakpoint.source.is_some()
509− && doc.path().is_some()
510− && breakpoint.source.as_ref().unwrap().path == doc.path().cloned()
511− {
512− match (breakpoint.line, breakpoint.end_line) {
513− #[allow(clippy::int_plus_one)]
514− (Some(l), Some(el)) => l - 1 <= line && line <= el - 1,
515− (Some(l), None) => l - 1 == line,
516− _ => false,
517− }
518− } else {
519− false
520− }
521− })
522− } else {
523− None
524− };
525−
526− if let Some(breakpoint) = user.iter().find(|breakpoint| breakpoint.line - 1 == line)
527− {
528− let verified = debugger_breakpoint.map(|b| b.verified).unwrap_or(false);
529− let mut style =
530− if breakpoint.condition.is_some() && breakpoint.log_message.is_some() {
531− error.add_modifier(Modifier::UNDERLINED)
532− } else if breakpoint.condition.is_some() {
533− error
534− } else if breakpoint.log_message.is_some() {
535− info
536− } else {
537− warning
538− };
539− if !verified {
540− // Faded colors
541− style = if let Some(Color::Rgb(r, g, b)) = style.fg {
542− style.fg(Color::Rgb(
543− ((r as f32) * 0.4).floor() as u8,
544− ((g as f32) * 0.4).floor() as u8,
545− ((b as f32) * 0.4).floor() as u8,
546− ))
547− } else {
548− style.fg(Color::Gray)
549− }
550− };
551− surface.set_stringn(viewport.x, viewport.y + i as u16, "▲", 1, style);
552− } else if let Some(breakpoint) = debugger_breakpoint {
553− let style = if breakpoint.verified {
554− info
555− } else {
556− info.fg(Color::Gray)
557− };
558− surface.set_stringn(viewport.x, viewport.y + i as u16, "⊚", 1, style);
559− }
560− }
561−
562− if let Some(frame) = stack_frame {
563− if frame.line - 1 == line {
564− surface.set_style(
565− Rect::new(viewport.x, viewport.y + i as u16, 6, 1),
566− helix_view::graphics::Style::default()
567− .bg(helix_view::graphics::Color::LightYellow),
454+ // let mut breakpoints: Option<&Vec<SourceBreakpoint>> = None;
455+ // let mut stack_frame: Option<&StackFrame> = None;
456+ // if let Some(path) = doc.path() {
457+ // breakpoints = all_breakpoints.get(path);
458+ // if let Some(debugger) = debugger {
459+ // // if we have a frame, and the frame path matches document
460+ // if let (Some(frame), Some(thread_id)) = (debugger.active_frame, debugger.thread_id)
461+ // {
462+ // let frame = debugger
463+ // .stack_frames
464+ // .get(&thread_id)
465+ // .and_then(|bt| bt.get(frame)); // TODO: drop the clone..
466+ // if let Some(StackFrame {
467+ // source: Some(source),
468+ // ..
469+ // }) = &frame
470+ // {
471+ // if source.path.as_ref() == Some(path) {
472+ // stack_frame = frame;
473+ // }
474+ // };
475+ // };
476+ // }
477+ // }
478+
479+ // TODO: debugger should translate received breakpoints to 0-indexing
480+
481+ // if let Some(user) = breakpoints.as_ref() {
482+ // let debugger_breakpoint = if let Some(debugger) = dbg_breakpoints.as_ref() {
483+ // debugger.iter().find(|breakpoint| {
484+ // if breakpoint.source.is_some()
485+ // && doc.path().is_some()
486+ // && breakpoint.source.as_ref().unwrap().path == doc.path().cloned()
487+ // {
488+ // match (breakpoint.line, breakpoint.end_line) {
489+ // #[allow(clippy::int_plus_one)]
490+ // (Some(l), Some(el)) => l - 1 <= line && line <= el - 1,
491+ // (Some(l), None) => l - 1 == line,
492+ // _ => false,
493+ // }
494+ // } else {
495+ // false
496+ // }
497+ // })
498+ // } else {
499+ // None
500+ // };
501+
502+ // if let Some(breakpoint) = user.iter().find(|breakpoint| breakpoint.line - 1 == line)
503+ // {
504+ // let verified = debugger_breakpoint.map(|b| b.verified).unwrap_or(false);
505+ // let mut style =
506+ // if breakpoint.condition.is_some() && breakpoint.log_message.is_some() {
507+ // error.add_modifier(Modifier::UNDERLINED)
508+ // } else if breakpoint.condition.is_some() {
509+ // error
510+ // } else if breakpoint.log_message.is_some() {
511+ // info
512+ // } else {
513+ // warning
514+ // };
515+ // if !verified {
516+ // // Faded colors
517+ // style = if let Some(Color::Rgb(r, g, b)) = style.fg {
518+ // style.fg(Color::Rgb(
519+ // ((r as f32) * 0.4).floor() as u8,
520+ // ((g as f32) * 0.4).floor() as u8,
521+ // ((b as f32) * 0.4).floor() as u8,
522+ // ))
523+ // } else {
524+ // style.fg(Color::Gray)
525+ // }
526+ // };
527+ // surface.set_stringn(viewport.x, viewport.y + i as u16, "▲", 1, style);
528+ // } else if let Some(breakpoint) = debugger_breakpoint {
529+ // let style = if breakpoint.verified {
530+ // info
531+ // } else {
532+ // info.fg(Color::Gray)
533+ // };
534+ // surface.set_stringn(viewport.x, viewport.y + i as u16, "⊚", 1, style);
535+ // }
536+ // }
537+
538+ // if let Some(frame) = stack_frame {
539+ // if frame.line - 1 == line {
540+ // surface.set_style(
541+ // Rect::new(viewport.x, viewport.y + i as u16, 6, 1),
542+ // helix_view::graphics::Style::default()
543+ // .bg(helix_view::graphics::Color::LightYellow),
544+ // );
545+ // }
546+ // }
547+
548+ let mut offset = 0;
549+
550+ // avoid lots of small allocations by reusing a text buffer for each line
551+ let mut text = String::with_capacity(8);
552+
553+ for (constructor, width) in view.gutters() {
554+ let gutter = constructor(doc, view, theme, config, is_focused, *width);
555+ text.reserve(*width); // ensure there's enough space for the gutter
556+ for (i, line) in (view.offset.row..(last_line + 1)).enumerate() {
557+ let selected = cursors.contains(&line);
558+
559+ if let Some(style) = gutter(line, selected, &mut text) {
560+ surface.set_stringn(
561+ viewport.x + offset,
562+ viewport.y + i as u16,
563+ &text,
564+ *width,
565+ style,
568566 );
569567 }
568+ text.clear();
570569 }
571570
572− let text = if line == last_line && !draw_last {
573− " ~".into()
574− } else {
575− let line = match config.line_number {
576− LineNumber::Absolute => line + 1,
577− LineNumber::Relative => {
578− if current_line == line {
579− line + 1
580− } else {
581− abs_diff(current_line, line)
582− }
583− }
584− };
585− format!("{:>5}", line)
586− };
587− surface.set_stringn(
588− viewport.x + 1,
589− viewport.y + i as u16,
590− text,
591− 5,
592− if selected && is_focused {
593− linenr_select
594− } else {
595− linenr
596− },
597− );
571+ offset += *width as u16;
598572 }
599573 }
600574
@@ -1364,12 +1338,3 @@ fn canonicalize_key(key: &mut KeyEvent) {
13641338 key.modifiers.remove(KeyModifiers::SHIFT)
13651339 }
13661340}
1367−
1368−#[inline]
1369−const fn abs_diff(a: usize, b: usize) -> usize {
1370− if a > b {
1371− a - b
1372− } else {
1373− b - a
1374− }
1375−}
helix-term/src/ui/markdown.rs+5−2
@@ -55,7 +55,7 @@ fn parse<'a>(
5555 fn to_span(text: pulldown_cmark::CowStr) -> Span {
5656 use std::ops::Deref;
5757 Span::raw::<std::borrow::Cow<_>>(match text {
58− CowStr::Borrowed(s) => s.to_string().into(), // could retain borrow
58+ CowStr::Borrowed(s) => s.into(),
5959 CowStr::Boxed(s) => s.to_string().into(),
6060 CowStr::Inlined(s) => s.deref().to_owned().into(),
6161 })
@@ -179,7 +179,9 @@ fn parse<'a>(
179179 spans.push(Span::raw(" "));
180180 }
181181 Event::Rule => {
182− lines.push(Spans::from("---"));
182+ let mut span = Span::raw("---");
183+ span.style = code_style;
184+ lines.push(Spans::from(span));
183185 lines.push(Spans::default());
184186 }
185187 // TaskListMarker(bool) true if checked
@@ -226,6 +228,7 @@ impl Component for Markdown {
226228 return None;
227229 }
228230 let contents = parse(&self.contents, None, &self.config_loader);
231+ // TODO: account for tab width
229232 let max_text_width = (viewport.0 - padding).min(120);
230233 let mut text_width = 0;
231234 let mut height = padding;
helix-term/src/ui/mod.rs+10−1
@@ -93,13 +93,22 @@ pub fn regex_prompt(
9393 )
9494}
9595
96−pub fn file_picker(root: PathBuf) -> FilePicker<PathBuf> {
96+pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePicker<PathBuf> {
9797 use ignore::{types::TypesBuilder, WalkBuilder};
9898 use std::time;
9999
100100 // We want to exclude files that the editor can't handle yet
101101 let mut type_builder = TypesBuilder::new();
102102 let mut walk_builder = WalkBuilder::new(&root);
103+ walk_builder
104+ .hidden(config.file_picker.hidden)
105+ .parents(config.file_picker.parents)
106+ .ignore(config.file_picker.ignore)
107+ .git_ignore(config.file_picker.git_ignore)
108+ .git_global(config.file_picker.git_global)
109+ .git_exclude(config.file_picker.git_exclude)
110+ .max_depth(config.file_picker.max_depth);
111+
103112 let walk_builder = match type_builder.add(
104113 "compressed",
105114 "*.{zip,gz,bz2,zst,lzo,sz,tgz,tbz2,lz,lz4,lzma,lzo,z,Z,xz,7z,rar,cab}",
helix-view/src/editor.rs+128−76
@@ -14,6 +14,7 @@ use tokio_stream::wrappers::UnboundedReceiverStream;
1414use std::{
1515 collections::{BTreeMap, HashMap},
1616 io::stdin,
17+ num::NonZeroUsize,
1718 path::{Path, PathBuf},
1819 pin::Pin,
1920 sync::Arc,
@@ -21,7 +22,7 @@ use std::{
2122
2223use tokio::time::{sleep, Duration, Instant, Sleep};
2324
24−use anyhow::Error;
25+use anyhow::{bail, Context, Error};
2526
2627pub use helix_core::diagnostic::Severity;
2728pub use helix_core::register::Registers;
@@ -39,6 +40,46 @@ where
3940 Ok(Duration::from_millis(millis))
4041}
4142
43+#[derive(Debug, Clone, PartialEq, Deserialize)]
44+#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
45+pub struct FilePickerConfig {
46+ /// IgnoreOptions
47+ /// Enables ignoring hidden files.
48+ /// Whether to hide hidden files in file picker and global search results. Defaults to true.
49+ pub hidden: bool,
50+ /// Enables reading ignore files from parent directories. Defaults to true.
51+ pub parents: bool,
52+ /// Enables reading `.ignore` files.
53+ /// Whether to hide files listed in .ignore in file picker and global search results. Defaults to true.
54+ pub ignore: bool,
55+ /// Enables reading `.gitignore` files.
56+ /// Whether to hide files listed in .gitignore in file picker and global search results. Defaults to true.
57+ pub git_ignore: bool,
58+ /// Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option.
59+ /// Whether to hide files listed in global .gitignore in file picker and global search results. Defaults to true.
60+ pub git_global: bool,
61+ /// Enables reading `.git/info/exclude` files.
62+ /// Whether to hide files listed in .git/info/exclude in file picker and global search results. Defaults to true.
63+ pub git_exclude: bool,
64+ /// WalkBuilder options
65+ /// Maximum Depth to recurse directories in file picker and global search. Defaults to `None`.
66+ pub max_depth: Option<usize>,
67+}
68+
69+impl Default for FilePickerConfig {
70+ fn default() -> Self {
71+ Self {
72+ hidden: true,
73+ parents: true,
74+ ignore: true,
75+ git_ignore: true,
76+ git_global: true,
77+ git_exclude: true,
78+ max_depth: None,
79+ }
80+ }
81+}
82+
4283#[derive(Debug, Clone, PartialEq, Deserialize)]
4384#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
4485pub struct Config {
@@ -66,9 +107,10 @@ pub struct Config {
66107 pub completion_trigger_len: u8,
67108 /// Whether to display infoboxes. Defaults to true.
68109 pub auto_info: bool,
110+ pub file_picker: FilePickerConfig,
69111}
70112
71−#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
113+#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize)]
72114#[serde(rename_all = "kebab-case")]
73115pub enum LineNumber {
74116 /// Show absolute line number
@@ -97,6 +139,7 @@ impl Default for Config {
97139 idle_timeout: Duration::from_millis(400),
98140 completion_trigger_len: 2,
99141 auto_info: true,
142+ file_picker: FilePickerConfig::default(),
100143 }
101144 }
102145}
@@ -116,7 +159,7 @@ impl std::fmt::Debug for Motion {
116159#[derive(Debug)]
117160pub struct Editor {
118161 pub tree: Tree,
119− pub next_document_id: usize,
162+ pub next_document_id: DocumentId,
120163 pub documents: BTreeMap<DocumentId, Document>,
121164 pub count: Option<std::num::NonZeroUsize>,
122165 pub selected_register: Option<char>,
@@ -154,8 +197,8 @@ pub enum Action {
154197impl Editor {
155198 pub fn new(
156199 mut area: Rect,
157− themes: Arc<theme::Loader>,
158− config_loader: Arc<syntax::Loader>,
200+ theme_loader: Arc<theme::Loader>,
201+ syn_loader: Arc<syntax::Loader>,
159202 config: Config,
160203 ) -> Self {
161204 let language_servers = helix_lsp::Registry::new();
@@ -165,17 +208,17 @@ impl Editor {
165208
166209 Self {
167210 tree: Tree::new(area),
168− next_document_id: 0,
211+ next_document_id: DocumentId::default(),
169212 documents: BTreeMap::new(),
170213 count: None,
171214 selected_register: None,
172− theme: themes.default(),
215+ theme: theme_loader.default(),
173216 language_servers,
174217 debugger: None,
175218 debugger_events: SelectAll::new(),
176219 breakpoints: HashMap::new(),
177− syn_loader: config_loader,
178− theme_loader: themes,
220+ syn_loader,
221+ theme_loader,
179222 registers: Registers::default(),
180223 clipboard_provider: get_clipboard_provider(),
181224 status_msg: None,
@@ -232,7 +275,6 @@ impl Editor {
232275 }
233276
234277 pub fn set_theme_from_name(&mut self, theme: &str) -> anyhow::Result<()> {
235− use anyhow::Context;
236278 let theme = self
237279 .theme_loader
238280 .load(theme.as_ref())
@@ -241,6 +283,53 @@ impl Editor {
241283 Ok(())
242284 }
243285
286+ /// Refreshes the language server for a given document
287+ pub fn refresh_language_server(&mut self, doc_id: DocumentId) -> Option<()> {
288+ let doc = self.documents.get_mut(&doc_id)?;
289+ doc.detect_language(Some(&self.theme), &self.syn_loader);
290+ Self::launch_language_server(&mut self.language_servers, doc)
291+ }
292+
293+ /// Launch a language server for a given document
294+ fn launch_language_server(ls: &mut helix_lsp::Registry, doc: &mut Document) -> Option<()> {
295+ // try to find a language server based on the language name
296+ let language_server = doc.language.as_ref().and_then(|language| {
297+ ls.get(language)
298+ .map_err(|e| {
299+ log::error!(
300+ "Failed to initialize the LSP for `{}` {{ {} }}",
301+ language.scope(),
302+ e
303+ )
304+ })
305+ .ok()
306+ });
307+ if let Some(language_server) = language_server {
308+ // only spawn a new lang server if the servers aren't the same
309+ if Some(language_server.id()) != doc.language_server().map(|server| server.id()) {
310+ if let Some(language_server) = doc.language_server() {
311+ tokio::spawn(language_server.text_document_did_close(doc.identifier()));
312+ }
313+ let language_id = doc
314+ .language()
315+ .and_then(|s| s.split('.').last()) // source.rust
316+ .map(ToOwned::to_owned)
317+ .unwrap_or_default();
318+
319+ // TODO: this now races with on_init code if the init happens too quickly
320+ tokio::spawn(language_server.text_document_did_open(
321+ doc.url().unwrap(),
322+ doc.version(),
323+ doc.text(),
324+ language_id,
325+ ));
326+
327+ doc.set_language_server(Some(language_server));
328+ }
329+ }
330+ Some(())
331+ }
332+
244333 fn _refresh(&mut self) {
245334 for (view, _) in self.tree.views_mut() {
246335 let doc = &self.documents[&view.doc];
@@ -311,23 +400,22 @@ impl Editor {
311400 }
312401 Action::Load => {
313402 let view_id = view!(self).id;
314− if let Some(doc) = self.document_mut(id) {
315− if doc.selections().is_empty() {
316− doc.selections.insert(view_id, Selection::point(0));
317− }
403+ let doc = self.documents.get_mut(&id).unwrap();
404+ if doc.selections().is_empty() {
405+ doc.selections.insert(view_id, Selection::point(0));
318406 }
319407 return;
320408 }
321− Action::HorizontalSplit => {
322− let view = View::new(id);
323− let view_id = self.tree.split(view, Layout::Horizontal);
324− // initialize selection for view
325− let doc = self.documents.get_mut(&id).unwrap();
326− doc.selections.insert(view_id, Selection::point(0));
327− }
328− Action::VerticalSplit => {
409+ Action::HorizontalSplit | Action::VerticalSplit => {
329410 let view = View::new(id);
330− let view_id = self.tree.split(view, Layout::Vertical);
411+ let view_id = self.tree.split(
412+ view,
413+ match action {
414+ Action::HorizontalSplit => Layout::Horizontal,
415+ Action::VerticalSplit => Layout::Vertical,
416+ _ => unreachable!(),
417+ },
418+ );
331419 // initialize selection for view
332420 let doc = self.documents.get_mut(&id).unwrap();
333421 doc.selections.insert(view_id, Selection::point(0));
@@ -337,16 +425,19 @@ impl Editor {
337425 self._refresh();
338426 }
339427
340− fn new_document(&mut self, mut document: Document) -> DocumentId {
341− let id = DocumentId(self.next_document_id);
342− self.next_document_id += 1;
343− document.id = id;
344− self.documents.insert(id, document);
428+ /// Generate an id for a new document and register it.
429+ fn new_document(&mut self, mut doc: Document) -> DocumentId {
430+ let id = self.next_document_id;
431+ // Safety: adding 1 from 1 is fine, probably impossible to reach usize max
432+ self.next_document_id =
433+ DocumentId(unsafe { NonZeroUsize::new_unchecked(self.next_document_id.0.get() + 1) });
434+ doc.id = id;
435+ self.documents.insert(id, doc);
345436 id
346437 }
347438
348− fn new_file_from_document(&mut self, action: Action, document: Document) -> DocumentId {
349− let id = self.new_document(document);
439+ fn new_file_from_document(&mut self, action: Action, doc: Document) -> DocumentId {
440+ let id = self.new_document(doc);
350441 self.switch(id, action);
351442 id
352443 }
@@ -362,54 +453,16 @@ impl Editor {
362453
363454 pub fn open(&mut self, path: PathBuf, action: Action) -> Result<DocumentId, Error> {
364455 let path = helix_core::path::get_canonicalized_path(&path)?;
365−
366− let id = self
367− .documents()
368− .find(|doc| doc.path() == Some(&path))
369− .map(|doc| doc.id);
456+ let id = self.document_by_path(&path).map(|doc| doc.id);
370457
371458 let id = if let Some(id) = id {
372459 id
373460 } else {
374461 let mut doc = Document::open(&path, None, Some(&self.theme), Some(&self.syn_loader))?;
375462
376− // try to find a language server based on the language name
377− let language_server = doc.language.as_ref().and_then(|language| {
378− self.language_servers
379− .get(language)
380− .map_err(|e| {
381− log::error!(
382− "Failed to initialize the LSP for `{}` {{ {} }}",
383− language.scope(),
384− e
385− )
386− })
387− .ok()
388− });
389−
390− if let Some(language_server) = language_server {
391− let language_id = doc
392− .language()
393− .and_then(|s| s.split('.').last()) // source.rust
394− .map(ToOwned::to_owned)
395− .unwrap_or_default();
396−
397− // TODO: this now races with on_init code if the init happens too quickly
398− tokio::spawn(language_server.text_document_did_open(
399− doc.url().unwrap(),
400− doc.version(),
401− doc.text(),
402− language_id,
403− ));
404−
405− doc.set_language_server(Some(language_server));
406− }
463+ let _ = Self::launch_language_server(&mut self.language_servers, &mut doc);
407464
408− let id = DocumentId(self.next_document_id);
409− self.next_document_id += 1;
410− doc.id = id;
411− self.documents.insert(id, doc);
412− id
465+ self.new_document(doc)
413466 };
414467
415468 self.switch(id, action);
@@ -432,11 +485,11 @@ impl Editor {
432485 pub fn close_document(&mut self, doc_id: DocumentId, force: bool) -> anyhow::Result<()> {
433486 let doc = match self.documents.get(&doc_id) {
434487 Some(doc) => doc,
435− None => anyhow::bail!("document does not exist"),
488+ None => bail!("document does not exist"),
436489 };
437490
438491 if !force && doc.is_modified() {
439− anyhow::bail!(
492+ bail!(
440493 "buffer {:?} is modified",
441494 doc.relative_path()
442495 .map(|path| path.to_string_lossy().to_string())
@@ -469,7 +522,7 @@ impl Editor {
469522 // If the document we removed was visible in all views, we will have no more views. We don't
470523 // want to close the editor just for a simple buffer close, so we need to create a new view
471524 // containing either an existing document, or a brand new document.
472− if self.tree.views().peekable().peek().is_none() {
525+ if self.tree.views().next().is_none() {
473526 let doc_id = self
474527 .documents
475528 .iter()
@@ -554,8 +607,7 @@ impl Editor {
554607 }
555608
556609 pub fn cursor(&self) -> (Option<Position>, CursorKind) {
557− let view = view!(self);
558− let doc = &self.documents[&view.doc];
610+ let (view, doc) = current_ref!(self);
559611 let cursor = doc
560612 .selection(view.id)
561613 .primary()
helix-view/src/gutter.rsnew file+95
@@ -0,0 +1,95 @@
1+use std::fmt::Write;
2+
3+use crate::{editor::Config, graphics::Style, Document, Theme, View};
4+
5+pub type GutterFn<'doc> = Box<dyn Fn(usize, bool, &mut String) -> Option<Style> + 'doc>;
6+pub type Gutter =
7+ for<'doc> fn(&'doc Document, &View, &Theme, &Config, bool, usize) -> GutterFn<'doc>;
8+
9+pub fn diagnostic<'doc>(
10+ doc: &'doc Document,
11+ _view: &View,
12+ theme: &Theme,
13+ _config: &Config,
14+ _is_focused: bool,
15+ _width: usize,
16+) -> GutterFn<'doc> {
17+ let warning = theme.get("warning");
18+ let error = theme.get("error");
19+ let info = theme.get("info");
20+ let hint = theme.get("hint");
21+ let diagnostics = doc.diagnostics();
22+
23+ Box::new(move |line: usize, _selected: bool, out: &mut String| {
24+ use helix_core::diagnostic::Severity;
25+ if let Some(diagnostic) = diagnostics.iter().find(|d| d.line == line) {
26+ write!(out, "●").unwrap();
27+ return Some(match diagnostic.severity {
28+ Some(Severity::Error) => error,
29+ Some(Severity::Warning) | None => warning,
30+ Some(Severity::Info) => info,
31+ Some(Severity::Hint) => hint,
32+ });
33+ }
34+ None
35+ })
36+}
37+
38+pub fn line_number<'doc>(
39+ doc: &'doc Document,
40+ view: &View,
41+ theme: &Theme,
42+ config: &Config,
43+ is_focused: bool,
44+ width: usize,
45+) -> GutterFn<'doc> {
46+ let text = doc.text().slice(..);
47+ let last_line = view.last_line(doc);
48+ // Whether to draw the line number for the last line of the
49+ // document or not. We only draw it if it's not an empty line.
50+ let draw_last = text.line_to_byte(last_line) < text.len_bytes();
51+
52+ let linenr = theme.get("ui.linenr");
53+ let linenr_select: Style = theme.try_get("ui.linenr.selected").unwrap_or(linenr);
54+
55+ let current_line = doc
56+ .text()
57+ .char_to_line(doc.selection(view.id).primary().cursor(text));
58+
59+ let config = config.line_number;
60+
61+ Box::new(move |line: usize, selected: bool, out: &mut String| {
62+ if line == last_line && !draw_last {
63+ write!(out, "{:>1$}", '~', width).unwrap();
64+ Some(linenr)
65+ } else {
66+ use crate::editor::LineNumber;
67+ let line = match config {
68+ LineNumber::Absolute => line + 1,
69+ LineNumber::Relative => {
70+ if current_line == line {
71+ line + 1
72+ } else {
73+ abs_diff(current_line, line)
74+ }
75+ }
76+ };
77+ let style = if selected && is_focused {
78+ linenr_select
79+ } else {
80+ linenr
81+ };
82+ write!(out, "{:>1$}", line, width).unwrap();
83+ Some(style)
84+ }
85+ })
86+}
87+
88+#[inline(always)]
89+const fn abs_diff(a: usize, b: usize) -> usize {
90+ if a > b {
91+ a - b
92+ } else {
93+ b - a
94+ }
95+}
helix-view/src/lib.rs+13−2
@@ -5,6 +5,7 @@ pub mod clipboard;
55pub mod document;
66pub mod editor;
77pub mod graphics;
8+pub mod gutter;
89pub mod info;
910pub mod input;
1011pub mod keyboard;
@@ -12,8 +13,18 @@ pub mod theme;
1213pub mod tree;
1314pub mod view;
1415
15−#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
16−pub struct DocumentId(usize);
16+use std::num::NonZeroUsize;
17+
18+// uses NonZeroUsize so Option<DocumentId> use a byte rather than two
19+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
20+pub struct DocumentId(NonZeroUsize);
21+
22+impl Default for DocumentId {
23+ fn default() -> DocumentId {
24+ // Safety: 1 is non-zero
25+ DocumentId(unsafe { NonZeroUsize::new_unchecked(1) })
26+ }
27+}
1728
1829slotmap::new_key_type! {
1930 pub struct ViewId;
helix-view/src/view.rs+20−4
@@ -1,6 +1,10 @@
11use std::borrow::Cow;
22
3−use crate::{graphics::Rect, Document, DocumentId, ViewId};
3+use crate::{
4+ graphics::Rect,
5+ gutter::{self, Gutter},
6+ Document, DocumentId, ViewId,
7+};
48use helix_core::{
59 graphemes::{grapheme_width, RopeGraphemes},
610 line_ending::line_end_char_index,
@@ -60,6 +64,8 @@ impl JumpList {
6064 }
6165}
6266
67+const GUTTERS: &[(Gutter, usize)] = &[(gutter::diagnostic, 1), (gutter::line_number, 5)];
68+
6369#[derive(Debug)]
6470pub struct View {
6571 pub id: ViewId,
@@ -83,10 +89,19 @@ impl View {
8389 }
8490 }
8591
92+ pub fn gutters(&self) -> &[(Gutter, usize)] {
93+ GUTTERS
94+ }
95+
8696 pub fn inner_area(&self) -> Rect {
87− // TODO: not ideal
88− const OFFSET: u16 = 7; // 1 diagnostic + 5 linenr + 1 gutter
89− self.area.clip_left(OFFSET).clip_bottom(1) // -1 for statusline
97+ // TODO: cache this
98+ let offset = self
99+ .gutters()
100+ .iter()
101+ .map(|(_, width)| *width as u16)
102+ .sum::<u16>()
103+ + 1; // +1 for some space between gutters and line
104+ self.area.clip_left(offset).clip_bottom(1) // -1 for statusline
90105 }
91106
92107 //
@@ -296,6 +311,7 @@ mod tests {
296311 use super::*;
297312 use helix_core::Rope;
298313 const OFFSET: u16 = 7; // 1 diagnostic + 5 linenr + 1 gutter
314+ // const OFFSET: u16 = GUTTERS.iter().map(|(_, width)| *width as u16).sum();
299315
300316 #[test]
301317 fn test_text_pos_at_screen_coords() {
languages.toml+25
@@ -508,3 +508,28 @@ shebangs = ["perl"]
508508roots = []
509509comment-token = "#"
510510indent = { tab-width = 2, unit = " " }
511+
512+[[language]]
513+name = "racket"
514+scope = "source.rkt"
515+roots = []
516+file-types = ["rkt"]
517+shebangs = ["racket"]
518+comment-token = ";"
519+language-server = { command = "racket", args = ["-l", "racket-langserver"] }
520+
521+[[language]]
522+name = "wgsl"
523+scope = "source.wgsl"
524+file-types = ["wgsl"]
525+roots = []
526+comment-token = "//"
527+indent = { tab-width = 4, unit = " " }
528+
529+[[language]]
530+name = "llvm"
531+scope = "source.llvm"
532+roots = []
533+file-types = ["ll"]
534+comment-token = ";"
535+indent = { tab-width = 2, unit = " " }
runtime/queries/llvm/highlights.scmnew file+14
@@ -0,0 +1,14 @@
1+(type) @type
2+(statement) @keyword.operator
3+(number) @constant.numeric.integer
4+(comment) @comment
5+(string) @string
6+(label) @label
7+(keyword) @keyword
8+"ret" @keyword.control.return
9+(boolean) @constant.builtin.boolean
10+(float) @constant.numeric.float
11+(constant) @constant
12+(identifier) @variable
13+(symbol) @punctuation.delimiter
14+(bracket) @punctuation.bracket
runtime/queries/wgsl/highlights.scmnew file+102
@@ -0,0 +1,102 @@
1+(const_literal) @constant.numeric
2+
3+(type_declaration) @type
4+
5+(function_declaration
6+ (identifier) @function)
7+
8+(struct_declaration
9+ (identifier) @type)
10+
11+(type_constructor_or_function_call_expression
12+ (type_declaration) @function)
13+
14+(parameter
15+ (variable_identifier_declaration (identifier) @variable.parameter))
16+
17+[
18+ "struct"
19+ "bitcast"
20+ ; "block"
21+ "discard"
22+ "enable"
23+ "fallthrough"
24+ "fn"
25+ "let"
26+ "private"
27+ "read"
28+ "read_write"
29+ "return"
30+ "storage"
31+ "type"
32+ "uniform"
33+ "var"
34+ "workgroup"
35+ "write"
36+ (texel_format)
37+] @keyword ; TODO reserved keywords
38+
39+[
40+ (true)
41+ (false)
42+] @constant.builtin.boolean
43+
44+[ "," "." ":" ";" ] @punctuation.delimiter
45+
46+;; brackets
47+[
48+ "("
49+ ")"
50+ "["
51+ "]"
52+ "{"
53+ "}"
54+] @punctuation.bracket
55+
56+[
57+ "loop"
58+ "for"
59+ "break"
60+ "continue"
61+ "continuing"
62+] @keyword.control.repeat
63+
64+[
65+ "if"
66+ "else"
67+ "elseif"
68+ "switch"
69+ "case"
70+ "default"
71+] @keyword.control.conditional
72+
73+[
74+ "&"
75+ "&&"
76+ "/"
77+ "!"
78+ "="
79+ "=="
80+ "!="
81+ ">"
82+ ">="
83+ ">>"
84+ "<"
85+ "<="
86+ "<<"
87+ "%"
88+ "-"
89+ "+"
90+ "|"
91+ "||"
92+ "*"
93+ "~"
94+ "^"
95+] @operator
96+
97+(attribute
98+ (identifier) @variable.other.member)
99+
100+(comment) @comment
101+
102+(ERROR) @error
runtime/themes/solarized_dark.toml+6−6
@@ -28,18 +28,18 @@
2828# 行号栏
2929"ui.linenr" = { fg = "base0", bg = "base02" }
3030# 当前行号栏
31−"ui.linenr.selected" = { fg = "red", modifiers = ["bold"] }
31+"ui.linenr.selected" = { fg = "blue", modifiers = ["bold"] }
3232
3333# 状态栏
34−"ui.statusline" = { fg = "base02", bg = "base1" }
34+"ui.statusline" = { fg = "base03", bg = "base0" }
3535# 非活动状态栏
36−"ui.statusline.inactive" = { fg = "base02", bg = "base00" }
36+"ui.statusline.inactive" = { fg = "base1", bg = "base01" }
3737
3838# 补全窗口, preview窗口
39−"ui.popup" = { bg = "base1" }
39+"ui.popup" = { bg = "base02" }
4040# 影响 补全选中 cmd弹出信息选中
41−"ui.menu.selected" = { fg = "base02", bg = "violet"}
42−"ui.menu" = { fg = "base02" }
41+"ui.menu.selected" = { fg = "base02", bg = "base2"}
42+"ui.menu" = { fg = "base1" }
4343# ??
4444"ui.window" = { fg = "base3" }
4545# 命令行 补全的帮助信息
runtime/themes/solarized_light.toml+6−6
@@ -28,18 +28,18 @@
2828# 行号栏
2929"ui.linenr" = { fg = "base0", bg = "base02" }
3030# 当前行号栏
31−"ui.linenr.selected" = { fg = "red", modifiers = ["bold"] }
31+"ui.linenr.selected" = { fg = "blue", modifiers = ["bold"] }
3232
3333# 状态栏
34−"ui.statusline" = { fg = "base02", bg = "base1" }
34+"ui.statusline" = { fg = "base03", bg = "base0" }
3535# 非活动状态栏
36−"ui.statusline.inactive" = { fg = "base02", bg = "base00" }
36+"ui.statusline.inactive" = { fg = "base1", bg = "base01" }
3737
3838# 补全窗口, preview窗口
39−"ui.popup" = { bg = "base1" }
39+"ui.popup" = { bg = "base02" }
4040# 影响 补全选中 cmd弹出信息选中
41−"ui.menu.selected" = { fg = "base02", bg = "violet"}
42−"ui.menu" = { fg = "base02" }
41+"ui.menu.selected" = { fg = "base02", bg = "base2"}
42+"ui.menu" = { fg = "base1" }
4343# ??
4444"ui.window" = { fg = "base3" }
4545# 命令行 补全的帮助信息