From 801984c7fc2cd3f4072f1bdf42c5fbfe1a634348 Mon Sep 17 00:00:00 2001 From: Mike Trinkala Date: Sun, 23 Oct 2022 16:02:58 -0700 Subject: [PATCH 01/57] Update textwrap to 0.16.0 (#4437) --- Cargo.lock | 29 +++++++++++++++++++++++++---- helix-core/Cargo.toml | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec48c596..878f4fa4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,17 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.18" @@ -383,6 +394,15 @@ dependencies = [ "memmap2", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + [[package]] name = "helix-core" version = "0.6.0" @@ -1112,9 +1132,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" dependencies = [ "smawk", "unicode-linebreak", @@ -1264,10 +1284,11 @@ checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" [[package]] name = "unicode-linebreak" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a52dcaab0c48d931f7cc8ef826fa51690a08e1ea55117ef26f89864f532383f" +checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" dependencies = [ + "hashbrown", "regex", ] diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml index 4eaadd1e..7585c347 100644 --- a/helix-core/Cargo.toml +++ b/helix-core/Cargo.toml @@ -43,7 +43,7 @@ encoding_rs = "0.8" chrono = { version = "0.4", default-features = false, features = ["alloc", "std"] } etcetera = "0.4" -textwrap = "0.15.1" +textwrap = "0.16.0" [dev-dependencies] quickcheck = { version = "1", default-features = false } From d8ffa02255b99f94475cfaa7f456c6ae991dda25 Mon Sep 17 00:00:00 2001 From: Owen Lynch Date: Mon, 24 Oct 2022 18:44:36 -0400 Subject: [PATCH 02/57] Update scala treesitter grammar (#4353) --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index a639ccad..6f58112a 100644 --- a/languages.toml +++ b/languages.toml @@ -982,7 +982,7 @@ language-server = { command = "metals" } [[grammar]] name = "scala" -source = { git = "https://github.com/tree-sitter/tree-sitter-scala", rev = "0a3dd53a7fc4b352a538397d054380aaa28be54c" } +source = { git = "https://github.com/tree-sitter/tree-sitter-scala", rev = "140c96cf398693189d4e50f76d19ddfcd8a018f8" } [[language]] name = "dockerfile" From 45da569a4c2db545ffae041eab9fbc66bde44ed3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 18:14:05 -0500 Subject: [PATCH 03/57] build(deps): bump anyhow from 1.0.65 to 1.0.66 (#4459) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 878f4fa4..7b2ea378 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,9 +33,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.65" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] name = "arc-swap" From 6ea2c541528a2d4ae3562f45e3e6206cca96b6c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 18:14:27 -0500 Subject: [PATCH 04/57] build(deps): bump futures-util from 0.3.24 to 0.3.25 (#4460) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b2ea378..84409051 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -288,9 +288,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" [[package]] name = "futures-executor" @@ -305,15 +305,15 @@ dependencies = [ [[package]] name = "futures-task" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" [[package]] name = "futures-util" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" dependencies = [ "futures-core", "futures-task", From 093842988b6c7fcd15dc90f9bf012a2fa6005de4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 18:18:41 -0500 Subject: [PATCH 05/57] build(deps): bump termini from 0.1.2 to 0.1.4 (#4461) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84409051..96682aa3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1123,9 +1123,9 @@ dependencies = [ [[package]] name = "termini" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "394766021ef3dae8077f080518cdf5360831990f77f5708d5e3594c9b3efa2f9" +checksum = "8c0f7ecb9c2a380d2686a747e4fc574043712326e8d39fbd220ab3bd29768a12" dependencies = [ "dirs-next", ] From 02385599e1e47ec46f5cfbba8b454378d5f19f41 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 18:18:50 -0500 Subject: [PATCH 06/57] build(deps): bump serde_json from 1.0.86 to 1.0.87 (#4462) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 96682aa3..35813993 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -959,9 +959,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" dependencies = [ "itoa", "ryu", From 6aacdaaf9f3e315b99aba8bae6d19c6dc0bae831 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 18:35:12 -0500 Subject: [PATCH 07/57] build(deps): bump futures-executor from 0.3.24 to 0.3.25 (#4464) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35813993..283fffe2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -294,9 +294,9 @@ checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" [[package]] name = "futures-executor" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" dependencies = [ "futures-core", "futures-task", From 001e4e304b6177148b8a74a222e0d02b91f53a11 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 18:37:25 -0500 Subject: [PATCH 08/57] build(deps): bump serde from 1.0.145 to 1.0.147 (#4463) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 283fffe2..163b3ad4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -939,18 +939,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2", "quote", From c47ca331374b28a70c8bb9fd0fe991c478c696a1 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Tue, 25 Oct 2022 07:03:35 -0500 Subject: [PATCH 09/57] Render diagnostics in the file picker preview (#4324) This is mostly for the sake of the diagnostics pickers: without rendering the diagnostic styles, it's hard to tell where the entries in the picker are pointing to. --- helix-term/src/ui/picker.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index c7149c61..2505f219 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -248,8 +248,14 @@ impl Component for FilePicker { let offset = Position::new(first_line, 0); - let highlights = + let mut highlights = EditorView::doc_syntax_highlights(doc, offset, area.height, &cx.editor.theme); + for spans in EditorView::doc_diagnostics_highlights(doc, &cx.editor.theme) { + if spans.is_empty() { + continue; + } + highlights = Box::new(helix_core::syntax::merge(highlights, spans)); + } EditorView::render_text_highlights( doc, offset, From 9fae4b81189e9ba02718595a09840535f6fb558b Mon Sep 17 00:00:00 2001 From: GabrielDertoni Date: Sun, 9 Oct 2022 00:23:02 -0300 Subject: [PATCH 10/57] fix: terminal freezing on `shell_insert_output` This bug occurs on `shell_insert_output` and `shell_append_output` commands. The previous implementation would create a child process using the Rust stdlib's `Command` builder. However, when nothing should be piped in from the editor, the default value for `stdin` would be used. According to the Rust stdlib documentation that is `Stdio::inherit` which will make the child process inherit the parent process' stdin. This would cause the terminal to freeze. This change will set the child process' stdin to `Stdio::null` whenever it doesn't pipe it. In the `if` statement where this change was made there was an extra condition for windows that I am not sure if would require some special treatment. --- helix-term/src/commands.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 468e9814..69870a27 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -4665,6 +4665,8 @@ fn shell_impl( if input.is_some() || cfg!(windows) { process.stdin(Stdio::piped()); + } else { + process.stdin(Stdio::null()); } let mut process = match process.spawn() { From 65edf9c19880fe4fd068db6d86c4c2830c8a91f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zabielski?= Date: Wed, 26 Oct 2022 04:15:46 +0200 Subject: [PATCH 11/57] fix: repeating repeat operator (#4450) --- helix-term/src/ui/editor.rs | 61 +++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index b1bb02c7..72c9d15e 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -25,7 +25,7 @@ use helix_view::{ keyboard::{KeyCode, KeyModifiers}, Document, Editor, Theme, View, }; -use std::{borrow::Cow, cmp::min, path::PathBuf}; +use std::{borrow::Cow, cmp::min, num::NonZeroUsize, path::PathBuf}; use tui::buffer::Buffer as Surface; @@ -1009,37 +1009,40 @@ impl EditorView { } // special handling for repeat operator (key!('.'), _) if self.keymaps.pending().is_empty() => { - // first execute whatever put us into insert mode - self.last_insert.0.execute(cxt); - // then replay the inputs - for key in self.last_insert.1.clone() { - match key { - InsertEvent::Key(key) => self.insert_mode(cxt, key), - InsertEvent::CompletionApply(compl) => { - let (view, doc) = current!(cxt.editor); - - doc.restore(view); - - let text = doc.text().slice(..); - let cursor = doc.selection(view.id).primary().cursor(text); - - let shift_position = - |pos: usize| -> usize { pos + cursor - compl.trigger_offset }; - - let tx = Transaction::change( - doc.text(), - compl.changes.iter().cloned().map(|(start, end, t)| { - (shift_position(start), shift_position(end), t) - }), - ); - apply_transaction(&tx, doc, view); - } - InsertEvent::TriggerCompletion => { - let (_, doc) = current!(cxt.editor); - doc.savepoint(); + for _ in 0..cxt.editor.count.map_or(1, NonZeroUsize::into) { + // first execute whatever put us into insert mode + self.last_insert.0.execute(cxt); + // then replay the inputs + for key in self.last_insert.1.clone() { + match key { + InsertEvent::Key(key) => self.insert_mode(cxt, key), + InsertEvent::CompletionApply(compl) => { + let (view, doc) = current!(cxt.editor); + + doc.restore(view); + + let text = doc.text().slice(..); + let cursor = doc.selection(view.id).primary().cursor(text); + + let shift_position = + |pos: usize| -> usize { pos + cursor - compl.trigger_offset }; + + let tx = Transaction::change( + doc.text(), + compl.changes.iter().cloned().map(|(start, end, t)| { + (shift_position(start), shift_position(end), t) + }), + ); + apply_transaction(&tx, doc, view); + } + InsertEvent::TriggerCompletion => { + let (_, doc) = current!(cxt.editor); + doc.savepoint(); + } } } } + cxt.editor.count = None; } _ => { // set the count From ba9e50e93b43f102de352ead57c28d86c34a7c73 Mon Sep 17 00:00:00 2001 From: Gaurav Tyagi Date: Wed, 26 Oct 2022 08:28:49 +0530 Subject: [PATCH 12/57] Add `:update` that will write the changes if the file has been modified. (#4426) * add command update that will write the changes if file hasn been modified * add docs * update the docs --- book/src/generated/typable-cmd.md | 1 + helix-term/src/commands/typed.rs | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/book/src/generated/typable-cmd.md b/book/src/generated/typable-cmd.md index 05a0985b..49e7e778 100644 --- a/book/src/generated/typable-cmd.md +++ b/book/src/generated/typable-cmd.md @@ -44,6 +44,7 @@ | `:show-directory`, `:pwd` | Show the current working directory. | | `:encoding` | Set encoding. Based on `https://encoding.spec.whatwg.org`. | | `:reload` | Discard changes and reload from the source file. | +| `:update` | Write changes only if the file has been modified. | | `:lsp-restart` | Restarts the Language Server that is in use by the current doc | | `:tree-sitter-scopes` | Display tree sitter scopes, primarily for theming and development. | | `:debug-start`, `:dbg` | Start a debug session from a given template with given parameters. | diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 7ea4c801..9b79c3e6 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -1029,6 +1029,24 @@ fn reload( }) } +/// Update the [`Document`] if it has been modified. +fn update( + cx: &mut compositor::Context, + args: &[Cow], + event: PromptEvent, +) -> anyhow::Result<()> { + if event != PromptEvent::Validate { + return Ok(()); + } + + let (_view, doc) = current!(cx.editor); + if doc.is_modified() { + write(cx, args, event) + } else { + Ok(()) + } +} + fn lsp_restart( cx: &mut compositor::Context, _args: &[Cow], @@ -1957,6 +1975,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ fun: reload, completer: None, }, + TypableCommand { + name: "update", + aliases: &[], + doc: "Write changes only if the file has been modified.", + fun: update, + completer: None, + }, TypableCommand { name: "lsp-restart", aliases: &[], From ac0fe29867012ba0840ee7c8893b41d976d5ab38 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Wed, 26 Oct 2022 03:59:50 +0100 Subject: [PATCH 13/57] commands: Make no arg ':theme' show name (#3740) Most commands that accept an argument show their current value if no argument is specified. The `:theme` command previously displayed an error message in the status bar if not provided with an argument: ``` Theme name not provided ``` It now shows the current theme name in the status bar if no argument is specified. Signed-off-by: James O. D. Hunt Signed-off-by: James O. D. Hunt --- book/src/generated/typable-cmd.md | 2 +- helix-term/src/commands/typed.rs | 25 ++++++++++++++--------- helix-view/src/theme.rs | 34 +++++++++++++++++++------------ 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/book/src/generated/typable-cmd.md b/book/src/generated/typable-cmd.md index 49e7e778..f858ba72 100644 --- a/book/src/generated/typable-cmd.md +++ b/book/src/generated/typable-cmd.md @@ -28,7 +28,7 @@ | `:quit-all!`, `:qa!` | Force close all views ignoring unsaved changes. | | `:cquit`, `:cq` | Quit with exit code (default 1). Accepts an optional integer exit code (:cq 2). | | `:cquit!`, `:cq!` | Force quit with exit code (default 1) ignoring unsaved changes. Accepts an optional integer exit code (:cq! 2). | -| `:theme` | Change the editor theme. | +| `:theme` | Change the editor theme (show current theme if no name specified). | | `:clipboard-yank` | Yank main selection into system clipboard. | | `:clipboard-yank-join` | Yank joined selections into system clipboard. A separator can be provided as first argument. Default value is newline. | | `:primary-clipboard-yank` | Yank main selection into system primary clipboard. | diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 9b79c3e6..0cf75ada 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -772,16 +772,21 @@ fn theme( }; } PromptEvent::Validate => { - let theme_name = args.first().with_context(|| "Theme name not provided")?; - let theme = cx - .editor - .theme_loader - .load(theme_name) - .with_context(|| "Theme does not exist")?; - if !(true_color || theme.is_16_color()) { - bail!("Unsupported theme: theme requires true color support"); + if let Some(theme_name) = args.first() { + let theme = cx + .editor + .theme_loader + .load(theme_name) + .with_context(|| "Theme does not exist")?; + if !(true_color || theme.is_16_color()) { + bail!("Unsupported theme: theme requires true color support"); + } + cx.editor.set_theme(theme); + } else { + let name = cx.editor.theme.name().to_string(); + + cx.editor.set_status(name); } - cx.editor.set_theme(theme); } }; @@ -1866,7 +1871,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ TypableCommand { name: "theme", aliases: &[], - doc: "Change the editor theme.", + doc: "Change the editor theme (show current theme if no name specified).", fun: theme, completer: Some(completers::theme), }, diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index 302844b7..f1219ec5 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -14,19 +14,14 @@ use toml::{map::Map, Value}; use crate::graphics::UnderlineStyle; pub use crate::graphics::{Color, Modifier, Style}; -pub static DEFAULT_THEME: Lazy = Lazy::new(|| { - // let raw_theme: Value = toml::from_slice(include_bytes!("../../theme.toml")) - // .expect("Failed to parse default theme"); - // Theme::from(raw_theme) - - toml::from_slice(include_bytes!("../../theme.toml")).expect("Failed to parse default theme") +pub static DEFAULT_THEME: Lazy = Lazy::new(|| Theme { + name: "default".into(), + ..toml::from_slice(include_bytes!("../../theme.toml")).expect("Failed to parse default theme") }); -pub static BASE16_DEFAULT_THEME: Lazy = Lazy::new(|| { - // let raw_theme: Value = toml::from_slice(include_bytes!("../../base16_theme.toml")) - // .expect("Failed to parse base 16 default theme"); - // Theme::from(raw_theme) - toml::from_slice(include_bytes!("../../base16_theme.toml")) +pub static BASE16_DEFAULT_THEME: Lazy = Lazy::new(|| Theme { + name: "base16_theme".into(), + ..toml::from_slice(include_bytes!("../../base16_theme.toml")) .expect("Failed to parse base 16 default theme") }); @@ -53,7 +48,12 @@ impl Loader { return Ok(self.base16_default()); } - self.load_theme(name, name, false).map(Theme::from) + let theme = self.load_theme(name, name, false).map(Theme::from)?; + + Ok(Theme { + name: name.into(), + ..theme + }) } // load the theme and its parent recursively and merge them @@ -180,8 +180,10 @@ impl Loader { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct Theme { + name: String, + // UI styles are stored in a HashMap styles: HashMap, // tree-sitter highlight styles are stored in a Vec to optimize lookups @@ -200,6 +202,7 @@ impl From for Theme { styles, scopes, highlights, + ..Default::default() } } } @@ -217,6 +220,7 @@ impl<'de> Deserialize<'de> for Theme { styles, scopes, highlights, + ..Default::default() }) } } @@ -266,6 +270,10 @@ impl Theme { self.highlights[index] } + pub fn name(&self) -> &str { + &self.name + } + pub fn get(&self, scope: &str) -> Style { self.try_get(scope).unwrap_or_default() } From c4d7cde6c8d7f5ca3a9cabd50bdfbda9c3f7bb15 Mon Sep 17 00:00:00 2001 From: A-Walrus <58790821+A-Walrus@users.noreply.github.com> Date: Wed, 26 Oct 2022 06:00:13 +0300 Subject: [PATCH 14/57] Allow the area to be bigger than u16 (width and height remain u16) (#4318) Now the editor can fill **very** large terminals. Changed/removed tests which check the truncating behaviour. --- helix-tui/src/buffer.rs | 14 +++++------ helix-tui/tests/terminal.rs | 6 ++--- helix-view/src/graphics.rs | 49 ++++--------------------------------- 3 files changed, 15 insertions(+), 54 deletions(-) diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs index 424e6d32..23ba43f1 100644 --- a/helix-tui/src/buffer.rs +++ b/helix-tui/src/buffer.rs @@ -137,7 +137,7 @@ impl Buffer { /// Returns a Buffer with all cells initialized with the attributes of the given Cell pub fn filled(area: Rect, cell: &Cell) -> Buffer { - let size = area.area() as usize; + let size = area.area(); let mut content = Vec::with_capacity(size); for _ in 0..size { content.push(cell.clone()); @@ -239,7 +239,7 @@ impl Buffer { y, self.area ); - ((y - self.area.y) * self.area.width + (x - self.area.x)) as usize + ((y - self.area.y) as usize) * (self.area.width as usize) + ((x - self.area.x) as usize) } /// Returns the index in the Vec for the given global (x, y) coordinates, @@ -278,8 +278,8 @@ impl Buffer { self.content.len() ); ( - self.area.x + i as u16 % self.area.width, - self.area.y + i as u16 / self.area.width, + (self.area.x as usize + (i % self.area.width as usize)) as u16, + (self.area.y as usize + (i / self.area.width as usize)) as u16, ) } @@ -480,7 +480,7 @@ impl Buffer { /// Resize the buffer so that the mapped area matches the given area and that the buffer /// length is equal to area.width * area.height pub fn resize(&mut self, area: Rect) { - let length = area.area() as usize; + let length = area.area(); if self.content.len() > length { self.content.truncate(length); } else { @@ -587,8 +587,8 @@ impl Buffer { let mut to_skip: usize = 0; for (i, (current, previous)) in next_buffer.iter().zip(previous_buffer.iter()).enumerate() { if (current != previous || invalidated > 0) && to_skip == 0 { - let x = i as u16 % width; - let y = i as u16 / width; + let x = (i % width as usize) as u16; + let y = (i / width as usize) as u16; updates.push((x, y, &next_buffer[i])); } diff --git a/helix-tui/tests/terminal.rs b/helix-tui/tests/terminal.rs index 3dd3b0b0..2824c9f2 100644 --- a/helix-tui/tests/terminal.rs +++ b/helix-tui/tests/terminal.rs @@ -4,12 +4,12 @@ use helix_tui::{ }; #[test] -fn terminal_buffer_size_should_be_limited() { +fn terminal_buffer_size_should_not_be_limited() { let backend = TestBackend::new(400, 400); let terminal = Terminal::new(backend).unwrap(); let size = terminal.backend().size().unwrap(); - assert_eq!(size.width, 255); - assert_eq!(size.height, 255); + assert_eq!(size.width, 400); + assert_eq!(size.height, 400); } // #[test] diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs index 4374a537..cbae873a 100644 --- a/helix-view/src/graphics.rs +++ b/helix-view/src/graphics.rs @@ -95,31 +95,19 @@ pub struct Rect { } impl Rect { - /// Creates a new rect, with width and height limited to keep the area under max u16. - /// If clipped, aspect ratio will be preserved. + /// Creates a new rect, with width and height pub fn new(x: u16, y: u16, width: u16, height: u16) -> Rect { - let max_area = u16::max_value(); - let (clipped_width, clipped_height) = - if u32::from(width) * u32::from(height) > u32::from(max_area) { - let aspect_ratio = f64::from(width) / f64::from(height); - let max_area_f = f64::from(max_area); - let height_f = (max_area_f / aspect_ratio).sqrt(); - let width_f = height_f * aspect_ratio; - (width_f as u16, height_f as u16) - } else { - (width, height) - }; Rect { x, y, - width: clipped_width, - height: clipped_height, + width, + height, } } #[inline] - pub fn area(self) -> u16 { - self.width * self.height + pub fn area(self) -> usize { + (self.width as usize) * (self.height as usize) } #[inline] @@ -630,33 +618,6 @@ impl Style { mod tests { use super::*; - #[test] - fn test_rect_size_truncation() { - for width in 256u16..300u16 { - for height in 256u16..300u16 { - let rect = Rect::new(0, 0, width, height); - rect.area(); // Should not panic. - assert!(rect.width < width || rect.height < height); - // The target dimensions are rounded down so the math will not be too precise - // but let's make sure the ratios don't diverge crazily. - assert!( - (f64::from(rect.width) / f64::from(rect.height) - - f64::from(width) / f64::from(height)) - .abs() - < 1.0 - ) - } - } - - // One dimension below 255, one above. Area above max u16. - let width = 900; - let height = 100; - let rect = Rect::new(0, 0, width, height); - assert_ne!(rect.width, 900); - assert_ne!(rect.height, 100); - assert!(rect.width < width || rect.height < height); - } - #[test] fn test_rect_size_preservation() { for width in 0..256u16 { From 27217bb435fa0242b5cf43a23d3d13c739866b9f Mon Sep 17 00:00:00 2001 From: Matthias Deiml Date: Thu, 27 Oct 2022 15:39:22 +0200 Subject: [PATCH 15/57] Update tree-sitter markdown grammar (#4483) --- languages.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/languages.toml b/languages.toml index 6f58112a..cc8f155b 100644 --- a/languages.toml +++ b/languages.toml @@ -943,7 +943,7 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "markdown" -source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "d5740f0fe4b8e4603f2229df107c5c9ef5eec389", subpath = "tree-sitter-markdown" } +source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "a7de4be29783a6e25f3240c90afea52f2417faa3", subpath = "tree-sitter-markdown" } [[language]] name = "markdown.inline" @@ -955,7 +955,7 @@ grammar = "markdown_inline" [[grammar]] name = "markdown_inline" -source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "d5740f0fe4b8e4603f2229df107c5c9ef5eec389", subpath = "tree-sitter-markdown-inline" } +source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "a7de4be29783a6e25f3240c90afea52f2417faa3", subpath = "tree-sitter-markdown-inline" } [[language]] name = "dart" From b1ffbbd49fd54525c55252162b5897d4ad4e990d Mon Sep 17 00:00:00 2001 From: Matthias Deiml Date: Thu, 27 Oct 2022 15:40:47 +0200 Subject: [PATCH 16/57] Include unnamed children for html injected into inline markdown (#4478) --- runtime/queries/markdown.inline/injections.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/markdown.inline/injections.scm b/runtime/queries/markdown.inline/injections.scm index c137a822..2dd149d9 100644 --- a/runtime/queries/markdown.inline/injections.scm +++ b/runtime/queries/markdown.inline/injections.scm @@ -1,2 +1,2 @@ -((html_tag) @injection.content (#set! injection.language "html")) +((html_tag) @injection.content (#set! injection.language "html") (#set! injection.include-unnamed-children)) From b4a3dd8f89d6b3c1c973be2dfb2121c4b6cb501f Mon Sep 17 00:00:00 2001 From: lazytanuki <43273245+lazytanuki@users.noreply.github.com> Date: Thu, 27 Oct 2022 16:16:55 +0200 Subject: [PATCH 17/57] feat(lsp): LSP preselected items appear first in completion menu (#4480) * feat(lsp): LSP preselected items appear first in completion menu * fix: shorter diff --- helix-term/src/ui/completion.rs | 6 +++++- helix-term/src/ui/menu.rs | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs index a21767f9..de7c3232 100644 --- a/helix-term/src/ui/completion.rs +++ b/helix-term/src/ui/completion.rs @@ -92,11 +92,15 @@ impl Completion { pub fn new( editor: &Editor, - items: Vec, + mut items: Vec, offset_encoding: helix_lsp::OffsetEncoding, start_offset: usize, trigger_offset: usize, ) -> Self { + // Sort completion items according to their preselect status (given by the LSP server) + items.sort_by_key(|item| !item.preselect.unwrap_or(false)); + + // Then create the menu let menu = Menu::new(items, (), move |editor: &mut Editor, item, event| { fn item_to_transaction( doc: &Document, diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index 75769b90..99c2473d 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -108,7 +108,8 @@ impl Menu { .map(|score| (index, score)) }), ); - self.matches.sort_unstable_by_key(|(_, score)| -score); + // Order of equal elements needs to be preserved as LSP preselected items come in order of high to low priority + self.matches.sort_by_key(|(_, score)| -score); // reset cursor position self.cursor = None; From de5b100556ce4d9a2f739bd54904246f97dc6863 Mon Sep 17 00:00:00 2001 From: Sora Date: Fri, 28 Oct 2022 03:19:01 +0200 Subject: [PATCH 18/57] Add the debugger for Zig (#4492) --- languages.toml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/languages.toml b/languages.toml index cc8f155b..0a87fad2 100644 --- a/languages.toml +++ b/languages.toml @@ -767,6 +767,29 @@ language-server = { command = "zls" } indent = { tab-width = 4, unit = " " } formatter = { command = "zig" , args = ["fmt", "--stdin"] } +[language.debugger] +name = "lldb-vscode" +transport = "stdio" +command = "lldb-vscode" + +[[language.debugger.templates]] +name = "binary" +request = "launch" +completion = [ { name = "binary", completion = "filename" } ] +args = { console = "internalConsole", program = "{0}" } + +[[language.debugger.templates]] +name = "attach" +request = "attach" +completion = [ "pid" ] +args = { console = "internalConsole", pid = "{0}" } + +[[language.debugger.templates]] +name = "gdbserver attach" +request = "attach" +completion = [ { name = "lldb connect url", default = "connect://localhost:3333" }, { name = "file", completion = "filename" }, "pid" ] +args = { console = "internalConsole", attachCommands = [ "platform select remote-gdb-server", "platform connect {0}", "file {1}", "attach {2}" ] } + [[grammar]] name = "zig" source = { git = "https://github.com/maxxnino/tree-sitter-zig", rev = "8d3224c3bd0890fe08358886ebf54fca2ed448a6" } From 6752c7d3474289596c9e062f54beaf07011b6a40 Mon Sep 17 00:00:00 2001 From: Dario Oddenino Date: Fri, 28 Oct 2022 03:31:28 +0200 Subject: [PATCH 19/57] Trim quotes and braces from paths in goto_file_impl (#4370) Co-authored-by: Michael Davis --- helix-term/src/commands.rs | 23 ++++++++---- helix-term/tests/test/commands.rs | 60 +++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 6 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 69870a27..48bd9e57 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1023,6 +1023,7 @@ fn goto_file_vsplit(cx: &mut Context) { goto_file_impl(cx, Action::VerticalSplit); } +/// Goto files in selection. fn goto_file_impl(cx: &mut Context, action: Action) { let (view, doc) = current_ref!(cx.editor); let text = doc.text(); @@ -1032,15 +1033,25 @@ fn goto_file_impl(cx: &mut Context, action: Action) { .map(|r| text.slice(r.from()..r.to()).to_string()) .collect(); let primary = selections.primary(); - if selections.len() == 1 && primary.to() - primary.from() == 1 { - let current_word = movement::move_next_long_word_start( - text.slice(..), - movement::move_prev_long_word_start(text.slice(..), primary, 1), - 1, + // Checks whether there is only one selection with a width of 1 + if selections.len() == 1 && primary.len() == 1 { + let count = cx.count(); + let text_slice = text.slice(..); + // In this case it selects the WORD under the cursor + let current_word = textobject::textobject_word( + text_slice, + primary, + textobject::TextObject::Inside, + count, + true, ); + // Trims some surrounding chars so that the actual file is opened. + let surrounding_chars: &[_] = &['\'', '"', '(', ')']; paths.clear(); paths.push( - text.slice(current_word.from()..current_word.to()) + current_word + .fragment(text_slice) + .trim_matches(surrounding_chars) .to_string(), ); } diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs index e24ee3e0..aadf104b 100644 --- a/helix-term/tests/test/commands.rs +++ b/helix-term/tests/test/commands.rs @@ -1,6 +1,7 @@ use std::ops::RangeInclusive; use helix_core::diagnostic::Severity; +use helix_term::application::Application; use super::*; @@ -133,3 +134,62 @@ async fn test_selection_duplication() -> anyhow::Result<()> { .await?; Ok(()) } + +#[tokio::test(flavor = "multi_thread")] +async fn test_goto_file_impl() -> anyhow::Result<()> { + let file = tempfile::NamedTempFile::new()?; + + fn match_paths(app: &Application, matches: Vec<&str>) -> usize { + app.editor + .documents() + .filter_map(|d| d.path()?.file_name()) + .filter(|n| matches.iter().any(|m| *m == n.to_string_lossy())) + .count() + } + + // Single selection + test_key_sequence( + &mut AppBuilder::new().with_file(file.path(), None).build()?, + Some("ione.js%gf"), + Some(&|app| { + assert_eq!(1, match_paths(app, vec!["one.js"])); + }), + false, + ) + .await?; + + // Multiple selection + test_key_sequence( + &mut AppBuilder::new().with_file(file.path(), None).build()?, + Some("ione.jstwo.js%gf"), + Some(&|app| { + assert_eq!(2, match_paths(app, vec!["one.js", "two.js"])); + }), + false, + ) + .await?; + + // Cursor on first quote + test_key_sequence( + &mut AppBuilder::new().with_file(file.path(), None).build()?, + Some("iimport 'one.js'B;gf"), + Some(&|app| { + assert_eq!(1, match_paths(app, vec!["one.js"])); + }), + false, + ) + .await?; + + // Cursor on last quote + test_key_sequence( + &mut AppBuilder::new().with_file(file.path(), None).build()?, + Some("iimport 'one.js'bgf"), + Some(&|app| { + assert_eq!(1, match_paths(app, vec!["one.js"])); + }), + false, + ) + .await?; + + Ok(()) +} From cefdface3ba6cc2ed60a34fc7115de245c1f58b3 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 28 Oct 2022 07:42:40 -0500 Subject: [PATCH 20/57] Include colons for typable commands in command palette (#4495) Before: Goto next buffer. [buffer-next] After: Goto next buffer. [:buffer-next] --- helix-term/src/commands.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 48bd9e57..fca55b68 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2443,8 +2443,8 @@ impl ui::menu::Item for MappableCommand { match self { MappableCommand::Typable { doc, name, .. } => match keymap.get(name as &String) { - Some(bindings) => format!("{} ({}) [{}]", doc, fmt_binding(bindings), name).into(), - None => format!("{} [{}]", doc, name).into(), + Some(bindings) => format!("{} ({}) [:{}]", doc, fmt_binding(bindings), name).into(), + None => format!("{} [:{}]", doc, name).into(), }, MappableCommand::Static { doc, name, .. } => match keymap.get(*name) { Some(bindings) => format!("{} ({}) [{}]", doc, fmt_binding(bindings), name).into(), From 26f21da531179ccc77e70b73e32a1b458c4e225b Mon Sep 17 00:00:00 2001 From: rsteube Date: Fri, 28 Oct 2022 15:22:41 +0200 Subject: [PATCH 21/57] language: added vhs (#4486) --- book/src/generated/lang-support.md | 1 + languages.toml | 13 +++++++++++ runtime/queries/vhs/highlights.scm | 36 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 runtime/queries/vhs/highlights.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index caf5d525..c166af29 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -120,6 +120,7 @@ | v | ✓ | | | `vls` | | vala | ✓ | | | `vala-language-server` | | verilog | ✓ | ✓ | | `svlangserver` | +| vhs | ✓ | | | | | vue | ✓ | | | `vls` | | wast | ✓ | | | | | wat | ✓ | | | | diff --git a/languages.toml b/languages.toml index 0a87fad2..c5c45afc 100644 --- a/languages.toml +++ b/languages.toml @@ -1872,3 +1872,16 @@ formatter = { command = "dfmt" } [[grammar]] name = "d" source = { git = "https://github.com/gdamore/tree-sitter-d", rev="601c4a1e8310fb2f3c43fa8a923d0d27497f3c04" } + +[[language]] +name = "vhs" +scope = "source.vhs" +file-types = ["tape"] +roots = [] +comment-token = "#" +indent = { tab-width = 2, unit = " " } +grammar = "vhs" + +[[grammar]] +name = "vhs" +source = { git = "https://github.com/charmbracelet/tree-sitter-vhs", rev = "c6d81f34c011c29ee86dd73b45a8ecc9f2e2bdaf" } diff --git a/runtime/queries/vhs/highlights.scm b/runtime/queries/vhs/highlights.scm new file mode 100644 index 00000000..9a2d05cf --- /dev/null +++ b/runtime/queries/vhs/highlights.scm @@ -0,0 +1,36 @@ +[ + "Output" + "Backspace" + "Down" + "Enter" + "Escape" + "Left" + "Right" + "Space" + "Tab" + "Up" + "Set" + "Type" + "Sleep" + "Hide" + "Show" ] @keyword + +[ "FontFamily" + "FontSize" + "Framerate" + "Height" + "LetterSpacing" + "TypingSpeed" + "LineHeight" + "Padding" + "Theme" + "Width" ] @type + +[ "@" ] @operator +(control) @function.macro +(float) @constant.numeric.float +(integer) @constant.numeric.integer +(comment) @comment +(path) @string.special.path +[(string) (json)] @string +(time) @string.special.symbol \ No newline at end of file From c58e1729cef774db6619e394942465c12abd65cd Mon Sep 17 00:00:00 2001 From: Poliorcetics Date: Sat, 29 Oct 2022 01:20:55 +0200 Subject: [PATCH 22/57] fix: Never create automatic doc popups outside of Insert mode (#4456) --- helix-term/src/commands/lsp.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index 3c72cd2a..d7617c50 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -9,7 +9,7 @@ use tui::text::{Span, Spans}; use super::{align_view, push_jump, Align, Context, Editor, Open}; use helix_core::{path, Selection}; -use helix_view::{apply_transaction, editor::Action, theme::Style}; +use helix_view::{apply_transaction, document::Mode, editor::Action, theme::Style}; use crate::{ compositor::{self, Compositor}, @@ -957,6 +957,14 @@ pub fn signature_help_impl(cx: &mut Context, invoked: SignatureHelpInvoked) { return; } + // If the signature help invocation is automatic, don't show it outside of Insert Mode: + // it very probably means the server was a little slow to respond and the user has + // already moved on to something else, making a signature help popup will just be an + // annoyance, see https://github.com/helix-editor/helix/issues/3112 + if !was_manually_invoked && editor.mode != Mode::Insert { + return; + } + let response = match response { // According to the spec the response should be None if there // are no signatures, but some servers don't follow this. From 5e256e4a98561c2085b1ecae1e39e27bf3744724 Mon Sep 17 00:00:00 2001 From: Matthias Deiml Date: Sat, 29 Oct 2022 17:24:33 +0200 Subject: [PATCH 23/57] Make shell_impl concurrent (#3180) --- helix-term/src/commands.rs | 41 +++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index fca55b68..172a7b2e 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -8,7 +8,7 @@ use tui::text::Spans; pub use typed::*; use helix_core::{ - comment, coords_at_pos, find_first_non_whitespace_char, find_root, graphemes, + comment, coords_at_pos, encoding, find_first_non_whitespace_char, find_root, graphemes, history::UndoKind, increment::date_time::DateTimeIncrementor, increment::{number::NumberIncrementor, Increment}, @@ -4630,7 +4630,7 @@ fn shell_keep_pipe(cx: &mut Context) { for (i, range) in selection.ranges().iter().enumerate() { let fragment = range.slice(text); - let (_output, success) = match shell_impl(shell, input, Some(fragment)) { + let (_output, success) = match shell_impl(shell, input, Some(fragment.into())) { Ok(result) => result, Err(err) => { cx.editor.set_error(err.to_string()); @@ -4658,13 +4658,17 @@ fn shell_keep_pipe(cx: &mut Context) { ); } -fn shell_impl( +fn shell_impl(shell: &[String], cmd: &str, input: Option) -> anyhow::Result<(Tendril, bool)> { + tokio::task::block_in_place(|| helix_lsp::block_on(shell_impl_async(shell, cmd, input))) +} + +async fn shell_impl_async( shell: &[String], cmd: &str, - input: Option, + input: Option, ) -> anyhow::Result<(Tendril, bool)> { - use std::io::Write; - use std::process::{Command, Stdio}; + use std::process::Stdio; + use tokio::process::Command; ensure!(!shell.is_empty(), "No shell set"); let mut process = Command::new(&shell[0]); @@ -4687,13 +4691,22 @@ fn shell_impl( return Err(e.into()); } }; - if let Some(input) = input { - let mut stdin = process.stdin.take().unwrap(); - for chunk in input.chunks() { - stdin.write_all(chunk.as_bytes())?; - } - } - let output = process.wait_with_output()?; + let output = if let Some(mut stdin) = process.stdin.take() { + let input_task = tokio::spawn(async move { + if let Some(input) = input { + helix_view::document::to_writer(&mut stdin, encoding::UTF_8, &input).await?; + } + Ok::<_, anyhow::Error>(()) + }); + let (output, _) = tokio::join! { + process.wait_with_output(), + input_task, + }; + output? + } else { + // Process has no stdin, so we just take the output + process.wait_with_output().await? + }; if !output.status.success() { if !output.stderr.is_empty() { @@ -4731,7 +4744,7 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) { for range in selection.ranges() { let fragment = range.slice(text); - let (output, success) = match shell_impl(shell, cmd, pipe.then(|| fragment)) { + let (output, success) = match shell_impl(shell, cmd, pipe.then(|| fragment.into())) { Ok(result) => result, Err(err) => { cx.editor.set_error(err.to_string()); From b5e7501935472f4e68bf42ac9759d54688ccb5e6 Mon Sep 17 00:00:00 2001 From: Jaden Date: Sat, 29 Oct 2022 08:33:23 -0700 Subject: [PATCH 24/57] feat(lang): add kdl grammar (#4481) --- book/src/generated/lang-support.md | 1 + languages.toml | 12 ++++++++++++ runtime/queries/kdl/highlights.scm | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 runtime/queries/kdl/highlights.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index c166af29..ee54114a 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -60,6 +60,7 @@ | jsonnet | ✓ | | | `jsonnet-language-server` | | jsx | ✓ | ✓ | ✓ | `typescript-language-server` | | julia | ✓ | | | `julia` | +| kdl | ✓ | | | | | kotlin | ✓ | | | `kotlin-language-server` | | latex | ✓ | ✓ | | `texlab` | | lean | ✓ | | | `lean` | diff --git a/languages.toml b/languages.toml index c5c45afc..31a454b0 100644 --- a/languages.toml +++ b/languages.toml @@ -1885,3 +1885,15 @@ grammar = "vhs" [[grammar]] name = "vhs" source = { git = "https://github.com/charmbracelet/tree-sitter-vhs", rev = "c6d81f34c011c29ee86dd73b45a8ecc9f2e2bdaf" } + +[[language]] +name = "kdl" +scope = "source.kdl" +file-types = ["kdl"] +roots = [] +comment-token = "//" +injection-regex = "kdl" + +[[grammar]] +name = "kdl" +source = { git = "https://github.com/Unoqwy/tree-sitter-kdl", rev = "e1cd292c6d15df6610484e1d4b5c987ecad52373" } diff --git a/runtime/queries/kdl/highlights.scm b/runtime/queries/kdl/highlights.scm new file mode 100644 index 00000000..d83bde19 --- /dev/null +++ b/runtime/queries/kdl/highlights.scm @@ -0,0 +1,22 @@ +(comment) @comment +(single_line_comment) @comment + +(node + name: (identifier) @function) +(prop (identifier) @attribute) +(type) @type + +(bare_identifier) @variable.other.member + +(keyword) @keyword + +(string) @string +(number) @constant.numeric +(boolean) @constant.builtin.boolean + +"." @punctuation.delimiter + +"=" @operator + +"{" @punctuation.bracket +"}" @punctuation.bracket From e3eaad14790fb72995ce233a7cd6cd8c249997c0 Mon Sep 17 00:00:00 2001 From: Kristoffer Flottorp <2630397+krfl@users.noreply.github.com> Date: Sat, 29 Oct 2022 17:35:35 +0200 Subject: [PATCH 25/57] Fleetish: Adjustments to resemble official theme and reworked diagnostics to reduce subconjunctival hemorrhage (#4487) --- runtime/themes/fleetish.toml | 53 +++++++++++++++++------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/runtime/themes/fleetish.toml b/runtime/themes/fleetish.toml index a5b09fe4..74340cae 100644 --- a/runtime/themes/fleetish.toml +++ b/runtime/themes/fleetish.toml @@ -1,11 +1,11 @@ # Author: Kristoffer Flottorp -# Based on a few screenshots of Jetbrains Fleet +# A take on the JetBrains Fleet theme sprinkled with some creative freedom -"type" = { fg = "orange" } # .builtin -"constructor" = { fg = "orange" } -"constant" = { fg = "green" } +"type" = { fg = "yellow" } # .builtin +"constructor" = { fg = "yellow" } +"constant" = { fg = "cyan" } # "constant.builtin" = {} # .boolean -"constant.builtin.boolean" = { fg = "green" } # .boolean +"constant.builtin.boolean" = { fg = "cyan" } # .boolean # "constant.character" = {} #.escape "constant.numeric" = { fg = "yellow" } # .integer / .float "string" = { fg = "pink" } # .regexp @@ -16,31 +16,31 @@ "variable" = { fg = "light" } # .builtin / .parameter # "variable.other" = {} # .member "variable.other.member" = { fg = "purple" } -"label" = { fg = "orange" } +"label" = { fg = "yellow" } # "punctuation" = {} # .delimiter / .bracket -"keyword" = { fg = "green" } # .operator / .directive / .function +"keyword" = { fg = "cyan" } # .operator / .directive / .function # "keyword.control" = { fg = "orange" } # .conditional / .repeat / .import / .return / .exception "operator" = { fg = "light" } "function" = { fg = "blue" } # .builtin / .method / .macro / .special -"function.macro" = { fg = "yellow" } -"function.special" = { fg = "yellow" } -"tag" = { fg = "yellow" } -"special" = { fg = "yellow" } +"function.macro" = { fg = "green" } +"function.special" = { fg = "green" } +"tag" = { fg = "green"} +"special" = { fg = "green" } "namespace" = { fg = "light" } "markup" = { fg = "purple" } # .bold / .italic / .quote "markup.heading" = { fg = "light" } # .marker / .1 / .2 / .3 / .4 / .5 / .6 -"markup.heading.1" = { fg = "orange" } -"markup.heading.2" = { fg = "yellow" } +"markup.heading.1" = { fg = "yellow" } +"markup.heading.2" = { fg = "green" } "markup.heading.3" = { fg = "pink" } "markup.heading.4" = { fg = "purple" } -"markup.heading.5" = { fg = "green" } +"markup.heading.5" = { fg = "cyan" } "markup.heading.6" = { fg = "blue" } -"markup.list" = { fg = "green" } # .unnumbered / .numbered -"markup.link" = { fg = "yellow" } # .url / .label / .text +"markup.list" = { fg = "cyan" } # .unnumbered / .numbered +"markup.link" = { fg = "green" } # .url / .label / .text "markup.raw" = { fg = "pink" } # .inline / .block # "diff" = {} # .plus / .minus -"diff.plus" = { fg = "green" } -"diff.minus" = { fg = "orange" } +"diff.plus" = { fg = "cyan" } +"diff.minus" = { fg = "yellow" } "diff.delta" = { fg = "purple" } # .moved # used in theming @@ -74,11 +74,7 @@ "info" = { fg = "yellow_accent" } "warning" = { fg = "orange_accent" } "error" = { fg = "diff_red_accent" } -"diagnostic" = { fg = "orange", bg = "darkest" } # .hint / .info / .warning / .error -"diagnostic.hint" = { fg = "lightest", bg = "blue_accent" } -"diagnostic.info" = { fg = "lightest", bg = "purple_accent" } -"diagnostic.warning" = { fg = "lightest", bg = "yellow_accent" } -"diagnostic.error" = { fg = "lightest", bg = "orange_accent" } +"diagnostic". underline = { style = "curl" } [palette] darkest = "#0F0F0F" @@ -91,12 +87,13 @@ lightest = "#FFFFFF" dark_gray = "#5B5B5B" light_gray = "#757575" -purple = "#A096F9" -blue = "#52A7F6" -pink = "#E878DE" -green = "#78D0BD" +purple = "#AC9CF9" +blue = "#52A7F6" #"#94C1FA" +pink = "#D898D8" +green = "#AFCB85" +cyan = "#78D0BD" orange = "#ECA775" -yellow = "#F9CA6A" +yellow = "#E5C995" purple_accent = "#6363EE" blue_accent = "#2197F3" From 2935e9da197442620578e07d87cd0607ae4145f1 Mon Sep 17 00:00:00 2001 From: Poliorcetics Date: Sat, 29 Oct 2022 17:36:26 +0200 Subject: [PATCH 26/57] feat: Categorize Rust's keywords using more specific scopes (#4510) --- runtime/queries/rust/highlights.scm | 36 +++++++++++++++++++---------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/runtime/queries/rust/highlights.scm b/runtime/queries/rust/highlights.scm index 81f05f7a..0afb8388 100644 --- a/runtime/queries/rust/highlights.scm +++ b/runtime/queries/rust/highlights.scm @@ -111,23 +111,31 @@ ; ------- (for_expression - "for" @keyword.control) + "for" @keyword.control.repeat) ((identifier) @keyword.control (#match? @keyword.control "^yield$")) + +"in" @keyword.control + +[ + "match" + "if" + "else" +] @keyword.control.conditional + [ "while" "loop" - "in" +] @keyword.control.repeat + +[ "break" "continue" - "match" - "if" - "else" "return" "await" -] @keyword.control +] @keyword.control.return "use" @keyword.control.import (mod_item "mod" @keyword.control.import !body) @@ -143,24 +151,28 @@ "mod" "extern" - "struct" - "enum" "impl" "where" "trait" "for" - "type" - "union" "unsafe" "default" "macro_rules!" - "let" - "async" ] @keyword +[ + "struct" + "enum" + "union" + + "type" +] @keyword.storage.type + +"let" @keyword.storage + "fn" @keyword.function (mutable_specifier) @keyword.storage.modifier.mut From f054a3f3ed445cdfa8c0dc63698659ef30af57b7 Mon Sep 17 00:00:00 2001 From: Matthew Toohey Date: Sat, 29 Oct 2022 16:41:28 -0400 Subject: [PATCH 27/57] feat(lang): add xml (#4518) --- book/src/generated/lang-support.md | 1 + languages.toml | 20 ++++++++++++++ runtime/queries/xml/highlights.scm | 42 ++++++++++++++++++++++++++++++ runtime/queries/xml/indents.scm | 1 + runtime/queries/xml/injections.scm | 2 ++ 5 files changed, 66 insertions(+) create mode 100644 runtime/queries/xml/highlights.scm create mode 100644 runtime/queries/xml/indents.scm create mode 100644 runtime/queries/xml/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index ee54114a..545ec635 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -127,5 +127,6 @@ | wat | ✓ | | | | | wgsl | ✓ | | | `wgsl_analyzer` | | xit | ✓ | | | | +| xml | ✓ | | ✓ | | | yaml | ✓ | | ✓ | `yaml-language-server` | | zig | ✓ | ✓ | ✓ | `zls` | diff --git a/languages.toml b/languages.toml index 31a454b0..00e6459d 100644 --- a/languages.toml +++ b/languages.toml @@ -1897,3 +1897,23 @@ injection-regex = "kdl" [[grammar]] name = "kdl" source = { git = "https://github.com/Unoqwy/tree-sitter-kdl", rev = "e1cd292c6d15df6610484e1d4b5c987ecad52373" } + +[[language]] +name = "xml" +scope = "source.xml" +injection-regex = "xml" +file-types = ["xml"] +indent = { tab-width = 2, unit = " " } +roots = [] + +[language.auto-pairs] +'(' = ')' +'{' = '}' +'[' = ']' +'"' = '"' +"'" = "'" +"<" = ">" + +[[grammar]] +name = "xml" +source = { git = "https://github.com/RenjiSann/tree-sitter-xml", rev = "422528a43630db6dcc1e222d1c5ee3babd559473" } diff --git a/runtime/queries/xml/highlights.scm b/runtime/queries/xml/highlights.scm new file mode 100644 index 00000000..d5940c8a --- /dev/null +++ b/runtime/queries/xml/highlights.scm @@ -0,0 +1,42 @@ +(comment) @comment + +[ + "DOCTYPE" + "ELEMENT" + "ATTLIST" +] @keyword + +[ + "#REQUIRED" + "#IMPLIED" + "#FIXED" + "#PCDATA" +] @keyword.directive + +[ + "EMPTY" + "ANY" + "SYSTEM" + "PUBLIC" +] @constant + +(doctype) @variable +(element_name) @variable + +"xml" @tag +(tag_name) @tag + +[ + "encoding" + "version" + "standalone" +] @attribute +(attribute_name) @attribute + +(system_literal) @string +(pubid_literal) @string +(attribute_value) @string + +[ + "<" ">" "" "" " Date: Sat, 29 Oct 2022 17:23:18 -0400 Subject: [PATCH 28/57] fix: make `scroll` aware of tabs and wide characters (#4519) --- helix-term/src/commands.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 172a7b2e..adb4802d 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1360,7 +1360,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) { let range = doc.selection(view.id).primary(); let text = doc.text().slice(..); - let cursor = coords_at_pos(text, range.cursor(text)); + let cursor = visual_coords_at_pos(text, range.cursor(text), doc.tab_width()); let doc_last_line = doc.text().len_lines().saturating_sub(1); let last_line = view.last_line(doc); @@ -1392,7 +1392,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) { // If cursor needs moving, replace primary selection if line != cursor.row { - let head = pos_at_coords(text, Position::new(line, cursor.col), true); // this func will properly truncate to line end + let head = pos_at_visual_coords(text, Position::new(line, cursor.col), doc.tab_width()); // this func will properly truncate to line end let anchor = if cx.editor.mode == Mode::Select { range.anchor From 908529ccac153c12fd3b8e051a8f8ef68120d94d Mon Sep 17 00:00:00 2001 From: Triton171 Date: Sun, 30 Oct 2022 17:45:58 +0100 Subject: [PATCH 29/57] Update LaTex grammar (#4528) Fix comment injection & add highlighting for math delimiters. --- languages.toml | 2 +- runtime/queries/latex/highlights.scm | 6 ++++++ runtime/queries/latex/injections.scm | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/languages.toml b/languages.toml index 00e6459d..73915fc2 100644 --- a/languages.toml +++ b/languages.toml @@ -570,7 +570,7 @@ indent = { tab-width = 4, unit = "\t" } [[grammar]] name = "latex" -source = { git = "https://github.com/latex-lsp/tree-sitter-latex", rev = "b3b2cf27f33e71438ebe46934900b1153901c6f2" } +source = { git = "https://github.com/latex-lsp/tree-sitter-latex", rev = "8c75e93cd08ccb7ce1ccab22c1fbd6360e3bcea6" } [[language]] name = "lean" diff --git a/runtime/queries/latex/highlights.scm b/runtime/queries/latex/highlights.scm index e39226a2..3174d80b 100644 --- a/runtime/queries/latex/highlights.scm +++ b/runtime/queries/latex/highlights.scm @@ -29,6 +29,12 @@ (#eq? @punctuation.delimiter "&")) ["[" "]" "{" "}"] @punctuation.bracket ; "(" ")" has no syntactical meaning in LaTeX +(math_delimiter + left_command: _ @punctuation.delimiter + left_delimiter: _ @punctuation.delimiter + right_command: _ @punctuation.delimiter + right_delimiter: _ @punctuation.delimiter +) ;; General environments (begin diff --git a/runtime/queries/latex/injections.scm b/runtime/queries/latex/injections.scm index 321c90ad..d3fdb0ca 100644 --- a/runtime/queries/latex/injections.scm +++ b/runtime/queries/latex/injections.scm @@ -1,2 +1,2 @@ -((comment) @injection.content +((line_comment) @injection.content (#set! injection.language "comment")) From f6710879d1a1e587d17800682ba0e1045f35e7a9 Mon Sep 17 00:00:00 2001 From: seshotake <116971836+seshotake@users.noreply.github.com> Date: Sun, 30 Oct 2022 16:54:37 +0000 Subject: [PATCH 30/57] Update SQL grammar (#4529) --- languages.toml | 2 +- runtime/queries/sql/highlights.scm | 52 ++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/languages.toml b/languages.toml index 73915fc2..9c0293f0 100644 --- a/languages.toml +++ b/languages.toml @@ -1371,7 +1371,7 @@ injection-regex = "sql" [[grammar]] name = "sql" -source = { git = "https://github.com/DerekStride/tree-sitter-sql", rev = "0caa7fa2ee00e0b770493a79d4efacc1fc376cc5" } +source = { git = "https://github.com/DerekStride/tree-sitter-sql", rev = "2743c7b5e710e6854d4e8c14c302548b436e2a1f" } [[language]] name = "gdscript" diff --git a/runtime/queries/sql/highlights.scm b/runtime/queries/sql/highlights.scm index 5025352e..ece8be33 100644 --- a/runtime/queries/sql/highlights.scm +++ b/runtime/queries/sql/highlights.scm @@ -1,3 +1,34 @@ +(keyword_gist) @function.builtin +(keyword_btree) @function.builtin +(keyword_btree) @function.builtin +(keyword_hash) @function.builtin +(keyword_spgist) @function.builtin +(keyword_gin) @function.builtin +(keyword_brin) @function.builtin +(keyword_float) @function.builtin + +(invocation + name: (identifier) @function.builtin + parameter: [(field)]? @variable.other.member) + +(count + name: (identifier) @function.builtin + parameter: [(field)]? @variable.other.member) + +(table_reference + name: (identifier) @namespace) + +(relation + table_alias: (identifier) @variable.parameter) + +(field + name: (identifier) @variable.other.member) + +(field + table_alias: (identifier) @variable.parameter + name: (identifier) @variable.other.member) + + (comment) @comment [ @@ -5,6 +36,12 @@ ")" ] @punctuation.bracket +[ + ";" + "," + "." +] @punctuation.delimiter + [ "*" "+" @@ -29,11 +66,8 @@ (literal) @string -(set_schema schema: (identifier) @namespace) -(table_reference schema: (identifier) @namespace) -(table_expression schema: (identifier) @namespace) -(all_fields schema: (identifier) @namespace) -(field schema: (identifier) @namespace) +((literal) @constant.numeric + (#match? @constant.numeric "^(-?\d*\.?\d*)$")) [ (keyword_select) @@ -54,8 +88,10 @@ (keyword_lateral) (keyword_on) (keyword_not) - (keyword_order_by) - (keyword_group_by) + (keyword_order) + (keyword_group) + (keyword_partition) + (keyword_by) (keyword_having) (keyword_desc) (keyword_asc) @@ -89,6 +125,8 @@ (keyword_auto_increment) (keyword_default) (keyword_cascade) + (keyword_between) + (keyword_window) (keyword_with) (keyword_no) (keyword_data) From f41f28b6627bd2ae0152f468cde80df167889a2d Mon Sep 17 00:00:00 2001 From: Konstantin Podsvirov Date: Sun, 30 Oct 2022 19:55:31 +0300 Subject: [PATCH 31/57] Update windows install instructions (#4530) --- book/src/install.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/book/src/install.md b/book/src/install.md index 6e2a1f3d..a041d651 100644 --- a/book/src/install.md +++ b/book/src/install.md @@ -52,7 +52,8 @@ sudo xbps-install helix ## Windows -Helix can be installed using [Scoop](https://scoop.sh/) or [Chocolatey](https://chocolatey.org/). +Helix can be installed using [Scoop](https://scoop.sh/), [Chocolatey](https://chocolatey.org/) +or [MSYS2](https://msys2.org/). **Scoop:** @@ -66,6 +67,23 @@ scoop install helix choco install helix ``` +**MSYS2:** + +``` +pacman -S mingw-w64-i686-helix +``` + +or + +``` +pacman -S mingw-w64-x86_64-helix +``` + +or + +``` +pacman -S mingw-w64-ucrt-x86_64-helix +``` ## Build from source From df3c6412acc2c0948450653a67a4993092abf5fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 18:21:51 -0500 Subject: [PATCH 32/57] build(deps): bump cachix/cachix-action from 11 to 12 (#4547) Bumps [cachix/cachix-action](https://github.com/cachix/cachix-action) from 11 to 12. - [Release notes](https://github.com/cachix/cachix-action/releases) - [Commits](https://github.com/cachix/cachix-action/compare/v11...v12) --- updated-dependencies: - dependency-name: cachix/cachix-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/cachix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml index bc72bb78..20035678 100644 --- a/.github/workflows/cachix.yml +++ b/.github/workflows/cachix.yml @@ -17,7 +17,7 @@ jobs: uses: cachix/install-nix-action@v18 - name: Authenticate with Cachix - uses: cachix/cachix-action@v11 + uses: cachix/cachix-action@v12 with: name: helix authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} From 9df43584924a72be88f537ac432e5976430fa3f1 Mon Sep 17 00:00:00 2001 From: hh9527 Date: Tue, 1 Nov 2022 07:48:01 +0800 Subject: [PATCH 33/57] Support WIT grammar (#4525) --- book/src/generated/lang-support.md | 1 + languages.toml | 22 ++++++++++ runtime/queries/wit/highlights.scm | 67 ++++++++++++++++++++++++++++++ runtime/queries/wit/indents.scm | 13 ++++++ 4 files changed, 103 insertions(+) create mode 100644 runtime/queries/wit/highlights.scm create mode 100644 runtime/queries/wit/indents.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 545ec635..38d121b5 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -126,6 +126,7 @@ | wast | ✓ | | | | | wat | ✓ | | | | | wgsl | ✓ | | | `wgsl_analyzer` | +| wit | ✓ | | ✓ | | | xit | ✓ | | | | | xml | ✓ | | ✓ | | | yaml | ✓ | | ✓ | `yaml-language-server` | diff --git a/languages.toml b/languages.toml index 9c0293f0..ee31f372 100644 --- a/languages.toml +++ b/languages.toml @@ -1917,3 +1917,25 @@ roots = [] [[grammar]] name = "xml" source = { git = "https://github.com/RenjiSann/tree-sitter-xml", rev = "422528a43630db6dcc1e222d1c5ee3babd559473" } + +[[language]] +name = "wit" +scope = "source.wit" +injection-regex = "wit" +file-types = ["wit"] +roots = [] +comment-token = "//" +indent = { tab-width = 2, unit = " " } + +[language.auto-pairs] +'(' = ')' +'{' = '}' +'[' = ']' +'"' = '"' +"'" = "'" +"<" = ">" + +[[grammar]] +name = "wit" +source = { git = "https://github.com/hh9527/tree-sitter-wit", rev = "c917790ab9aec50c5fd664cbfad8dd45110cfff3" } + diff --git a/runtime/queries/wit/highlights.scm b/runtime/queries/wit/highlights.scm new file mode 100644 index 00000000..45754a5a --- /dev/null +++ b/runtime/queries/wit/highlights.scm @@ -0,0 +1,67 @@ +(line_comment) @comment.line +(block_comment) @comment.block +(ty (ident) @type) + +(item_type name: (ident) @type) +(item_record name: (ident) @type) +(item_variant name: (ident) @type) +(item_flags name: (ident) @type) +(item_enum name: (ident) @type) +(item_union name: (ident) @type) +(item_resource name: (ident) @type) + +(item_use from: (ident) @namespace) +(use_item name: (ident) @type) +(item_func name: (ident) @function) +(method name: (ident) @function.method) +(fields (named_ty name: (ident) @variable.other.member)) +(input (args (named_ty name: (ident) @variable.parameter))) +(output (args (named_ty name: (ident) @variable.other.member))) +(flags (ident) @constant) +(enum_items (ident) @constant) +(variant_item tag: (ident) @type.enum.variant) + +[ + (unit) + + "u8" "u16" "u32" "u64" + "s8" "s16" "s32" "s64" + "float32" "float64" + "char" "bool" "string" +] @type.builtin + +[ + "list" + "option" + "result" + "tuple" + "future" + "stream" +] @function.macro + +[ "," ":" ] @punctuation.delimiter +[ "(" ")" "{" "}" "<" ">" ] @punctuation.bracket +[ "=" "->" ] @operator + +[ + "record" + "flags" + "variant" + "enum" + "union" + "type" + "resource" +] @keyword.storage.type + +"func" @keyword + +[ + "static" +] @keyword.storage.modifier + +[ + (star) + "use" + "as" + "from" +] @keyword.control.import diff --git a/runtime/queries/wit/indents.scm b/runtime/queries/wit/indents.scm new file mode 100644 index 00000000..db6c148b --- /dev/null +++ b/runtime/queries/wit/indents.scm @@ -0,0 +1,13 @@ +[ + (use_items) + (fields) + (variant_items) + (variant_payload) + (flags) + (enum_items) + (union_items) + (args) + (resource_items) +] @indent + +[ "}" ")" ] @outdent From ed7ea8c9ba639daebdbc81630bd789aeb344e2d4 Mon Sep 17 00:00:00 2001 From: seshotake <116971836+seshotake@users.noreply.github.com> Date: Tue, 1 Nov 2022 02:23:09 +0200 Subject: [PATCH 34/57] add highlights for env and ini file formats (#4536) --- book/src/generated/lang-support.md | 2 ++ languages.toml | 27 ++++++++++++++++++++++++++- runtime/queries/env/highlights.scm | 19 +++++++++++++++++++ runtime/queries/ini/highlights.scm | 6 ++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 runtime/queries/env/highlights.scm create mode 100644 runtime/queries/ini/highlights.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 38d121b5..411e67b8 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -27,6 +27,7 @@ | elixir | ✓ | ✓ | | `elixir-ls` | | elm | ✓ | | | `elm-language-server` | | elvish | ✓ | | | `elvish` | +| env | ✓ | | | | | erb | ✓ | | | | | erlang | ✓ | ✓ | | `erlang_ls` | | esdl | ✓ | | | | @@ -53,6 +54,7 @@ | html | ✓ | | | `vscode-html-language-server` | | idris | | | | `idris2-lsp` | | iex | ✓ | | | | +| ini | ✓ | | | | | java | ✓ | | | `jdtls` | | javascript | ✓ | ✓ | ✓ | `typescript-language-server` | | jsdoc | ✓ | | | | diff --git a/languages.toml b/languages.toml index ee31f372..95c37945 100644 --- a/languages.toml +++ b/languages.toml @@ -1938,4 +1938,29 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "wit" source = { git = "https://github.com/hh9527/tree-sitter-wit", rev = "c917790ab9aec50c5fd664cbfad8dd45110cfff3" } - + +[[language]] +name = "env" +scope = "source.env" +file-types = [".env", ".env.local", ".env.development", ".env.production"] +injection-regex = "env" +comment-token = "#" +indent = { tab-width = 4, unit = "\t" } +roots = [] + +[[grammar]] +name = "env" +source = { git = "https://github.com/seshotake/tree-sitter-env", rev = "e6c6bb1e7b51d481cba463fe949f083cf22d81f7" } + +[[language]] +name = "ini" +scope = "source.ini" +file-types = ["ini"] +injection-regex = "ini" +comment-token = "#" +indent = { tab-width = 4, unit = "\t" } +roots = [] + +[[grammar]] +name = "ini" +source = { git = "https://github.com/justinmk/tree-sitter-ini", rev = "4d247fb876b4ae6b347687de4a179511bf67fcbc" } diff --git a/runtime/queries/env/highlights.scm b/runtime/queries/env/highlights.scm new file mode 100644 index 00000000..6a27e8e5 --- /dev/null +++ b/runtime/queries/env/highlights.scm @@ -0,0 +1,19 @@ +(env_variable (quoted_string)) @string +(env_variable (unquoted_string)) @string + +(env_key) @keyword + +((variable) @keyword + (#match? @keyword "^([A-Z][A-Z_0-9]*)$")) + +[ + "{" + "}" +] @punctuation.bracket + +[ + "$" + "=" +] @operator + +(comment) @comment \ No newline at end of file diff --git a/runtime/queries/ini/highlights.scm b/runtime/queries/ini/highlights.scm new file mode 100644 index 00000000..6277a067 --- /dev/null +++ b/runtime/queries/ini/highlights.scm @@ -0,0 +1,6 @@ +(section_name) @namespace + +(setting_name) @keyword +(setting_value) @string + +(comment) @comment From 9b247b1104ab34d55ca383daafab2a26dae31253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Ho=C3=9F?= Date: Tue, 1 Nov 2022 01:27:53 +0100 Subject: [PATCH 35/57] Update SSH client config grammar & highlight queries (#4538) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sebastian Hoß --- languages.toml | 2 +- .../queries/sshclientconfig/highlights.scm | 170 +++++++++--------- 2 files changed, 86 insertions(+), 86 deletions(-) diff --git a/languages.toml b/languages.toml index 95c37945..adce81c5 100644 --- a/languages.toml +++ b/languages.toml @@ -1518,7 +1518,7 @@ roots = [] [[grammar]] name = "sshclientconfig" -source = { git = "https://github.com/metio/tree-sitter-ssh-client-config", rev = "769d7a01a2e5493b4bb5a51096c6bf4be130b024" } +source = { git = "https://github.com/metio/tree-sitter-ssh-client-config", rev = "e45c6d5c71657344d4ecaf87dafae7736f776c57" } [[language]] name = "scheme" diff --git a/runtime/queries/sshclientconfig/highlights.scm b/runtime/queries/sshclientconfig/highlights.scm index 83a212a2..b54da587 100644 --- a/runtime/queries/sshclientconfig/highlights.scm +++ b/runtime/queries/sshclientconfig/highlights.scm @@ -1,17 +1,17 @@ -(host) @keyword -(host_value) @identifier +(host) @namespace +(host_value) @string -(match) @keyword -(match_value) @identifier +(match) @namespace +(match_value) @string (add_keys_to_agent) @keyword -(add_keys_to_agent_value) @boolean +(add_keys_to_agent_value) @constant.builtin.boolean (address_family) @keyword -(address_family_value) @type +(address_family_value) @constant.builtin (batch_mode) @keyword -(batch_mode_value) @boolean +(batch_mode_value) @constant.builtin.boolean (bind_address) @keyword (bind_address_value) @string @@ -20,165 +20,165 @@ (bind_interface_value) @string (canonical_domains) @keyword -(canonical_domains_value) @identifier +(canonical_domains_value) @string (canonicalize_fallback_local) @keyword -(canonicalize_fallback_local_value) @boolean +(canonicalize_fallback_local_value) @constant.builtin.boolean (canonicalize_hostname) @keyword -(canonicalize_hostname_value) @boolean +(canonicalize_hostname_value) @constant.builtin (canonicalize_max_dots) @keyword -(canonicalize_max_dots_value) @number +(canonicalize_max_dots_value) @constant.numeric.integer (canonicalize_permitted_cnames) @keyword -(canonicalize_permitted_cnames_value) @identifier +(canonicalize_permitted_cnames_value) @string (ca_signature_algorithms) @keyword -(ca_signature_algorithms_value) @identifier +(ca_signature_algorithms_value) @string (certificate_file) @keyword -(certificate_file_value) @file +(certificate_file_value) @string.special.path (challenge_response_authentication) @keyword -(challenge_response_authentication_value) @boolean +(challenge_response_authentication_value) @constant.builtin.boolean (check_host_ip) @keyword -(check_host_ip_value) @boolean +(check_host_ip_value) @constant.builtin.boolean (cipher) @keyword -(cipher_value) @identifier +(cipher_value) @string (ciphers) @keyword -(ciphers_value) @identifier +(ciphers_value) @string (clear_all_forwardings) @keyword -(clear_all_forwardings_value) @boolean +(clear_all_forwardings_value) @constant.builtin.boolean (comment) @comment (compression) @keyword -(compression_value) @boolean +(compression_value) @constant.builtin.boolean (connect_timeout) @keyword -(connect_timeout_value) @number +(connect_timeout_value) @constant.numeric.integer (connection_attempts) @keyword -(connection_attempts_value) @number +(connection_attempts_value) @constant.numeric.integer (control_master) @keyword -(control_master_value) @type +(control_master_value) @constant.builtin (control_path) @keyword -(control_path_value) @file +(control_path_value) @string.special.path (control_persist) @keyword -(control_persist_value) @type +(control_persist_value) @constant.builtin (dynamic_forward) @keyword (dynamic_forward_value) @string (enable_ssh_keysign) @keyword -(enable_ssh_keysign_value) @boolean +(enable_ssh_keysign_value) @constant.builtin.boolean (escape_char) @keyword -(escape_char_value) @string +(escape_char_value) @constant.character.escape (exit_on_forward_failure) @keyword -(exit_on_forward_failure_value) @boolean +(exit_on_forward_failure_value) @constant.builtin.boolean (fingerprint_hash) @keyword -(fingerprint_hash_value) @identifier +(fingerprint_hash_value) @constant.builtin (fork_after_authentication) @keyword -(fork_after_authentication_value) @boolean +(fork_after_authentication_value) @constant.builtin.boolean (forward_agent) @keyword -(forward_agent_value) @boolean +(forward_agent_value) @string (forward_x11) @keyword -(forward_x11_value) @boolean +(forward_x11_value) @constant.builtin.boolean (forward_x11_timeout) @keyword -(forward_x11_timeout_value) @time +(forward_x11_timeout_value) @constant.numeric.integer (forward_x11_trusted) @keyword -(forward_x11_trusted_value) @boolean +(forward_x11_trusted_value) @constant.builtin.boolean (gateway_ports) @keyword -(gateway_ports_value) @boolean +(gateway_ports_value) @constant.builtin.boolean (global_known_hosts_file) @keyword -(global_known_hosts_file_value) @file +(global_known_hosts_file_value) @string.special.path (gssapi_authentication) @keyword -(gssapi_authentication_value) @boolean +(gssapi_authentication_value) @constant.builtin.boolean (gssapi_client_identity) @keyword (gssapi_client_identity_value) @string (gssapi_delegate_credentials) @keyword -(gssapi_delegate_credentials_value) @boolean +(gssapi_delegate_credentials_value) @constant.builtin.boolean (gssapi_kex_algorithms) @keyword -(gssapi_kex_algorithms_value) @identifier +(gssapi_kex_algorithms_value) @string (gssapi_key_exchange) @keyword -(gssapi_key_exchange_value) @boolean +(gssapi_key_exchange_value) @constant.builtin.boolean (gssapi_renewal_forces_rekey) @keyword -(gssapi_renewal_forces_rekey_value) @boolean +(gssapi_renewal_forces_rekey_value) @constant.builtin.boolean (gssapi_server_identity) @keyword (gssapi_server_identity_value) @string (gssapi_trust_dns) @keyword -(gssapi_trust_dns_value) @boolean +(gssapi_trust_dns_value) @constant.builtin.boolean (hash_known_hosts) @keyword -(hash_known_hosts_value) @boolean +(hash_known_hosts_value) @constant.builtin.boolean (host_key_algorithms) @keyword -(host_key_algorithms_value) @identifier +(host_key_algorithms_value) @string (host_key_alias) @keyword (host_key_alias_value) @string (hostbased_accepted_algorithms) @keyword -(hostbased_accepted_algorithms_value) @identifier +(hostbased_accepted_algorithms_value) @string (hostbased_authentication) @keyword -(hostbased_authentication_value) @boolean +(hostbased_authentication_value) @constant.builtin.boolean (hostname) @keyword (hostname_value) @string (identities_only) @keyword -(identities_only_value) @boolean +(identities_only_value) @constant.builtin.boolean (identity_agent) @keyword (identity_agent_value) @string (identity_file) @keyword -(identity_file_value) @file +(identity_file_value) @string.special.path (ignore_unknown) @keyword (ignore_unknown_value) @string -(include) @keyword -(include_value) @file +(include) @function.macro +(include_value) @string.special.path (ip_qos) @keyword -(ip_qos_value) @type +(ip_qos_value) @constant.builtin (kbd_interactive_authentication) @keyword -(kbd_interactive_authentication_value) @boolean +(kbd_interactive_authentication_value) @constant.builtin.boolean (kbd_interactive_devices) @keyword -(kbd_interactive_devices_value) @type +(kbd_interactive_devices_value) @string (kex_algorithms) @keyword -(kex_algorithms_value) @identifier +(kex_algorithms_value) @string (known_hosts_command) @keyword (known_hosts_command_value) @string @@ -190,25 +190,25 @@ (local_forward_value) @string (log_level) @keyword -(log_level_value) @type +(log_level_value) @constant.builtin (log_verbose) @keyword (log_verbose_value) @string (macs) @keyword -(macs_value) @identifier +(macs_value) @string (no_host_authentication_for_localhost) @keyword -(no_host_authentication_for_localhost_value) @boolean +(no_host_authentication_for_localhost_value) @constant.builtin.boolean (number_of_password_prompts) @keyword -(number_of_password_prompts_value) @number +(number_of_password_prompts_value) @constant.numeric.integer (password_authentication) @keyword -(password_authentication_value) @boolean +(password_authentication_value) @constant.builtin.boolean (permit_local_command) @keyword -(permit_local_command_value) @boolean +(permit_local_command_value) @constant.builtin.boolean (permit_remote_open) @keyword (permit_remote_open_value) @string @@ -217,13 +217,13 @@ (pkcs11_provider_value) @string (port) @keyword -(port_value) @number +(port_value) @constant.numeric.integer (preferred_authentications) @keyword -(preferred_authentications_value) @type +(preferred_authentications_value) @string (protocol) @keyword -(protocol_value) @number +(protocol_value) @constant.numeric.integer (proxy_command) @keyword (proxy_command_value) @string @@ -232,16 +232,16 @@ (proxy_jump_value) @string (proxy_use_fdpass) @keyword -(proxy_use_fdpass_value) @boolean +(proxy_use_fdpass_value) @constant.builtin.boolean (pubkey_accepted_algorithms) @keyword -(pubkey_accepted_algorithms_value) @identifier +(pubkey_accepted_algorithms_value) @string (pubkey_accepted_key_types) @keyword -(pubkey_accepted_key_types_value) @identifier +(pubkey_accepted_key_types_value) @string (pubkey_authentication) @keyword -(pubkey_authentication_value) @boolean +(pubkey_authentication_value) @constant.builtin (rekey_limit) @keyword (rekey_limit_value) @string @@ -253,10 +253,10 @@ (remote_forward_value) @string (request_tty) @keyword -(request_tty_value) @type +(request_tty_value) @constant.builtin (revoked_host_keys) @keyword -(revoked_host_keys_value) @file +(revoked_host_keys_value) @string.special.path (security_key_provider) @keyword (security_key_provider_value) @string @@ -265,60 +265,60 @@ (send_env_value) @string (server_alive_count_max) @keyword -(server_alive_count_max_value) @number +(server_alive_count_max_value) @constant.numeric.integer (server_alive_interval) @keyword -(server_alive_interval_value) @number +(server_alive_interval_value) @constant.numeric.integer (session_type) @keyword -(session_type_value) @type +(session_type_value) @constant.builtin (set_env) @keyword (set_env_value) @string (stdin_null) @keyword -(stdin_null_value) @boolean +(stdin_null_value) @constant.builtin.boolean (stream_local_bind_mask) @keyword (stream_local_bind_mask_value) @string (stream_local_bind_unlink) @keyword -(stream_local_bind_unlink_value) @boolean +(stream_local_bind_unlink_value) @constant.builtin.boolean (strict_host_key_checking) @keyword -(strict_host_key_checking_value) @type +(strict_host_key_checking_value) @constant.builtin (syslog_facility) @keyword -(syslog_facility_value) @type +(syslog_facility_value) @constant.builtin (tcp_keep_alive) @keyword -(tcp_keep_alive_value) @boolean +(tcp_keep_alive_value) @constant.builtin.boolean (keep_alive) @keyword -(keep_alive_value) @boolean +(keep_alive_value) @constant.builtin.boolean (tunnel) @keyword -(tunnel_value) @type +(tunnel_value) @constant.builtin (tunnel_device) @keyword (tunnel_device_value) @string (update_host_keys) @keyword -(update_host_keys_value) @type +(update_host_keys_value) @constant.builtin (use_keychain) @keyword -(use_keychain_value) @boolean +(use_keychain_value) @constant.builtin.boolean (user) @keyword (user_value) @string (user_known_hosts_file) @keyword -(user_known_hosts_file_value) @file +(user_known_hosts_file_value) @string.special.path (verify_host_key_dns) @keyword -(verify_host_key_dns_value) @type +(verify_host_key_dns_value) @constant.builtin (visual_host_key) @keyword -(visual_host_key_value) @boolean +(visual_host_key_value) @constant.builtin.boolean (xauth_location) @keyword -(xauth_location_value) @file +(xauth_location_value) @string.special.path From 92b13f9e71c7d8adae4a6c1fa5f0135137c3c290 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 19:29:01 -0500 Subject: [PATCH 36/57] build(deps): bump cc from 1.0.73 to 1.0.74 (#4549) Bumps [cc](https://github.com/rust-lang/cc-rs) from 1.0.73 to 1.0.74. - [Release notes](https://github.com/rust-lang/cc-rs/releases) - [Commits](https://github.com/rust-lang/cc-rs/compare/1.0.73...1.0.74) --- updated-dependencies: - dependency-name: cc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 163b3ad4..e4d4568a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,9 +92,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574" [[package]] name = "cfg-if" From 3792d9ebb7ffc3294987d3fae0c14511cbdbb615 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 19:29:32 -0500 Subject: [PATCH 37/57] build(deps): bump lsp-types from 0.93.1 to 0.93.2 (#4550) Bumps [lsp-types](https://github.com/gluon-lang/lsp-types) from 0.93.1 to 0.93.2. - [Release notes](https://github.com/gluon-lang/lsp-types/releases) - [Changelog](https://github.com/gluon-lang/lsp-types/blob/master/CHANGELOG.md) - [Commits](https://github.com/gluon-lang/lsp-types/compare/v0.93.1...v0.93.2) --- updated-dependencies: - dependency-name: lsp-types dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e4d4568a..ecbc0a14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -684,9 +684,9 @@ dependencies = [ [[package]] name = "lsp-types" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3bcfee315dde785ba887edb540b08765fd7df75a7d948844be6bf5712246734" +checksum = "9be6e9c7e2d18f651974370d7aff703f9513e0df6e464fd795660edc77e6ca51" dependencies = [ "bitflags", "serde", From 79c7203a388e1ac7aa6aebfc2e4c9a91b6efc97a Mon Sep 17 00:00:00 2001 From: Jonas Everaert <62475953+Jomy10@users.noreply.github.com> Date: Tue, 1 Nov 2022 01:30:08 +0100 Subject: [PATCH 38/57] Added missing keywords to wat (wasm) hightlights (#4542) added "if", "then", "else", "block", "loop", "end" and "mut" to the wat highlights. --- runtime/queries/wat/highlights.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/queries/wat/highlights.scm b/runtime/queries/wat/highlights.scm index 007e3bbf..93f03aac 100644 --- a/runtime/queries/wat/highlights.scm +++ b/runtime/queries/wat/highlights.scm @@ -1,4 +1,7 @@ -["module" "func" "param" "result" "type" "memory" "elem" "data" "table" "global"] @keyword +[ + "module" "func" "param" "result" "type" "memory" "elem" "data" "table" "global" + "if" "then" "else" "block" "loop" "end" "mut" +] @keyword ["import" "export"] @keyword.control.import From e5319ea8c52d6c97ce901426c2714a26f535be0b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 19:31:08 -0500 Subject: [PATCH 39/57] build(deps): bump once_cell from 1.15.0 to 1.16.0 (#4548) Bumps [once_cell](https://github.com/matklad/once_cell) from 1.15.0 to 1.16.0. - [Release notes](https://github.com/matklad/once_cell/releases) - [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md) - [Commits](https://github.com/matklad/once_cell/compare/v1.15.0...v1.16.0) --- updated-dependencies: - dependency-name: once_cell dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- helix-core/Cargo.toml | 2 +- helix-loader/Cargo.toml | 2 +- helix-term/Cargo.toml | 2 +- helix-view/Cargo.toml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ecbc0a14..93459aa0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -753,9 +753,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "parking_lot" diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml index 7585c347..45272f98 100644 --- a/helix-core/Cargo.toml +++ b/helix-core/Cargo.toml @@ -26,7 +26,7 @@ unicode-general-category = "0.6" # slab = "0.4.2" slotmap = "1.0" tree-sitter = "0.20" -once_cell = "1.15" +once_cell = "1.16" arc-swap = "1" regex = "1" bitflags = "1.3" diff --git a/helix-loader/Cargo.toml b/helix-loader/Cargo.toml index b4541de5..760205e1 100644 --- a/helix-loader/Cargo.toml +++ b/helix-loader/Cargo.toml @@ -19,7 +19,7 @@ serde = { version = "1.0", features = ["derive"] } toml = "0.5" etcetera = "0.4" tree-sitter = "0.20" -once_cell = "1.15" +once_cell = "1.16" log = "0.4" # TODO: these two should be on !wasm32 only diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index 30de5589..485cabe9 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -32,7 +32,7 @@ helix-dap = { version = "0.6", path = "../helix-dap" } helix-loader = { version = "0.6", path = "../helix-loader" } anyhow = "1" -once_cell = "1.15" +once_cell = "1.16" which = "4.2" diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml index b96a537d..a2a88001 100644 --- a/helix-view/Cargo.toml +++ b/helix-view/Cargo.toml @@ -23,7 +23,7 @@ helix-dap = { version = "0.6", path = "../helix-dap" } crossterm = { version = "0.25", optional = true } # Conversion traits -once_cell = "1.15" +once_cell = "1.16" url = "2" arc-swap = { version = "1.5.1" } From 3881fef39d01c94a09b8f5da67decc2c3ccb3660 Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Tue, 1 Nov 2022 03:52:03 +0300 Subject: [PATCH 40/57] build(nix): update nci, fixup flake (#4537) --- flake.lock | 71 ++++++++++++----- flake.nix | 225 ++++++++++++++++++++++++++--------------------------- 2 files changed, 165 insertions(+), 131 deletions(-) diff --git a/flake.lock b/flake.lock index f28ec884..cfa227e3 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,22 @@ { "nodes": { + "all-cabal-json": { + "flake": false, + "locked": { + "lastModified": 1665552503, + "narHash": "sha256-r14RmRSwzv5c+bWKUDaze6pXM7nOsiz1H8nvFHJvufc=", + "owner": "nix-community", + "repo": "all-cabal-json", + "rev": "d7c0434eebffb305071404edcf9d5cd99703878e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "hackage", + "repo": "all-cabal-json", + "type": "github" + } + }, "crane": { "flake": false, "locked": { @@ -19,11 +36,11 @@ "devshell": { "flake": false, "locked": { - "lastModified": 1660811669, - "narHash": "sha256-V6lmsaLNFz41myppL0yxglta92ijkSvpZ+XVygAh+bU=", + "lastModified": 1666548262, + "narHash": "sha256-4DyN4KXqQQsCw0vCXkMThw4b5Q4/q87ZZgRb4st8COc=", "owner": "numtide", "repo": "devshell", - "rev": "c2feacb46ee69949124c835419861143c4016fb5", + "rev": "c8ce8ed81726079c398f5f29c4b68a7d6a3c2fa2", "type": "github" }, "original": { @@ -38,6 +55,7 @@ "nci", "nixpkgs" ], + "all-cabal-json": "all-cabal-json", "crane": "crane", "devshell": [ "nci", @@ -47,6 +65,7 @@ "nci", "nixpkgs" ], + "ghc-utils": "ghc-utils", "gomod2nix": [ "nci", "nixpkgs" @@ -69,11 +88,11 @@ ] }, "locked": { - "lastModified": 1662176993, - "narHash": "sha256-Sy7DsGAveDUFBb6YDsUSYZd/AcXfP/MOMIwMt/NgY84=", + "lastModified": 1666993587, + "narHash": "sha256-4cLrs+CwWnceYXnCpL5gO3bybS9CjLxUoTEKjB2QFtg=", "owner": "nix-community", "repo": "dream2nix", - "rev": "809bc5940214744eb29778a9a0b03f161979c1b2", + "rev": "2b7456e3d2f0053bc2474fb0c461dd468545277f", "type": "github" }, "original": { @@ -84,11 +103,11 @@ }, "flake-utils": { "locked": { - "lastModified": 1656928814, - "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "owner": "numtide", "repo": "flake-utils", - "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", "type": "github" }, "original": { @@ -97,6 +116,22 @@ "type": "github" } }, + "ghc-utils": { + "flake": false, + "locked": { + "lastModified": 1662774800, + "narHash": "sha256-1Rd2eohGUw/s1tfvkepeYpg8kCEXiIot0RijapUjAkE=", + "ref": "refs/heads/master", + "rev": "bb3a2d3dc52ff0253fb9c2812bd7aa2da03e0fea", + "revCount": 1072, + "type": "git", + "url": "https://gitlab.haskell.org/bgamari/ghc-utils" + }, + "original": { + "type": "git", + "url": "https://gitlab.haskell.org/bgamari/ghc-utils" + } + }, "nci": { "inputs": { "devshell": "devshell", @@ -109,11 +144,11 @@ ] }, "locked": { - "lastModified": 1662177071, - "narHash": "sha256-x6XF//RdZlw81tFAYM1TkjY+iQIpyMCWZ46r9o4wVQY=", + "lastModified": 1667232647, + "narHash": "sha256-cFo7G8BqYShgL9m7yD6p+SHAZ+aIt2guuF69LV235n8=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "65270dea87bb82fc02102a15221677eea237680e", + "rev": "16082f7b4e42ce140a562fa630bcf8e96eadeb59", "type": "github" }, "original": { @@ -124,11 +159,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1662019588, - "narHash": "sha256-oPEjHKGGVbBXqwwL+UjsveJzghWiWV0n9ogo1X6l4cw=", + "lastModified": 1667142599, + "narHash": "sha256-OLJxsg9VqfKjFkerOxWtNIkibsCvxsv5A8wNWO1MeWk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2da64a81275b68fdad38af669afeda43d401e94b", + "rev": "412b9917cea092f3d39f9cd5dead4effd5bc4053", "type": "github" }, "original": { @@ -153,11 +188,11 @@ ] }, "locked": { - "lastModified": 1662087605, - "narHash": "sha256-Gpf2gp2JenKGf+TylX/YJpttY2bzsnvAMLdLaxoZRyU=", + "lastModified": 1667184938, + "narHash": "sha256-/kuCiXuAxiD0c0zrfDvJ1Yba3FuVdRk/ROfb393AeX4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "60c2cfaa8b90ed8cebd18b214fac8682dcf222dd", + "rev": "8f81faec35508647ced65c44fd3e8648a5518afb", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 8cb4b663..b1d3f01e 100644 --- a/flake.nix +++ b/flake.nix @@ -21,57 +21,124 @@ ... }: let lib = nixpkgs.lib; + ncl = nci.lib.nci-lib; mkRootPath = rel: builtins.path { path = "${toString ./.}/${rel}"; name = rel; }; + filteredSource = let + pathsToIgnore = [ + ".envrc" + ".ignore" + ".github" + "runtime" + "screenshot.png" + "book" + "contrib" + "docs" + "README.md" + "CHANGELOG.md" + "shell.nix" + "default.nix" + "grammars.nix" + "flake.nix" + "flake.lock" + ]; + ignorePaths = path: type: let + # split the nix store path into its components + components = lib.splitString "/" path; + # drop off the `/nix/hash-source` section from the path + relPathComponents = lib.drop 4 components; + # reassemble the path components + relPath = lib.concatStringsSep "/" relPathComponents; + in + lib.all (p: ! (lib.hasPrefix p relPath)) pathsToIgnore; + in + builtins.path { + name = "helix-source"; + path = toString ./.; + # filter out unnecessary paths + filter = ignorePaths; + }; outputs = nci.lib.makeOutputs { root = ./.; - renameOutputs = {"helix-term" = "helix";}; - # Set default app to hx (binary is from helix-term release build) - # Set default package to helix-term release build - defaultOutputs = { - app = "hx"; - package = "helix"; + config = common: { + outputs = { + # rename helix-term to helix since it's our main package + rename = {"helix-term" = "helix";}; + # Set default app to hx (binary is from helix-term release build) + # Set default package to helix-term release build + defaults = { + app = "hx"; + package = "helix"; + }; + }; + cCompiler.package = with common.pkgs; + if stdenv.isLinux + then gcc + else clang; + shell = { + packages = with common.pkgs; + [lld_13 cargo-flamegraph rust-analyzer] + ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin) + ++ (lib.optional stdenv.isLinux lldb); + env = [ + { + name = "HELIX_RUNTIME"; + eval = "$PWD/runtime"; + } + { + name = "RUST_BACKTRACE"; + value = "1"; + } + { + name = "RUSTFLAGS"; + value = + if common.pkgs.stdenv.isLinux + then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment" + else ""; + } + ]; + }; }; - overrides = { - cCompiler = common: - with common.pkgs; - if stdenv.isLinux - then gcc - else clang; - crateOverrides = common: _: { - helix-term = prev: { - src = builtins.path { - name = "helix-source"; - path = toString ./.; - # filter out unneeded stuff that cause rebuilds - filter = path: type: - lib.all - (n: builtins.baseNameOf path != n) - [ - ".envrc" - ".ignore" - ".github" - "runtime" - "screenshot.png" - "book" - "contrib" - "docs" - "README.md" - "shell.nix" - "default.nix" - "grammars.nix" - "flake.nix" - "flake.lock" - ]; - }; + pkgConfig = common: { + helix-term = { + # Wrap helix with runtime + wrapper = _: old: let + inherit (common) pkgs; + makeOverridableHelix = old: config: let + grammars = pkgs.callPackage ./grammars.nix config; + runtimeDir = pkgs.runCommand "helix-runtime" {} '' + mkdir -p $out + ln -s ${mkRootPath "runtime"}/* $out + rm -r $out/grammars + ln -s ${grammars} $out/grammars + ''; + helix-wrapped = + common.internal.pkgsSet.utils.wrapDerivation old + { + nativeBuildInputs = [pkgs.makeWrapper]; + makeWrapperArgs = config.makeWrapperArgs or []; + } + '' + rm -rf $out/bin + mkdir -p $out/bin + ln -sf ${old}/bin/* $out/bin/ + wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}" + ''; + in + helix-wrapped + // {override = makeOverridableHelix old;}; + in + makeOverridableHelix old {}; + overrides.fix-build.overrideAttrs = prev: { + src = filteredSource; # disable fetching and building of tree-sitter grammars in the helix-term build.rs HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1"; - buildInputs = (prev.buildInputs or []) ++ [common.cCompiler.cc.lib]; + buildInputs = ncl.addBuildInputs prev [common.config.cCompiler.package.cc.lib]; # link languages and theme toml files since helix-term expects them (for tests) preConfigure = '' @@ -87,88 +154,20 @@ meta.mainProgram = "hx"; }; }; - shell = common: prev: { - packages = - prev.packages - ++ ( - with common.pkgs; - [lld_13 cargo-flamegraph rust-analyzer] - ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin) - ++ (lib.optional stdenv.isLinux lldb) - ); - env = - prev.env - ++ [ - { - name = "HELIX_RUNTIME"; - eval = "$PWD/runtime"; - } - { - name = "RUST_BACKTRACE"; - value = "1"; - } - { - name = "RUSTFLAGS"; - value = - if common.pkgs.stdenv.isLinux - then "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment" - else ""; - } - ]; - }; }; }; - makeOverridableHelix = system: old: config: let - pkgs = nixpkgs.legacyPackages.${system}; - grammars = pkgs.callPackage ./grammars.nix config; - runtimeDir = pkgs.runCommand "helix-runtime" {} '' - mkdir -p $out - ln -s ${mkRootPath "runtime"}/* $out - rm -r $out/grammars - ln -s ${grammars} $out/grammars - ''; - helix-wrapped = - pkgs.runCommand "${old.name}-wrapped" - { - inherit (old) pname version meta; - - nativeBuildInputs = [pkgs.makeWrapper]; - makeWrapperArgs = config.makeWrapperArgs or []; - } - '' - mkdir -p $out - cp -r --no-preserve=mode,ownership ${old}/* $out/ - chmod +x $out/bin/* - wrapProgram "$out/bin/hx" ''${makeWrapperArgs[@]} --set HELIX_RUNTIME "${runtimeDir}" - ''; - in - helix-wrapped - // {override = makeOverridableHelix system old;}; in outputs // { - apps = - lib.mapAttrs - ( - system: apps: rec { - default = hx; - hx = { - type = "app"; - program = lib.getExe self.${system}.packages.helix; - }; - } - ) - outputs.apps; packages = lib.mapAttrs ( - system: packages: rec { - default = helix; - helix = makeOverridableHelix system helix-unwrapped {}; - helix-debug = makeOverridableHelix system helix-unwrapped-debug {}; - helix-unwrapped = packages.helix; - helix-unwrapped-debug = packages.helix-debug; - } + system: packages: + packages + // { + helix-unwrapped = packages.helix.passthru.unwrapped; + helix-unwrapped-debug = packages.helix-debug.passthru.unwrapped; + } ) outputs.packages; }; From 8584b38cfbe6ffe3e5d539ad953c413e44e90bfa Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Tue, 1 Nov 2022 12:48:37 +0100 Subject: [PATCH 41/57] Correctly handle escaping in completion (#4316) * Correctly handle escaping in completion * Added escaping tests --- helix-core/src/shellwords.rs | 31 +++++++++++++++++++++++++++++++ helix-term/src/commands/typed.rs | 9 ++++----- helix-term/src/ui/prompt.rs | 6 +++++- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/helix-core/src/shellwords.rs b/helix-core/src/shellwords.rs index afc83496..6edf3cc7 100644 --- a/helix-core/src/shellwords.rs +++ b/helix-core/src/shellwords.rs @@ -1,5 +1,22 @@ use std::borrow::Cow; +/// Auto escape for shellwords usage. +pub fn escape(input: &str) -> Cow<'_, str> { + if !input.chars().any(|x| x.is_ascii_whitespace()) { + Cow::Borrowed(input) + } else if cfg!(unix) { + Cow::Owned(input.chars().fold(String::new(), |mut buf, c| { + if c.is_ascii_whitespace() { + buf.push('\\'); + } + buf.push(c); + buf + })) + } else { + Cow::Owned(format!("\"{}\"", input)) + } +} + /// Get the vec of escaped / quoted / doublequoted filenames from the input str pub fn shellwords(input: &str) -> Vec> { enum State { @@ -226,4 +243,18 @@ mod test { ]; assert_eq!(expected, result); } + + #[cfg(unix)] + fn test_escaping_unix() { + assert_eq!(escape("foobar"), Cow::Borrowed("foobar")); + assert_eq!(escape("foo bar"), Cow::Borrowed("foo\\ bar")); + assert_eq!(escape("foo\tbar"), Cow::Borrowed("foo\\\tbar")); + } + + #[test] + #[cfg(windows)] + fn test_escaping_windows() { + assert_eq!(escape("foobar"), Cow::Borrowed("foobar")); + assert_eq!(escape("foo bar"), Cow::Borrowed("\"foo bar\"")); + } } diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 0cf75ada..f4dfce7a 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -2183,12 +2183,10 @@ pub(super) fn command_mode(cx: &mut Context) { static FUZZY_MATCHER: Lazy = Lazy::new(fuzzy_matcher::skim::SkimMatcherV2::default); - // we use .this over split_whitespace() because we care about empty segments - let parts = input.split(' ').collect::>(); - // simple heuristic: if there's no just one part, complete command name. // if there's a space, per command completion kicks in. - if parts.len() <= 1 { + // we use .this over split_whitespace() because we care about empty segments + if input.split(' ').count() <= 1 { let mut matches: Vec<_> = typed::TYPABLE_COMMAND_LIST .iter() .filter_map(|command| { @@ -2204,12 +2202,13 @@ pub(super) fn command_mode(cx: &mut Context) { .map(|(name, _)| (0.., name.into())) .collect() } else { + let parts = shellwords::shellwords(input); let part = parts.last().unwrap(); if let Some(typed::TypableCommand { completer: Some(completer), .. - }) = typed::TYPABLE_COMMAND_MAP.get(parts[0]) + }) = typed::TYPABLE_COMMAND_MAP.get(&parts[0] as &str) { completer(editor, part) .into_iter() diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index db3bd62d..d0991d3c 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -1,5 +1,6 @@ use crate::compositor::{Component, Compositor, Context, Event, EventResult}; use crate::{alt, ctrl, key, shift, ui}; +use helix_core::shellwords; use helix_view::input::KeyEvent; use helix_view::keyboard::KeyCode; use std::{borrow::Cow, ops::RangeFrom}; @@ -335,7 +336,10 @@ impl Prompt { let (range, item) = &self.completion[index]; - self.line.replace_range(range.clone(), item); + // since we are using shellwords to parse arguments, make sure + // that whitespace in files is properly escaped. + let item = shellwords::escape(item); + self.line.replace_range(range.clone(), &item); self.move_end(); } From 8ff92c749287fb3ac4a68661d0ee99cb56cc6295 Mon Sep 17 00:00:00 2001 From: Poliorcetics Date: Tue, 1 Nov 2022 13:37:19 +0100 Subject: [PATCH 42/57] Add missed test attribute in #4316 (#4557) --- helix-core/src/shellwords.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/helix-core/src/shellwords.rs b/helix-core/src/shellwords.rs index 6edf3cc7..e8c5945b 100644 --- a/helix-core/src/shellwords.rs +++ b/helix-core/src/shellwords.rs @@ -244,6 +244,7 @@ mod test { assert_eq!(expected, result); } + #[test] #[cfg(unix)] fn test_escaping_unix() { assert_eq!(escape("foobar"), Cow::Borrowed("foobar")); From c803ef8753bc828c9c68f40878d9467ead50dc0d Mon Sep 17 00:00:00 2001 From: Yuriy Gabuev Date: Tue, 1 Nov 2022 15:48:43 +0100 Subject: [PATCH 43/57] Fix `delete_char_backward` for paired characters (#4558) When backward-deleting a character, if this character and the following character form a Pair, we want to delete both. However, there is a bug that deletes both characters also if both characters are closers of some Pair. This commit fixes that by adding an additional check that the deleted character should be an opener in a Pair. Closes https://github.com/helix-editor/helix/issues/4544. --- helix-term/src/commands.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index adb4802d..35439431 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3198,6 +3198,7 @@ pub mod insert { (Some(_x), Some(_y), Some(ap)) if range.is_single_grapheme(text) && ap.get(_x).is_some() + && ap.get(_x).unwrap().open == _x && ap.get(_x).unwrap().close == _y => // delete both autopaired characters { From 185236c3a40ef89f9978358d02b83f47ca4da0eb Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 1 Nov 2022 17:44:56 -0700 Subject: [PATCH 44/57] Fix D unittest injection query. (#4562) --- runtime/queries/d/textobjects.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/queries/d/textobjects.scm b/runtime/queries/d/textobjects.scm index 9ca07160..6e9e623a 100644 --- a/runtime/queries/d/textobjects.scm +++ b/runtime/queries/d/textobjects.scm @@ -4,6 +4,6 @@ (class_declaration (aggregate_body) @class.inside) @class.around (interface_declaration (aggregate_body) @class.inside) @class.around (struct_declaration (aggregate_body) @class.inside) @class.around -(unittest_declaration (block_statement) @test.insid) @test.around +(unittest_declaration (block_statement) @test.inside) @test.around (parameter) @parameter.inside -(template_parameter) @parameter.inside \ No newline at end of file +(template_parameter) @parameter.inside From db3383c76e93a696a7dedb8b644ba12b379da9b4 Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Wed, 2 Nov 2022 09:08:25 +0800 Subject: [PATCH 45/57] Exit select mode on replace commands (#4554) --- helix-term/src/commands.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 35439431..ee9bad98 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1304,6 +1304,7 @@ fn replace(cx: &mut Context) { }); apply_transaction(&transaction, doc, view); + exit_select_mode(cx); } }) } @@ -3581,18 +3582,19 @@ fn replace_with_yanked(cx: &mut Context) { }); apply_transaction(&transaction, doc, view); + exit_select_mode(cx); } } } fn replace_selections_with_clipboard_impl( - editor: &mut Editor, + cx: &mut Context, clipboard_type: ClipboardType, - count: usize, ) -> anyhow::Result<()> { - let (view, doc) = current!(editor); + let count = cx.count(); + let (view, doc) = current!(cx.editor); - match editor.clipboard_provider.get_contents(clipboard_type) { + match cx.editor.clipboard_provider.get_contents(clipboard_type) { Ok(contents) => { let selection = doc.selection(view.id); let transaction = Transaction::change_by_selection(doc.text(), selection, |range| { @@ -3605,18 +3607,20 @@ fn replace_selections_with_clipboard_impl( apply_transaction(&transaction, doc, view); doc.append_changes_to_history(view.id); - Ok(()) } - Err(e) => Err(e.context("Couldn't get system clipboard contents")), + Err(e) => return Err(e.context("Couldn't get system clipboard contents")), } + + exit_select_mode(cx); + Ok(()) } fn replace_selections_with_clipboard(cx: &mut Context) { - let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Clipboard, cx.count()); + let _ = replace_selections_with_clipboard_impl(cx, ClipboardType::Clipboard); } fn replace_selections_with_primary_clipboard(cx: &mut Context) { - let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Selection, cx.count()); + let _ = replace_selections_with_clipboard_impl(cx, ClipboardType::Selection); } fn paste(cx: &mut Context, pos: Paste) { From e0b034dcd1a99683efa429e55657dd68ebd9a301 Mon Sep 17 00:00:00 2001 From: Yuriy Date: Tue, 1 Nov 2022 18:01:01 +0100 Subject: [PATCH 46/57] Add syntax highlighting for Python pattern matching Add syntax highlighting for `match` and `case` keywords in Python (https://peps.python.org/pep-0636/). --- runtime/queries/python/highlights.scm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/queries/python/highlights.scm b/runtime/queries/python/highlights.scm index a94d7caf..70b91efb 100644 --- a/runtime/queries/python/highlights.scm +++ b/runtime/queries/python/highlights.scm @@ -2,7 +2,7 @@ (dotted_name (identifier)* @namespace) - + (aliased_import alias: (identifier) @namespace) @@ -67,7 +67,7 @@ (parameters (dictionary_splat_pattern ; **kwargs (identifier) @variable.parameter)) - + (lambda_parameters (identifier) @variable.parameter) @@ -97,7 +97,7 @@ (#match? @constant "^[A-Z_]{2,}$")) ((identifier) @type - (#match? @type "^[A-Z]")) + (#match? @type "^[A-Z]")) (attribute attribute: (identifier) @variable.other.member) (identifier) @variable @@ -168,6 +168,8 @@ "if" "elif" "else" + "match" + "case" ] @keyword.control.conditional [ From b156f5761804a7e9a95268f80ff5e34dea783200 Mon Sep 17 00:00:00 2001 From: Yuriy Date: Tue, 1 Nov 2022 18:49:33 +0100 Subject: [PATCH 47/57] Add indentation for Python pattern matching Add indentation for `match` and `case`. --- runtime/queries/python/indents.scm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runtime/queries/python/indents.scm b/runtime/queries/python/indents.scm index b7b499c0..743971ad 100644 --- a/runtime/queries/python/indents.scm +++ b/runtime/queries/python/indents.scm @@ -9,6 +9,8 @@ (while_statement) (with_statement) (try_statement) + (match_statement) + (case_clause) (import_from_statement) (parenthesized_expression) @@ -33,6 +35,8 @@ (while_statement) (with_statement) (try_statement) + (match_statement) + (case_clause) (function_definition) (class_definition) From 1bed2f30435cfa45502ad2c481a1f4ffe4a1119a Mon Sep 17 00:00:00 2001 From: Charlie Groves Date: Tue, 1 Nov 2022 21:12:40 -0400 Subject: [PATCH 48/57] Use OSC 52 as a fallback for setting the system clipboard (#3220) This adds a simple base64 implementation to keep us from adding a crate for one function. It's mostly based on https://github.com/marshallpierce/rust-base64/blob/a675443d327e175f735a37f574de803d6a332591/src/engine/naive.rs#L42 --- helix-view/src/base64.rs | 163 ++++++++++++++++++++++++++++++++++ helix-view/src/clipboard.rs | 172 +++++++++++++++++++++++------------- helix-view/src/editor.rs | 10 +-- helix-view/src/env.rs | 8 ++ helix-view/src/lib.rs | 2 + 5 files changed, 288 insertions(+), 67 deletions(-) create mode 100644 helix-view/src/base64.rs create mode 100644 helix-view/src/env.rs diff --git a/helix-view/src/base64.rs b/helix-view/src/base64.rs new file mode 100644 index 00000000..a0dc167f --- /dev/null +++ b/helix-view/src/base64.rs @@ -0,0 +1,163 @@ +// A minimal base64 implementation to keep from pulling in a crate for just that. It's based on +// https://github.com/marshallpierce/rust-base64 but without all the customization options. +// The biggest portion comes from +// https://github.com/marshallpierce/rust-base64/blob/a675443d327e175f735a37f574de803d6a332591/src/engine/naive.rs#L42 +// Thanks, rust-base64! + +// The MIT License (MIT) + +// Copyright (c) 2015 Alice Maz + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +use std::ops::{BitAnd, BitOr, Shl, Shr}; + +const PAD_BYTE: u8 = b'='; +const ENCODE_TABLE: &[u8] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".as_bytes(); +const LOW_SIX_BITS: u32 = 0x3F; + +pub fn encode(input: &[u8]) -> String { + let rem = input.len() % 3; + let complete_chunks = input.len() / 3; + let remainder_chunk = if rem == 0 { 0 } else { 1 }; + let encoded_size = (complete_chunks + remainder_chunk) * 4; + + let mut output = vec![0; encoded_size]; + + // complete chunks first + let complete_chunk_len = input.len() - rem; + + let mut input_index = 0_usize; + let mut output_index = 0_usize; + while input_index < complete_chunk_len { + let chunk = &input[input_index..input_index + 3]; + + // populate low 24 bits from 3 bytes + let chunk_int: u32 = + (chunk[0] as u32).shl(16) | (chunk[1] as u32).shl(8) | (chunk[2] as u32); + // encode 4x 6-bit output bytes + output[output_index] = ENCODE_TABLE[chunk_int.shr(18) as usize]; + output[output_index + 1] = ENCODE_TABLE[chunk_int.shr(12_u8).bitand(LOW_SIX_BITS) as usize]; + output[output_index + 2] = ENCODE_TABLE[chunk_int.shr(6_u8).bitand(LOW_SIX_BITS) as usize]; + output[output_index + 3] = ENCODE_TABLE[chunk_int.bitand(LOW_SIX_BITS) as usize]; + + input_index += 3; + output_index += 4; + } + + // then leftovers + if rem == 2 { + let chunk = &input[input_index..input_index + 2]; + + // high six bits of chunk[0] + output[output_index] = ENCODE_TABLE[chunk[0].shr(2) as usize]; + // bottom 2 bits of [0], high 4 bits of [1] + output[output_index + 1] = ENCODE_TABLE + [(chunk[0].shl(4_u8).bitor(chunk[1].shr(4_u8)) as u32).bitand(LOW_SIX_BITS) as usize]; + // bottom 4 bits of [1], with the 2 bottom bits as zero + output[output_index + 2] = + ENCODE_TABLE[(chunk[1].shl(2_u8) as u32).bitand(LOW_SIX_BITS) as usize]; + output[output_index + 3] = PAD_BYTE; + } else if rem == 1 { + let byte = input[input_index]; + output[output_index] = ENCODE_TABLE[byte.shr(2) as usize]; + output[output_index + 1] = + ENCODE_TABLE[(byte.shl(4_u8) as u32).bitand(LOW_SIX_BITS) as usize]; + output[output_index + 2] = PAD_BYTE; + output[output_index + 3] = PAD_BYTE; + } + String::from_utf8(output).expect("Invalid UTF8") +} + +#[cfg(test)] +mod tests { + fn compare_encode(expected: &str, target: &[u8]) { + assert_eq!(expected, super::encode(target)); + } + + #[test] + fn encode_rfc4648_0() { + compare_encode("", b""); + } + + #[test] + fn encode_rfc4648_1() { + compare_encode("Zg==", b"f"); + } + + #[test] + fn encode_rfc4648_2() { + compare_encode("Zm8=", b"fo"); + } + + #[test] + fn encode_rfc4648_3() { + compare_encode("Zm9v", b"foo"); + } + + #[test] + fn encode_rfc4648_4() { + compare_encode("Zm9vYg==", b"foob"); + } + + #[test] + fn encode_rfc4648_5() { + compare_encode("Zm9vYmE=", b"fooba"); + } + + #[test] + fn encode_rfc4648_6() { + compare_encode("Zm9vYmFy", b"foobar"); + } + + #[test] + fn encode_all_ascii() { + let mut ascii = Vec::::with_capacity(128); + + for i in 0..128 { + ascii.push(i); + } + + compare_encode( + "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7P\ + D0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn8\ + =", + &ascii, + ); + } + + #[test] + fn encode_all_bytes() { + let mut bytes = Vec::::with_capacity(256); + + for i in 0..255 { + bytes.push(i); + } + bytes.push(255); //bug with "overflowing" ranges? + + compare_encode( + "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7P\ + D0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn\ + +AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6\ + /wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==", + &bytes, + ); + } +} diff --git a/helix-view/src/clipboard.rs b/helix-view/src/clipboard.rs index ad6f621a..19fade69 100644 --- a/helix-view/src/clipboard.rs +++ b/helix-view/src/clipboard.rs @@ -3,6 +3,7 @@ use anyhow::Result; use std::borrow::Cow; +#[derive(Clone, Copy, Debug)] pub enum ClipboardType { Clipboard, Selection, @@ -72,45 +73,48 @@ pub fn get_clipboard_provider() -> Box { #[cfg(target_os = "macos")] pub fn get_clipboard_provider() -> Box { - use provider::command::exists; + use crate::env::binary_exists; - if exists("pbcopy") && exists("pbpaste") { + if binary_exists("pbcopy") && binary_exists("pbpaste") { command_provider! { paste => "pbpaste"; copy => "pbcopy"; } } else { - Box::new(provider::NopProvider::new()) + Box::new(provider::FallbackProvider::new()) } } #[cfg(target_os = "wasm32")] pub fn get_clipboard_provider() -> Box { // TODO: - Box::new(provider::NopProvider::new()) + Box::new(provider::FallbackProvider::new()) } #[cfg(not(any(windows, target_os = "wasm32", target_os = "macos")))] pub fn get_clipboard_provider() -> Box { - use provider::command::{env_var_is_set, exists, is_exit_success}; + use crate::env::{binary_exists, env_var_is_set}; + use provider::command::is_exit_success; // TODO: support for user-defined provider, probably when we have plugin support by setting a // variable? - if env_var_is_set("WAYLAND_DISPLAY") && exists("wl-copy") && exists("wl-paste") { + if env_var_is_set("WAYLAND_DISPLAY") && binary_exists("wl-copy") && binary_exists("wl-paste") { command_provider! { paste => "wl-paste", "--no-newline"; copy => "wl-copy", "--type", "text/plain"; primary_paste => "wl-paste", "-p", "--no-newline"; primary_copy => "wl-copy", "-p", "--type", "text/plain"; } - } else if env_var_is_set("DISPLAY") && exists("xclip") { + } else if env_var_is_set("DISPLAY") && binary_exists("xclip") { command_provider! { paste => "xclip", "-o", "-selection", "clipboard"; copy => "xclip", "-i", "-selection", "clipboard"; primary_paste => "xclip", "-o"; primary_copy => "xclip", "-i"; } - } else if env_var_is_set("DISPLAY") && exists("xsel") && is_exit_success("xsel", &["-o", "-b"]) + } else if env_var_is_set("DISPLAY") + && binary_exists("xsel") + && is_exit_success("xsel", &["-o", "-b"]) { // FIXME: check performance of is_exit_success command_provider! { @@ -119,43 +123,78 @@ pub fn get_clipboard_provider() -> Box { primary_paste => "xsel", "-o"; primary_copy => "xsel", "-i"; } - } else if exists("win32yank.exe") { + } else if binary_exists("win32yank.exe") { command_provider! { paste => "win32yank.exe", "-o", "--lf"; copy => "win32yank.exe", "-i", "--crlf"; } - } else if exists("termux-clipboard-set") && exists("termux-clipboard-get") { + } else if binary_exists("termux-clipboard-set") && binary_exists("termux-clipboard-get") { command_provider! { paste => "termux-clipboard-get"; copy => "termux-clipboard-set"; } - } else if env_var_is_set("TMUX") && exists("tmux") { + } else if env_var_is_set("TMUX") && binary_exists("tmux") { command_provider! { paste => "tmux", "save-buffer", "-"; copy => "tmux", "load-buffer", "-"; } } else { - Box::new(provider::NopProvider::new()) + Box::new(provider::FallbackProvider::new()) } } +#[cfg(not(target_os = "windows"))] pub mod provider { use super::{ClipboardProvider, ClipboardType}; use anyhow::Result; use std::borrow::Cow; - #[cfg(not(target_os = "windows"))] + #[cfg(feature = "term")] + mod osc52 { + use {super::ClipboardType, crate::base64, crossterm}; + + #[derive(Debug)] + pub struct SetClipboardCommand { + encoded_content: String, + clipboard_type: ClipboardType, + } + + impl SetClipboardCommand { + pub fn new(content: &str, clipboard_type: ClipboardType) -> Self { + Self { + encoded_content: base64::encode(content.as_bytes()), + clipboard_type, + } + } + } + + impl crossterm::Command for SetClipboardCommand { + fn write_ansi(&self, f: &mut impl std::fmt::Write) -> std::fmt::Result { + let kind = match &self.clipboard_type { + ClipboardType::Clipboard => "c", + ClipboardType::Selection => "p", + }; + // Send an OSC 52 set command: https://terminalguide.namepad.de/seq/osc-52/ + write!(f, "\x1b]52;{};{}\x1b\\", kind, &self.encoded_content) + } + } + } + #[derive(Debug)] - pub struct NopProvider { + pub struct FallbackProvider { buf: String, primary_buf: String, } - #[cfg(not(target_os = "windows"))] - impl NopProvider { + impl FallbackProvider { pub fn new() -> Self { + #[cfg(feature = "term")] + log::debug!( + "No native clipboard provider found. Yanking by OSC 52 and pasting will be internal to Helix" + ); + #[cfg(not(feature = "term"))] log::warn!( - "No clipboard provider found! Yanking and pasting will be internal to Helix" + "No native clipboard provider found! Yanking and pasting will be internal to Helix" ); Self { buf: String::new(), @@ -164,20 +203,27 @@ pub mod provider { } } - #[cfg(not(target_os = "windows"))] - impl Default for NopProvider { + impl Default for FallbackProvider { fn default() -> Self { Self::new() } } - #[cfg(not(target_os = "windows"))] - impl ClipboardProvider for NopProvider { + impl ClipboardProvider for FallbackProvider { + #[cfg(feature = "term")] + fn name(&self) -> Cow { + Cow::Borrowed("termcode") + } + + #[cfg(not(feature = "term"))] fn name(&self) -> Cow { Cow::Borrowed("none") } fn get_contents(&self, clipboard_type: ClipboardType) -> Result { + // This is the same noop if term is enabled or not. + // We don't use the get side of OSC 52 as it isn't often enabled, it's a security hole, + // and it would require this to be async to listen for the response let value = match clipboard_type { ClipboardType::Clipboard => self.buf.clone(), ClipboardType::Selection => self.primary_buf.clone(), @@ -187,6 +233,12 @@ pub mod provider { } fn set_contents(&mut self, content: String, clipboard_type: ClipboardType) -> Result<()> { + #[cfg(feature = "term")] + crossterm::execute!( + std::io::stdout(), + osc52::SetClipboardCommand::new(&content, clipboard_type) + )?; + // Set our internal variables to use in get_content regardless of using OSC 52 match clipboard_type { ClipboardType::Clipboard => self.buf = content, ClipboardType::Selection => self.primary_buf = content, @@ -195,52 +247,11 @@ pub mod provider { } } - #[cfg(target_os = "windows")] - #[derive(Default, Debug)] - pub struct WindowsProvider; - - #[cfg(target_os = "windows")] - impl ClipboardProvider for WindowsProvider { - fn name(&self) -> Cow { - log::info!("Using clipboard-win to interact with the system clipboard"); - Cow::Borrowed("clipboard-win") - } - - fn get_contents(&self, clipboard_type: ClipboardType) -> Result { - match clipboard_type { - ClipboardType::Clipboard => { - let contents = clipboard_win::get_clipboard(clipboard_win::formats::Unicode)?; - Ok(contents) - } - ClipboardType::Selection => Ok(String::new()), - } - } - - fn set_contents(&mut self, contents: String, clipboard_type: ClipboardType) -> Result<()> { - match clipboard_type { - ClipboardType::Clipboard => { - clipboard_win::set_clipboard(clipboard_win::formats::Unicode, contents)?; - } - ClipboardType::Selection => {} - }; - Ok(()) - } - } - #[cfg(not(target_arch = "wasm32"))] pub mod command { use super::*; use anyhow::{bail, Context as _, Result}; - pub fn exists(executable_name: &str) -> bool { - which::which(executable_name).is_ok() - } - - #[cfg(not(windows))] - pub fn env_var_is_set(env_var_name: &str) -> bool { - std::env::var_os(env_var_name).is_some() - } - #[cfg(not(any(windows, target_os = "macos")))] pub fn is_exit_success(program: &str, args: &[&str]) -> bool { std::process::Command::new(program) @@ -343,3 +354,40 @@ pub mod provider { } } } + +#[cfg(target_os = "windows")] +mod provider { + use super::{ClipboardProvider, ClipboardType}; + use anyhow::Result; + use std::borrow::Cow; + + #[derive(Default, Debug)] + pub struct WindowsProvider; + + impl ClipboardProvider for WindowsProvider { + fn name(&self) -> Cow { + log::info!("Using clipboard-win to interact with the system clipboard"); + Cow::Borrowed("clipboard-win") + } + + fn get_contents(&self, clipboard_type: ClipboardType) -> Result { + match clipboard_type { + ClipboardType::Clipboard => { + let contents = clipboard_win::get_clipboard(clipboard_win::formats::Unicode)?; + Ok(contents) + } + ClipboardType::Selection => Ok(String::new()), + } + } + + fn set_contents(&mut self, contents: String, clipboard_type: ClipboardType) -> Result<()> { + match clipboard_type { + ClipboardType::Clipboard => { + clipboard_win::set_clipboard(clipboard_win::formats::Unicode, contents)?; + } + ClipboardType::Selection => {} + }; + Ok(()) + } + } +} diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index af69ceea..47edf303 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -187,9 +187,9 @@ pub struct TerminalConfig { #[cfg(windows)] pub fn get_terminal_provider() -> Option { - use crate::clipboard::provider::command::exists; + use crate::env::binary_exists; - if exists("wt") { + if binary_exists("wt") { return Some(TerminalConfig { command: "wt".to_string(), args: vec![ @@ -210,16 +210,16 @@ pub fn get_terminal_provider() -> Option { #[cfg(not(any(windows, target_os = "wasm32")))] pub fn get_terminal_provider() -> Option { - use crate::clipboard::provider::command::{env_var_is_set, exists}; + use crate::env::{binary_exists, env_var_is_set}; - if env_var_is_set("TMUX") && exists("tmux") { + if env_var_is_set("TMUX") && binary_exists("tmux") { return Some(TerminalConfig { command: "tmux".to_string(), args: vec!["split-window".to_string()], }); } - if env_var_is_set("WEZTERM_UNIX_SOCKET") && exists("wezterm") { + if env_var_is_set("WEZTERM_UNIX_SOCKET") && binary_exists("wezterm") { return Some(TerminalConfig { command: "wezterm".to_string(), args: vec!["cli".to_string(), "split-pane".to_string()], diff --git a/helix-view/src/env.rs b/helix-view/src/env.rs new file mode 100644 index 00000000..c68cc609 --- /dev/null +++ b/helix-view/src/env.rs @@ -0,0 +1,8 @@ +pub fn binary_exists(binary_name: &str) -> bool { + which::which(binary_name).is_ok() +} + +#[cfg(not(windows))] +pub fn env_var_is_set(env_var_name: &str) -> bool { + std::env::var_os(env_var_name).is_some() +} diff --git a/helix-view/src/lib.rs b/helix-view/src/lib.rs index 276be441..52044ac7 100644 --- a/helix-view/src/lib.rs +++ b/helix-view/src/lib.rs @@ -4,12 +4,14 @@ pub mod macros; pub mod clipboard; pub mod document; pub mod editor; +pub mod env; pub mod graphics; pub mod gutter; pub mod handlers { pub mod dap; pub mod lsp; } +pub mod base64; pub mod info; pub mod input; pub mod keyboard; From ba394dca6d3a5b52622c4d7b0d3aba7c30af9701 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 3 Nov 2022 01:09:21 -0500 Subject: [PATCH 49/57] Fix panic from two windows editing the same document (#4570) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Clamp highlighting range to be within document This fixes a panic possible when two vsplits of the same document exist and enough lines are deleted from the document so that one of the windows focuses past the end of the document. * Ensure cursor is in view on window change If two windows are editing the same document, one may delete enough of the document so that the other window is pointing at a blank page (past the document end). In this change we ensure that the cursor is within view whenever we switch to a new window (for example with `w`). * Update helix-term/src/ui/editor.rs Co-authored-by: Blaž Hrastnik Co-authored-by: Blaž Hrastnik --- helix-term/src/ui/editor.rs | 16 ++++++++-------- helix-view/src/editor.rs | 8 ++++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 72c9d15e..2cd2ad05 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -227,16 +227,16 @@ impl EditorView { _theme: &Theme, ) -> Box + 'doc> { let text = doc.text().slice(..); - let last_line = std::cmp::min( - // Saturating subs to make it inclusive zero indexing. - (offset.row + height as usize).saturating_sub(1), - doc.text().len_lines().saturating_sub(1), - ); let range = { - // calculate viewport byte ranges - let start = text.line_to_byte(offset.row); - let end = text.line_to_byte(last_line + 1); + // Calculate viewport byte ranges: + // Saturating subs to make it inclusive zero indexing. + let last_line = doc.text().len_lines().saturating_sub(1); + let last_visible_line = (offset.row + height as usize) + .saturating_sub(1) + .min(last_line); + let start = text.line_to_byte(offset.row.min(last_line)); + let end = text.line_to_byte(last_visible_line + 1); start..end }; diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 47edf303..bb9616e8 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -1223,9 +1223,11 @@ impl Editor { pub fn focus(&mut self, view_id: ViewId) { let prev_id = std::mem::replace(&mut self.tree.focus, view_id); - // if leaving the view: mode should reset + // if leaving the view: mode should reset and the cursor should be + // within view if prev_id != view_id { self.mode = Mode::Normal; + self.ensure_cursor_in_view(view_id); } } @@ -1234,9 +1236,11 @@ impl Editor { self.tree.focus_next(); let id = self.tree.focus; - // if leaving the view: mode should reset + // if leaving the view: mode should reset and the cursor should be + // within view if prev_id != id { self.mode = Mode::Normal; + self.ensure_cursor_in_view(id); } } From c667ff8da3fa664c6fe37d2da8d9d22a4dd823e1 Mon Sep 17 00:00:00 2001 From: ChrHorn Date: Fri, 4 Nov 2022 03:17:06 +0100 Subject: [PATCH 50/57] Increase default language server timeout for Julia (#4575) --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index adce81c5..94b3e75f 100644 --- a/languages.toml +++ b/languages.toml @@ -593,7 +593,7 @@ injection-regex = "julia" file-types = ["jl"] roots = ["Manifest.toml", "Project.toml"] comment-token = "#" -language-server = { command = "julia", args = [ +language-server = { command = "julia", timeout = 60, args = [ "--startup-file=no", "--history-file=no", "--quiet", From d357f1673fecfadd96983c025057b63a3d3b45e0 Mon Sep 17 00:00:00 2001 From: throwaway-helix-zsh <117384672+throwaway-helix-zsh@users.noreply.github.com> Date: Fri, 4 Nov 2022 02:18:24 +0000 Subject: [PATCH 51/57] Use language=bash when shebang line uses zsh (#4582) This PR makes the editor use language=bash when the shebang line uses zsh. This is in the same line as using language=bash for zsh related file (~/.zshrc, ~/.zshenv etc.) as we already do. --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 94b3e75f..071c2e40 100644 --- a/languages.toml +++ b/languages.toml @@ -522,7 +522,7 @@ name = "bash" scope = "source.bash" injection-regex = "(shell|bash|zsh|sh)" file-types = ["sh", "bash", "zsh", ".bash_login", ".bash_logout", ".bash_profile", ".bashrc", ".profile", ".zshenv", ".zlogin", ".zlogout", ".zprofile", ".zshrc", "APKBUILD", "PKGBUILD", "eclass", "ebuild", "bazelrc"] -shebangs = ["sh", "bash", "dash"] +shebangs = ["sh", "bash", "dash", "zsh"] roots = [] comment-token = "#" language-server = { command = "bash-language-server", args = ["start"] } From 921d3510132b0bd89d4ac0a542371c3ae90e2e02 Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Fri, 4 Nov 2022 03:20:14 +0100 Subject: [PATCH 52/57] bump up LhKipp/tree-sitter-nu's version to latest (#4583) --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 071c2e40..061d1414 100644 --- a/languages.toml +++ b/languages.toml @@ -1414,7 +1414,7 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "nu" -source = { git = "https://github.com/LhKipp/tree-sitter-nu", rev = "db4e990b78824c8abef3618e0f93b7fe1e8f4c0d" } +source = { git = "https://github.com/LhKipp/tree-sitter-nu", rev = "eb95bdac3abd73ef47e53f19c63e74a31405ebd2" } [[language]] name = "vala" From c2c1280f02b83a468da67d88350c199915427535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Fri, 4 Nov 2022 21:01:17 +0900 Subject: [PATCH 53/57] Resolve a bunch of upcoming clippy lints --- helix-core/src/history.rs | 2 +- helix-core/src/increment/number.rs | 4 +- helix-core/src/line_ending.rs | 2 +- helix-core/src/surround.rs | 2 +- helix-core/src/syntax.rs | 14 ++-- helix-dap/src/transport.rs | 2 +- helix-dap/src/types.rs | 100 ++++++++++++++--------------- helix-loader/src/grammar.rs | 4 +- helix-lsp/src/jsonrpc.rs | 26 ++++---- helix-term/build.rs | 2 +- helix-term/src/application.rs | 4 +- helix-term/src/commands.rs | 15 ++--- helix-term/src/commands/lsp.rs | 6 +- helix-term/src/ui/menu.rs | 2 +- helix-term/src/ui/prompt.rs | 4 +- helix-tui/src/buffer.rs | 4 +- helix-tui/src/layout.rs | 2 +- helix-tui/src/text.rs | 8 +-- helix-tui/src/widgets/block.rs | 16 ++--- helix-tui/src/widgets/table.rs | 6 +- helix-view/src/editor.rs | 4 +- helix-view/src/graphics.rs | 8 +-- 22 files changed, 113 insertions(+), 124 deletions(-) diff --git a/helix-core/src/history.rs b/helix-core/src/history.rs index b608097c..5cd72b07 100644 --- a/helix-core/src/history.rs +++ b/helix-core/src/history.rs @@ -282,7 +282,7 @@ impl History { } /// Whether to undo by a number of edits or a duration of time. -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum UndoKind { Steps(usize), TimePeriod(std::time::Duration), diff --git a/helix-core/src/increment/number.rs b/helix-core/src/increment/number.rs index 62b4a19d..91268729 100644 --- a/helix-core/src/increment/number.rs +++ b/helix-core/src/increment/number.rs @@ -110,8 +110,8 @@ impl<'a> Increment for NumberIncrementor<'a> { let (lower_count, upper_count): (usize, usize) = old_text.chars().skip(2).fold((0, 0), |(lower, upper), c| { ( - lower + c.is_ascii_lowercase().then(|| 1).unwrap_or(0), - upper + c.is_ascii_uppercase().then(|| 1).unwrap_or(0), + lower + usize::from(c.is_ascii_lowercase()), + upper + usize::from(c.is_ascii_uppercase()), ) }); if upper_count > lower_count { diff --git a/helix-core/src/line_ending.rs b/helix-core/src/line_ending.rs index 3e8a6cae..09e92523 100644 --- a/helix-core/src/line_ending.rs +++ b/helix-core/src/line_ending.rs @@ -6,7 +6,7 @@ pub const DEFAULT_LINE_ENDING: LineEnding = LineEnding::Crlf; pub const DEFAULT_LINE_ENDING: LineEnding = LineEnding::LF; /// Represents one of the valid Unicode line endings. -#[derive(PartialEq, Copy, Clone, Debug)] +#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum LineEnding { Crlf, // CarriageReturn followed by LineFeed LF, // U+000A -- LineFeed diff --git a/helix-core/src/surround.rs b/helix-core/src/surround.rs index 6244b380..a3de3cd1 100644 --- a/helix-core/src/surround.rs +++ b/helix-core/src/surround.rs @@ -13,7 +13,7 @@ pub const PAIRS: &[(char, char)] = &[ ('(', ')'), ]; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Error { PairNotFound, CursorOverlap, diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index c17655a9..0f62577f 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -218,7 +218,7 @@ pub struct FormatterConfiguration { pub args: Vec, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub struct AdvancedCompletion { pub name: Option, @@ -226,14 +226,14 @@ pub struct AdvancedCompletion { pub default: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "kebab-case", untagged)] pub enum DebugConfigCompletion { Named(String), Advanced(AdvancedCompletion), } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(untagged)] pub enum DebugArgumentValue { String(String), @@ -241,7 +241,7 @@ pub enum DebugArgumentValue { Boolean(bool), } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub struct DebugTemplate { pub name: String, @@ -250,7 +250,7 @@ pub struct DebugTemplate { pub args: HashMap, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub struct DebugAdapterConfig { pub name: String, @@ -266,7 +266,7 @@ pub struct DebugAdapterConfig { } // Different workarounds for adapters' differences -#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, Default, PartialEq, Eq, Clone, Serialize, Deserialize)] pub struct DebuggerQuirks { #[serde(default)] pub absolute_paths: bool, @@ -280,7 +280,7 @@ pub struct IndentationConfiguration { } /// Configuration for auto pairs -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case", deny_unknown_fields, untagged)] pub enum AutoPairConfig { /// Enables or disables auto pairing. False means disabled. True means to use the default pairs. diff --git a/helix-dap/src/transport.rs b/helix-dap/src/transport.rs index 783a6f5d..dd03e568 100644 --- a/helix-dap/src/transport.rs +++ b/helix-dap/src/transport.rs @@ -22,7 +22,7 @@ pub struct Request { pub arguments: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] pub struct Response { // seq is omitted as unused and is not sent by some implementations pub request_seq: u64, diff --git a/helix-dap/src/types.rs b/helix-dap/src/types.rs index 51ecfe1b..0a9ebe5e 100644 --- a/helix-dap/src/types.rs +++ b/helix-dap/src/types.rs @@ -22,7 +22,7 @@ pub trait Request { const COMMAND: &'static str; } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct ColumnDescriptor { pub attribute_name: String, @@ -35,7 +35,7 @@ pub struct ColumnDescriptor { pub width: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct ExceptionBreakpointsFilter { pub filter: String, @@ -50,7 +50,7 @@ pub struct ExceptionBreakpointsFilter { pub condition_description: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct DebuggerCapabilities { #[serde(skip_serializing_if = "Option::is_none")] @@ -131,14 +131,14 @@ pub struct DebuggerCapabilities { pub supported_checksum_algorithms: Option>, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Checksum { pub algorithm: String, pub checksum: String, } -#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Source { #[serde(skip_serializing_if = "Option::is_none")] @@ -159,7 +159,7 @@ pub struct Source { pub checksums: Option>, } -#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct SourceBreakpoint { pub line: usize, @@ -173,7 +173,7 @@ pub struct SourceBreakpoint { pub log_message: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Breakpoint { #[serde(skip_serializing_if = "Option::is_none")] @@ -197,7 +197,7 @@ pub struct Breakpoint { pub offset: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct StackFrameFormat { #[serde(skip_serializing_if = "Option::is_none")] @@ -216,7 +216,7 @@ pub struct StackFrameFormat { pub include_all: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct StackFrame { pub id: usize, @@ -239,14 +239,14 @@ pub struct StackFrame { pub presentation_hint: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Thread { pub id: ThreadId, pub name: String, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Scope { pub name: String, @@ -270,14 +270,14 @@ pub struct Scope { pub end_column: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct ValueFormat { #[serde(skip_serializing_if = "Option::is_none")] pub hex: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct VariablePresentationHint { #[serde(skip_serializing_if = "Option::is_none")] @@ -288,7 +288,7 @@ pub struct VariablePresentationHint { pub visibility: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Variable { pub name: String, @@ -308,7 +308,7 @@ pub struct Variable { pub memory_reference: Option, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Module { pub id: String, // TODO: || number @@ -333,7 +333,7 @@ pub struct Module { pub mod requests { use super::*; - #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct InitializeArguments { #[serde(rename = "clientID", skip_serializing_if = "Option::is_none")] @@ -409,7 +409,7 @@ pub mod requests { const COMMAND: &'static str = "configurationDone"; } - #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct SetBreakpointsArguments { pub source: Source, @@ -420,7 +420,7 @@ pub mod requests { pub source_modified: Option, } - #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct SetBreakpointsResponse { #[serde(skip_serializing_if = "Option::is_none")] @@ -436,13 +436,13 @@ pub mod requests { const COMMAND: &'static str = "setBreakpoints"; } - #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct ContinueArguments { pub thread_id: ThreadId, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct ContinueResponse { #[serde(skip_serializing_if = "Option::is_none")] @@ -458,7 +458,7 @@ pub mod requests { const COMMAND: &'static str = "continue"; } - #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct StackTraceArguments { pub thread_id: ThreadId, @@ -470,7 +470,7 @@ pub mod requests { pub format: Option, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct StackTraceResponse { #[serde(skip_serializing_if = "Option::is_none")] @@ -487,7 +487,7 @@ pub mod requests { const COMMAND: &'static str = "stackTrace"; } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct ThreadsResponse { pub threads: Vec, @@ -502,13 +502,13 @@ pub mod requests { const COMMAND: &'static str = "threads"; } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct ScopesArguments { pub frame_id: usize, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct ScopesResponse { pub scopes: Vec, @@ -523,7 +523,7 @@ pub mod requests { const COMMAND: &'static str = "scopes"; } - #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct VariablesArguments { pub variables_reference: usize, @@ -537,7 +537,7 @@ pub mod requests { pub format: Option, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct VariablesResponse { pub variables: Vec, @@ -552,7 +552,7 @@ pub mod requests { const COMMAND: &'static str = "variables"; } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct StepInArguments { pub thread_id: ThreadId, @@ -571,7 +571,7 @@ pub mod requests { const COMMAND: &'static str = "stepIn"; } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct StepOutArguments { pub thread_id: ThreadId, @@ -588,7 +588,7 @@ pub mod requests { const COMMAND: &'static str = "stepOut"; } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct NextArguments { pub thread_id: ThreadId, @@ -605,7 +605,7 @@ pub mod requests { const COMMAND: &'static str = "next"; } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct PauseArguments { pub thread_id: ThreadId, @@ -620,7 +620,7 @@ pub mod requests { const COMMAND: &'static str = "pause"; } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct EvaluateArguments { pub expression: String, @@ -632,7 +632,7 @@ pub mod requests { pub format: Option, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct EvaluateResponse { pub result: String, @@ -658,7 +658,7 @@ pub mod requests { const COMMAND: &'static str = "evaluate"; } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct SetExceptionBreakpointsArguments { pub filters: Vec, @@ -666,7 +666,7 @@ pub mod requests { // pub exceptionOptions: Option>, // needs capability } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct SetExceptionBreakpointsResponse { #[serde(skip_serializing_if = "Option::is_none")] @@ -684,7 +684,7 @@ pub mod requests { // Reverse Requests - #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct RunInTerminalResponse { #[serde(skip_serializing_if = "Option::is_none")] @@ -693,7 +693,7 @@ pub mod requests { pub shell_process_id: Option, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct RunInTerminalArguments { #[serde(skip_serializing_if = "Option::is_none")] @@ -745,7 +745,7 @@ pub mod events { Memory(Memory), } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Stopped { pub reason: String, @@ -763,7 +763,7 @@ pub mod events { pub hit_breakpoint_ids: Option>, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Continued { pub thread_id: ThreadId, @@ -771,27 +771,27 @@ pub mod events { pub all_threads_continued: Option, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Exited { pub exit_code: usize, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Terminated { #[serde(skip_serializing_if = "Option::is_none")] pub restart: Option, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Thread { pub reason: String, pub thread_id: ThreadId, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Output { pub output: String, @@ -811,28 +811,28 @@ pub mod events { pub data: Option, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Breakpoint { pub reason: String, pub breakpoint: super::Breakpoint, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Module { pub reason: String, pub module: super::Module, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct LoadedSource { pub reason: String, pub source: super::Source, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Process { pub name: String, @@ -846,13 +846,13 @@ pub mod events { pub pointer_size: Option, } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Capabilities { pub capabilities: super::DebuggerCapabilities, } - // #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + // #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] // #[serde(rename_all = "camelCase")] // pub struct Invalidated { // pub areas: Vec, @@ -860,7 +860,7 @@ pub mod events { // pub stack_frame_id: Option, // } - #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Memory { pub memory_reference: String, diff --git a/helix-loader/src/grammar.rs b/helix-loader/src/grammar.rs index a92cadb6..833616e0 100644 --- a/helix-loader/src/grammar.rs +++ b/helix-loader/src/grammar.rs @@ -67,7 +67,7 @@ pub fn get_language(name: &str) -> Result { #[cfg(not(target_arch = "wasm32"))] pub fn get_language(name: &str) -> Result { use libloading::{Library, Symbol}; - let mut library_path = crate::runtime_dir().join("grammars").join(&name); + let mut library_path = crate::runtime_dir().join("grammars").join(name); library_path.set_extension(DYLIB_EXTENSION); let library = unsafe { Library::new(&library_path) } @@ -429,7 +429,7 @@ fn build_tree_sitter_library( if cfg!(all(windows, target_env = "msvc")) { command - .args(&["/nologo", "/LD", "/I"]) + .args(["/nologo", "/LD", "/I"]) .arg(header_path) .arg("/Od") .arg("/utf-8"); diff --git a/helix-lsp/src/jsonrpc.rs b/helix-lsp/src/jsonrpc.rs index b9b3fd2c..75ac9309 100644 --- a/helix-lsp/src/jsonrpc.rs +++ b/helix-lsp/src/jsonrpc.rs @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; // https://www.jsonrpc.org/specification#error_object -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub enum ErrorCode { ParseError, InvalidRequest, @@ -68,7 +68,7 @@ impl Serialize for ErrorCode { } } -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] pub struct Error { pub code: ErrorCode, pub message: String, @@ -100,7 +100,7 @@ impl std::error::Error for Error {} // https://www.jsonrpc.org/specification#request_object /// Request ID -#[derive(Debug, PartialEq, Clone, Hash, Eq, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Hash, Deserialize, Serialize)] #[serde(untagged)] pub enum Id { Null, @@ -109,7 +109,7 @@ pub enum Id { } /// Protocol Version -#[derive(Debug, PartialEq, Clone, Copy, Hash, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] pub enum Version { V2, } @@ -153,7 +153,7 @@ impl<'de> Deserialize<'de> for Version { } } -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum Params { None, @@ -182,7 +182,7 @@ impl From for Value { } } -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] pub struct MethodCall { pub jsonrpc: Option, @@ -192,7 +192,7 @@ pub struct MethodCall { pub id: Id, } -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] pub struct Notification { pub jsonrpc: Option, @@ -201,7 +201,7 @@ pub struct Notification { pub params: Params, } -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] #[serde(untagged)] pub enum Call { @@ -235,7 +235,7 @@ impl From for Call { } } -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] #[serde(untagged)] pub enum Request { @@ -245,7 +245,7 @@ pub enum Request { // https://www.jsonrpc.org/specification#response_object -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] pub struct Success { #[serde(skip_serializing_if = "Option::is_none")] pub jsonrpc: Option, @@ -253,7 +253,7 @@ pub struct Success { pub id: Id, } -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] pub struct Failure { #[serde(skip_serializing_if = "Option::is_none")] pub jsonrpc: Option, @@ -264,7 +264,7 @@ pub struct Failure { // Note that failure comes first because we're not using // #[serde(deny_unknown_field)]: we want a request that contains // both `result` and `error` to be a `Failure`. -#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)] #[serde(untagged)] pub enum Output { Failure(Failure), @@ -280,7 +280,7 @@ impl From for Result { } } -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(untagged)] pub enum Response { Single(Output), diff --git a/helix-term/build.rs b/helix-term/build.rs index 74c35a3a..719113ff 100644 --- a/helix-term/build.rs +++ b/helix-term/build.rs @@ -6,7 +6,7 @@ const VERSION: &str = include_str!("../VERSION"); fn main() { let git_hash = Command::new("git") - .args(&["rev-parse", "HEAD"]) + .args(["rev-parse", "HEAD"]) .output() .ok() .filter(|output| output.status.success()) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 173c5d49..e356c1f9 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -168,7 +168,7 @@ impl Application { } else if !args.files.is_empty() { let first = &args.files[0].0; // we know it's not empty if first.is_dir() { - std::env::set_current_dir(&first).context("set current dir")?; + std::env::set_current_dir(first).context("set current dir")?; editor.new_file(Action::VerticalSplit); let picker = ui::file_picker(".".into(), &config.load().editor); compositor.push(Box::new(overlayed(picker))); @@ -228,7 +228,7 @@ impl Application { #[cfg(windows)] let signals = futures_util::stream::empty(); #[cfg(not(windows))] - let signals = Signals::new(&[signal::SIGTSTP, signal::SIGCONT, signal::SIGUSR1]) + let signals = Signals::new([signal::SIGTSTP, signal::SIGCONT, signal::SIGUSR1]) .context("build signal handler")?; let app = Self { diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index ee9bad98..aae9979d 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3933,15 +3933,12 @@ pub fn completion(cx: &mut Context) { }; if !prefix.is_empty() { - items = items - .into_iter() - .filter(|item| { - item.filter_text - .as_ref() - .unwrap_or(&item.label) - .starts_with(&prefix) - }) - .collect(); + items.retain(|item| { + item.filter_text + .as_ref() + .unwrap_or(&item.label) + .starts_with(&prefix) + }); } if items.is_empty() { diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index d7617c50..5498fc83 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -57,7 +57,7 @@ impl ui::menu::Item for lsp::Location { // allocation, for `to_file_path`, else there will be two (2), with `to_string_lossy`. let mut write_path_to_res = || -> Option<()> { let path = self.uri.to_file_path().ok()?; - res.push_str(&path.strip_prefix(&cwdir).unwrap_or(&path).to_string_lossy()); + res.push_str(&path.strip_prefix(cwdir).unwrap_or(&path).to_string_lossy()); Some(()) }; write_path_to_res(); @@ -634,7 +634,7 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> { // Create directory if it does not exist if let Some(dir) = path.parent() { if !dir.is_dir() { - fs::create_dir_all(&dir)?; + fs::create_dir_all(dir)?; } } @@ -910,7 +910,7 @@ pub fn goto_reference(cx: &mut Context) { ); } -#[derive(PartialEq)] +#[derive(PartialEq, Eq)] pub enum SignatureHelpInvoked { Manual, Automatic, diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index 99c2473d..1baaf40a 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -40,7 +40,7 @@ impl Item for PathBuf { type Data = PathBuf; fn label(&self, root_path: &Self::Data) -> Spans { - self.strip_prefix(&root_path) + self.strip_prefix(root_path) .unwrap_or(self) .to_string_lossy() .into() diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index d0991d3c..ca2872a7 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -32,7 +32,7 @@ pub struct Prompt { next_char_handler: Option, } -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Eq)] pub enum PromptEvent { /// The prompt input has been updated. Update, @@ -408,7 +408,7 @@ impl Prompt { surface.set_stringn( area.x + col * (1 + col_width), area.y + row, - &completion, + completion, col_width.saturating_sub(1) as usize, color, ); diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs index 23ba43f1..5169196a 100644 --- a/helix-tui/src/buffer.rs +++ b/helix-tui/src/buffer.rs @@ -6,7 +6,7 @@ use unicode_segmentation::UnicodeSegmentation; use helix_view::graphics::{Color, Modifier, Rect, Style, UnderlineStyle}; /// A buffer cell -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Cell { pub symbol: String, pub fg: Color, @@ -119,7 +119,7 @@ impl Default for Cell { /// buf[(5, 0)].set_char('x'); /// assert_eq!(buf[(5, 0)].symbol, "x"); /// ``` -#[derive(Debug, Default, Clone, PartialEq)] +#[derive(Debug, Default, Clone, PartialEq, Eq)] pub struct Buffer { /// The area represented by this buffer pub area: Rect, diff --git a/helix-tui/src/layout.rs b/helix-tui/src/layout.rs index 7c72a778..1f3ddc6e 100644 --- a/helix-tui/src/layout.rs +++ b/helix-tui/src/layout.rs @@ -46,7 +46,7 @@ impl Constraint { } } -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Alignment { Left, Center, diff --git a/helix-tui/src/text.rs b/helix-tui/src/text.rs index 1bfe5ee1..ccdafad5 100644 --- a/helix-tui/src/text.rs +++ b/helix-tui/src/text.rs @@ -53,14 +53,14 @@ use std::borrow::Cow; use unicode_segmentation::UnicodeSegmentation; /// A grapheme associated to a style. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct StyledGrapheme<'a> { pub symbol: &'a str, pub style: Style, } /// A string where all graphemes have the same style. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Span<'a> { pub content: Cow<'a, str>, pub style: Style, @@ -209,7 +209,7 @@ impl<'a> From> for Span<'a> { } /// A string composed of clusters of graphemes, each with their own style. -#[derive(Debug, Default, Clone, PartialEq)] +#[derive(Debug, Default, Clone, PartialEq, Eq)] pub struct Spans<'a>(pub Vec>); impl<'a> Spans<'a> { @@ -297,7 +297,7 @@ impl<'a> From<&Spans<'a>> for String { /// text.extend(Text::styled("Some more lines\nnow with more style!", style)); /// assert_eq!(6, text.height()); /// ``` -#[derive(Debug, Default, Clone, PartialEq)] +#[derive(Debug, Default, Clone, PartialEq, Eq)] pub struct Text<'a> { pub lines: Vec>, } diff --git a/helix-tui/src/widgets/block.rs b/helix-tui/src/widgets/block.rs index bd025a31..98f84abe 100644 --- a/helix-tui/src/widgets/block.rs +++ b/helix-tui/src/widgets/block.rs @@ -7,7 +7,7 @@ use crate::{ use helix_view::graphics::{Rect, Style}; /// Border render type. Defaults to [`BorderType::Plain`]. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum BorderType { Plain, Rounded, @@ -47,7 +47,7 @@ impl Default for BorderType { /// .border_type(BorderType::Rounded) /// .style(Style::default().bg(Color::Black)); /// ``` -#[derive(Debug, Default, Clone, PartialEq)] +#[derive(Debug, Default, Clone, PartialEq, Eq)] pub struct Block<'a> { /// Optional title place on the upper left of the block title: Option>, @@ -187,16 +187,8 @@ impl<'a> Widget for Block<'a> { } if let Some(title) = self.title { - let lx = if self.borders.intersects(Borders::LEFT) { - 1 - } else { - 0 - }; - let rx = if self.borders.intersects(Borders::RIGHT) { - 1 - } else { - 0 - }; + let lx = u16::from(self.borders.intersects(Borders::LEFT)); + let rx = u16::from(self.borders.intersects(Borders::RIGHT)); let width = area.width.saturating_sub(lx).saturating_sub(rx); buf.set_spans(area.left() + lx, area.top(), &title, width); } diff --git a/helix-tui/src/widgets/table.rs b/helix-tui/src/widgets/table.rs index eb03704e..a8f428a7 100644 --- a/helix-tui/src/widgets/table.rs +++ b/helix-tui/src/widgets/table.rs @@ -34,7 +34,7 @@ use std::collections::HashMap; /// /// You can apply a [`Style`] on the entire [`Cell`] using [`Cell::style`] or rely on the styling /// capabilities of [`Text`]. -#[derive(Debug, Clone, PartialEq, Default)] +#[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct Cell<'a> { pub content: Text<'a>, style: Style, @@ -79,7 +79,7 @@ where /// ``` /// /// By default, a row has a height of 1 but you can change this using [`Row::height`]. -#[derive(Debug, Clone, PartialEq, Default)] +#[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct Row<'a> { pub cells: Vec>, height: u16, @@ -179,7 +179,7 @@ impl<'a> Row<'a> { /// // ...and potentially show a symbol in front of the selection. /// .highlight_symbol(">>"); /// ``` -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Table<'a> { /// A block to wrap the widget in block: Option>, diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index bb9616e8..bcd8dedb 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -111,7 +111,7 @@ impl Default for FilePickerConfig { } } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case", default, deny_unknown_fields)] pub struct Config { /// Padding to keep between the edge of the screen and the cursor when scrolling. Defaults to 5. @@ -346,7 +346,7 @@ pub enum StatusLineElement { // Cursor shape is read and used on every rendered frame and so needs // to be fast. Therefore we avoid a hashmap and use an enum indexed array. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct CursorShapeConfig([CursorKind; 3]); impl CursorShapeConfig { diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs index cbae873a..9264c50f 100644 --- a/helix-view/src/graphics.rs +++ b/helix-view/src/graphics.rs @@ -5,7 +5,7 @@ use std::{ str::FromStr, }; -#[derive(Debug, Clone, Copy, PartialEq, Deserialize, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] /// UNSTABLE pub enum CursorKind { @@ -250,7 +250,7 @@ impl Rect { } } -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Color { Reset, @@ -303,7 +303,7 @@ impl From for crossterm::style::Color { } } -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum UnderlineStyle { Reset, Line, @@ -449,7 +449,7 @@ impl FromStr for Modifier { /// buffer[(0, 0)].style(), /// ); /// ``` -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Style { pub fg: Option, From 9a898be95934bec46c5a77c61d77314ecb4d71fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Fri, 4 Nov 2022 21:01:34 +0900 Subject: [PATCH 54/57] nix: Bump flake dependencies --- flake.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index cfa227e3..74206d2b 100644 --- a/flake.lock +++ b/flake.lock @@ -36,11 +36,11 @@ "devshell": { "flake": false, "locked": { - "lastModified": 1666548262, - "narHash": "sha256-4DyN4KXqQQsCw0vCXkMThw4b5Q4/q87ZZgRb4st8COc=", + "lastModified": 1667210711, + "narHash": "sha256-IoErjXZAkzYWHEpQqwu/DeRNJGFdR7X2OGbkhMqMrpw=", "owner": "numtide", "repo": "devshell", - "rev": "c8ce8ed81726079c398f5f29c4b68a7d6a3c2fa2", + "rev": "96a9dd12b8a447840cc246e17a47b81a4268bba7", "type": "github" }, "original": { @@ -88,11 +88,11 @@ ] }, "locked": { - "lastModified": 1666993587, - "narHash": "sha256-4cLrs+CwWnceYXnCpL5gO3bybS9CjLxUoTEKjB2QFtg=", + "lastModified": 1667429039, + "narHash": "sha256-Lu6da25JioHzerkLHAHSO9suCQFzJ/XBjkcGCIbasLM=", "owner": "nix-community", "repo": "dream2nix", - "rev": "2b7456e3d2f0053bc2474fb0c461dd468545277f", + "rev": "5252794e58eedb02d607fa3187ffead7becc81b0", "type": "github" }, "original": { @@ -144,11 +144,11 @@ ] }, "locked": { - "lastModified": 1667232647, - "narHash": "sha256-cFo7G8BqYShgL9m7yD6p+SHAZ+aIt2guuF69LV235n8=", + "lastModified": 1667542401, + "narHash": "sha256-mdWjP5tjSf8n6FAtpSgL23kX4+eWBwLrSYo9iY3mA8Q=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "16082f7b4e42ce140a562fa630bcf8e96eadeb59", + "rev": "cd5e5cbd81c80dc219455dd3b1e0ddb55fae51ec", "type": "github" }, "original": { @@ -159,11 +159,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1667142599, - "narHash": "sha256-OLJxsg9VqfKjFkerOxWtNIkibsCvxsv5A8wNWO1MeWk=", + "lastModified": 1667482890, + "narHash": "sha256-pua0jp87iwN7NBY5/ypx0s9L9CG49Ju/NI4wGwurHc4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "412b9917cea092f3d39f9cd5dead4effd5bc4053", + "rev": "a2a777538d971c6b01c6e54af89ddd6567c055e8", "type": "github" }, "original": { @@ -188,11 +188,11 @@ ] }, "locked": { - "lastModified": 1667184938, - "narHash": "sha256-/kuCiXuAxiD0c0zrfDvJ1Yba3FuVdRk/ROfb393AeX4=", + "lastModified": 1667487142, + "narHash": "sha256-bVuzLs1ZVggJAbJmEDVO9G6p8BH3HRaolK70KXvnWnU=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "8f81faec35508647ced65c44fd3e8648a5518afb", + "rev": "cf668f737ac986c0a89e83b6b2e3c5ddbd8cf33b", "type": "github" }, "original": { From d6323b7cbc21a9d3ba29738c76581dad93f9f415 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 4 Nov 2022 11:02:19 -0500 Subject: [PATCH 55/57] Select text inserted by shell or paste (#4458) This follows changes in Kakoune to the same effects: * p/p: https://github.com/mawww/kakoune/commit/266d1c37d0d970a7eff747f5e6a5773a3cea39d8 * !/: https://github.com/mawww/kakoune/commit/85b78dda2e29d70b620836b04224b104426bdbae Selecting the new data inserted by shell or pasting is often more useful than retaining a selection of the pre-paste/insert content. --- helix-term/src/commands.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index aae9979d..a6ee6263 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3471,6 +3471,8 @@ fn paste_impl(values: &[String], doc: &mut Document, view: &mut View, action: Pa let text = doc.text(); let selection = doc.selection(view.id); + let mut ranges = SmallVec::with_capacity(selection.len()); + let transaction = Transaction::change_by_selection(text, selection, |range| { let pos = match (action, linewise) { // paste linewise before @@ -3487,8 +3489,21 @@ fn paste_impl(values: &[String], doc: &mut Document, view: &mut View, action: Pa // paste at cursor (Paste::Cursor, _) => range.cursor(text.slice(..)), }; - (pos, pos, values.next()) + + let value = values.next(); + + let value_len = value + .as_ref() + .map(|content| content.chars().count()) + .unwrap_or_default(); + + ranges.push(Range::new(pos, pos + value_len)); + + (pos, pos, value) }); + + let transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index())); + apply_transaction(&transaction, doc, view); } @@ -4742,6 +4757,7 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) { let selection = doc.selection(view.id); let mut changes = Vec::with_capacity(selection.len()); + let mut ranges = SmallVec::with_capacity(selection.len()); let text = doc.text().slice(..); for range in selection.ranges() { @@ -4765,11 +4781,13 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) { ShellBehavior::Append => (range.to(), range.to()), _ => (range.from(), range.from()), }; + ranges.push(Range::new(to, to + output.chars().count())); changes.push((from, to, Some(output))); } if behavior != &ShellBehavior::Ignore { - let transaction = Transaction::change(doc.text(), changes.into_iter()); + let transaction = Transaction::change(doc.text(), changes.into_iter()) + .with_selection(Selection::new(ranges, selection.primary_index())); apply_transaction(&transaction, doc, view); doc.append_changes_to_history(view.id); } From 38149872989477f62222ce68dc32d2d6018ae165 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 4 Nov 2022 11:04:16 -0500 Subject: [PATCH 56/57] Fix panic on paste from blackhole register (#4497) The sequence "_y"_p panics because the blackhole register contains an empty values vec. This causes a panic when pasting since it unwraps a `slice::last`. --- helix-term/src/commands.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index a6ee6263..ef963477 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3447,7 +3447,12 @@ enum Paste { } fn paste_impl(values: &[String], doc: &mut Document, view: &mut View, action: Paste, count: usize) { + if values.is_empty() { + return; + } + let repeat = std::iter::repeat( + // `values` is asserted to have at least one entry above. values .last() .map(|value| Tendril::from(value.repeat(count))) From 4ec2a21c6e21ab4e515f1bd7ee1049094af2a6b2 Mon Sep 17 00:00:00 2001 From: ChrHorn Date: Sat, 5 Nov 2022 19:30:40 +0100 Subject: [PATCH 57/57] Update Julia grammar, queries (#4588) --- languages.toml | 2 +- runtime/queries/julia/highlights.scm | 42 ++++++++++++++++++++++++---- runtime/queries/julia/locals.scm | 3 +- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/languages.toml b/languages.toml index 061d1414..41558e10 100644 --- a/languages.toml +++ b/languages.toml @@ -604,7 +604,7 @@ indent = { tab-width = 4, unit = " " } [[grammar]] name = "julia" -source = { git = "https://github.com/tree-sitter/tree-sitter-julia", rev = "fc60b7cce87da7a1b7f8cb0f9371c3dc8b684500" } +source = { git = "https://github.com/tree-sitter/tree-sitter-julia", rev = "8fb38abff74652c4faddbf04d2d5bbbc6b4bae25" } [[language]] name = "java" diff --git a/runtime/queries/julia/highlights.scm b/runtime/queries/julia/highlights.scm index 9271615f..90baee21 100644 --- a/runtime/queries/julia/highlights.scm +++ b/runtime/queries/julia/highlights.scm @@ -7,13 +7,22 @@ (block_comment) ] @comment -(((identifier) @constant.builtin) (match? @constant.builtin "^(nothing|missing|Inf|NaN)$")) -(((identifier) @constant.builtin.boolean) (#eq? @constant.builtin.boolean "true")) -(((identifier) @constant.builtin.boolean) (#eq? @constant.builtin.boolean "false")) +( + ((identifier) @constant.builtin) + (#match? @constant.builtin "^(nothing|missing|undef)$")) + +[ + (true) + (false) +] @constant.builtin.boolean (integer_literal) @constant.numeric.integer (float_literal) @constant.numeric.float +( + ((identifier) @constant.numeric.float) + (#match? @constant.numeric.float "^((Inf|NaN)(16|32|64)?)$")) + (character_literal) @constant.character (escape_sequence) @constant.character.escape @@ -66,7 +75,7 @@ (type_parameter_list (identifier) @type) -(constrained_parameter +(constrained_type_parameter (identifier) @type) (subtype_clause @@ -81,13 +90,32 @@ (type_argument_list (identifier) @type) +(where_clause + (identifier) @type) + ; ------------------- ; Function definition ; ------------------- ( (function_definition - name: (identifier) @function) + name: [ + (identifier) @function + (scoped_identifier + (identifier) @namespace + (identifier) @function) + ]) + ; prevent constructors (PascalCase) to be highlighted as functions + (#match? @function "^[^A-Z]")) + +( + (short_function_definition + name: [ + (identifier) @function + (scoped_identifier + (identifier) @namespace + (identifier) @function) + ]) ; prevent constructors (PascalCase) to be highlighted as functions (#match? @function "^[^A-Z]")) @@ -101,7 +129,7 @@ (optional_parameter . (identifier) @variable.parameter) -(spread_parameter +(slurp_parameter (identifier) @variable.parameter) (function_expression @@ -185,6 +213,7 @@ [ "abstract" + "baremodule" "begin" "const" "do" @@ -198,6 +227,7 @@ "return" "struct" "type" + "where" ] @keyword ; TODO: fix this diff --git a/runtime/queries/julia/locals.scm b/runtime/queries/julia/locals.scm index 07b96f2c..70b31e50 100644 --- a/runtime/queries/julia/locals.scm +++ b/runtime/queries/julia/locals.scm @@ -21,7 +21,7 @@ (optional_parameter . (identifier) @local.definition) -(spread_parameter +(slurp_parameter (identifier) @local.definition) (function_expression @@ -33,6 +33,7 @@ [ (function_definition) + (short_function_definition) (macro_definition) ] @local.scope