From 5f2fe5fca516fa2b55d3020004ab0cec60251e89 Mon Sep 17 00:00:00 2001 From: Triton171 Date: Thu, 29 Dec 2022 16:23:40 +0100 Subject: [PATCH 01/51] Fix erroneous indent between closers of auto-pairs (#5330) inserting a newline between 2 closers of an auto-pair. --- helix-core/src/auto_pairs.rs | 2 +- helix-term/src/commands.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/helix-core/src/auto_pairs.rs b/helix-core/src/auto_pairs.rs index 072c93d0..31f9d364 100644 --- a/helix-core/src/auto_pairs.rs +++ b/helix-core/src/auto_pairs.rs @@ -17,7 +17,7 @@ pub const DEFAULT_PAIRS: &[(char, char)] = &[ ]; /// The type that represents the collection of auto pairs, -/// keyed by the opener. +/// keyed by both opener and closer. #[derive(Debug, Clone)] pub struct AutoPairs(HashMap); diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 437e11b5..7ee1d77c 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3173,8 +3173,7 @@ pub mod insert { let on_auto_pair = doc .auto_pairs(cx.editor) .and_then(|pairs| pairs.get(prev)) - .and_then(|pair| if pair.close == curr { Some(pair) } else { None }) - .is_some(); + .map_or(false, |pair| pair.open == prev && pair.close == curr); let local_offs = if on_auto_pair { let inner_indent = indent.clone() + doc.indent_style.as_str(); From 3fe3f2c4ee1c483ad2d1f31dc34e33f15fc977db Mon Sep 17 00:00:00 2001 From: Yevgnen Date: Thu, 29 Dec 2022 23:24:03 +0800 Subject: [PATCH 02/51] Update `emacs` theme diff colors (#5334) --- runtime/themes/emacs.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/themes/emacs.toml b/runtime/themes/emacs.toml index cc725df8..b3a46b92 100644 --- a/runtime/themes/emacs.toml +++ b/runtime/themes/emacs.toml @@ -72,9 +72,9 @@ "ui.cursorline.primary" = { bg = "darkseagreen2" } "ui.cursorline.secondary" = { bg = "darkseagreen2" } -"diff.plus" = { fg = "#22aa22", bg = "#eeffee" } -"diff.delta" = { fg = "#aaaa22", bg = "#ffffcc" } -"diff.minus" = { fg = "#aa2222", bg = "#ffdddd" } +"diff.plus" = { fg = "green3" } +"diff.delta" = { fg = "orange2" } +"diff.minus" = { fg = "red2" } "error" = { fg = "red1" } "warning" = { fg = "dark_orange" } From 9d15b852093480d852e47dd9f0157828c2130298 Mon Sep 17 00:00:00 2001 From: willful759 <30967965+willful759@users.noreply.github.com> Date: Thu, 29 Dec 2022 09:51:23 -0600 Subject: [PATCH 03/51] Reload language config with `:config-reload` (#5239) --- helix-term/src/application.rs | 57 +++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 5f013b9a..83e853b1 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -397,38 +397,49 @@ impl Application { self.editor.refresh_config(); } + /// refresh language config after config change + fn refresh_language_config(&mut self) -> Result<(), Error> { + let syntax_config = helix_core::config::user_syntax_loader() + .map_err(|err| anyhow::anyhow!("Failed to load language config: {}", err))?; + + self.syn_loader = std::sync::Arc::new(syntax::Loader::new(syntax_config)); + for document in self.editor.documents.values_mut() { + document.detect_language(self.syn_loader.clone()); + } + + Ok(()) + } + /// Refresh theme after config change - fn refresh_theme(&mut self, config: &Config) { + fn refresh_theme(&mut self, config: &Config) -> Result<(), Error> { if let Some(theme) = config.theme.clone() { let true_color = self.true_color(); - match self.theme_loader.load(&theme) { - Ok(theme) => { - if true_color || theme.is_16_color() { - self.editor.set_theme(theme); - } else { - self.editor - .set_error("theme requires truecolor support, which is not available"); - } - } - Err(err) => { - let err_string = format!("failed to load theme `{}` - {}", theme, err); - self.editor.set_error(err_string); - } + let theme = self + .theme_loader + .load(&theme) + .map_err(|err| anyhow::anyhow!("Failed to load theme `{}`: {}", theme, err))?; + + if true_color || theme.is_16_color() { + self.editor.set_theme(theme); + } else { + anyhow::bail!("theme requires truecolor support, which is not available") } } + + Ok(()) } fn refresh_config(&mut self) { - match Config::load_default() { - Ok(config) => { - self.refresh_theme(&config); + let mut refresh_config = || -> Result<(), Error> { + let default_config = Config::load_default() + .map_err(|err| anyhow::anyhow!("Failed to load config: {}", err))?; + self.refresh_language_config()?; + self.refresh_theme(&default_config)?; + Ok(()) + }; - // Store new config - self.config.store(Arc::new(config)); - } - Err(err) => { - self.editor.set_error(err.to_string()); - } + if let Err(err) = refresh_config() { + self.editor.set_error(err.to_string()); } } From 6c9541148873ff5350bf082ace3b04f2efe52dcd Mon Sep 17 00:00:00 2001 From: iobtl <59901837+iobtl@users.noreply.github.com> Date: Fri, 30 Dec 2022 00:13:06 +0800 Subject: [PATCH 04/51] Expand `~` when parsing file paths in `:open` (#5329) --- helix-term/src/commands/typed.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index c2ca1a47..5c0cd654 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -65,6 +65,7 @@ fn open(cx: &mut compositor::Context, args: &[Cow], event: PromptEvent) -> ensure!(!args.is_empty(), "wrong argument count"); for arg in args { let (path, pos) = args::parse_file(arg); + let path = helix_core::path::expand_tilde(&path); // If the path is a directory, open a file picker on that directory and update the status // message if let Ok(true) = std::fs::canonicalize(&path).map(|p| p.is_dir()) { From 6f8f9cac9a05bb986a3b5d141104563de3528e29 Mon Sep 17 00:00:00 2001 From: k12ish <45272873+k12ish@users.noreply.github.com> Date: Fri, 30 Dec 2022 14:09:15 +0000 Subject: [PATCH 05/51] Add bash syntax highlighting for `.bash_aliases` (#5347) --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 53f65be7..75ab4951 100644 --- a/languages.toml +++ b/languages.toml @@ -537,7 +537,7 @@ source = { git = "https://github.com/tree-sitter/tree-sitter-ruby", rev = "4c600 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"] +file-types = ["sh", "bash", "zsh", ".bash_login", ".bash_logout", ".bash_profile", ".bashrc", ".profile", ".zshenv", ".zlogin", ".zlogout", ".zprofile", ".zshrc", "APKBUILD", "PKGBUILD", "eclass", "ebuild", "bazelrc", ".bash_aliases"] shebangs = ["sh", "bash", "dash", "zsh"] roots = [] comment-token = "#" From b813b1a659e39fbe4c1a757ec837a132c6fadbf9 Mon Sep 17 00:00:00 2001 From: mrjerzy <36932167+mrjerzy@users.noreply.github.com> Date: Fri, 30 Dec 2022 15:11:06 +0100 Subject: [PATCH 06/51] Add tutor example for WORDS (#5304) --- runtime/tutor | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/runtime/tutor b/runtime/tutor index 408f7451..8336a516 100644 --- a/runtime/tutor +++ b/runtime/tutor @@ -271,17 +271,17 @@ _________________________________________________________________ whitespace, whereas words can be separated by other characters in addition to whitespace. - All of these motions select the text they traverse. - - - - - - - - - - + 1. Move the cursor to the beginning of the line marked with '-->'. + 2. Type w repeatedly to select individual words until you + reach the end of the line. + 3. Note that 'one-of-a-kind' required 7 keystrokes to be + traversed. '"modal"' required 3 keystrokes. + 4. Move the cursor back to beginning of the line marked '-->'. + 5. Type W repeatedly to select individual WORDS. + 6. Note that 'one-of-a-kind' and '"modal"' have been selected + both with one keystroke each. + +--> Helix is a one-of-a-kind "modal" text editor ================================================================= From 63dcaae1b9083396fb3faaef9eaa2421f7e48fb9 Mon Sep 17 00:00:00 2001 From: jliaoh <48660001+hunterliao29@users.noreply.github.com> Date: Fri, 30 Dec 2022 09:15:30 -0500 Subject: [PATCH 07/51] Fix theme inheritance for default themes (#5218) --- helix-view/src/theme.rs | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index b2c8a79f..cb0d3ac4 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -14,15 +14,23 @@ use toml::{map::Map, Value}; use crate::graphics::UnderlineStyle; pub use crate::graphics::{Color, Modifier, Style}; +pub static DEFAULT_THEME_DATA: Lazy = Lazy::new(|| { + toml::from_slice(include_bytes!("../../theme.toml")).expect("Failed to parse default theme") +}); + +pub static BASE16_DEFAULT_THEME_DATA: Lazy = Lazy::new(|| { + toml::from_slice(include_bytes!("../../base16_theme.toml")) + .expect("Failed to parse base 16 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") + ..Theme::from(DEFAULT_THEME_DATA.clone()) }); 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") + name: "base16_default".into(), + ..Theme::from(BASE16_DEFAULT_THEME_DATA.clone()) }); #[derive(Clone, Debug)] @@ -78,11 +86,16 @@ impl Loader { ) })?; - let parent_theme_toml = self.load_theme( - parent_theme_name, - base_them_name, - base_them_name == parent_theme_name, - )?; + let parent_theme_toml = match parent_theme_name { + // load default themes's toml from const. + "default" => DEFAULT_THEME_DATA.clone(), + "base16_default" => BASE16_DEFAULT_THEME_DATA.clone(), + _ => self.load_theme( + parent_theme_name, + base_them_name, + base_them_name == parent_theme_name, + )?, + }; self.merge_themes(parent_theme_toml, theme_toml) } else { From c9ed42cdec95b67b0d0ed15218daff37358ca86f Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 31 Dec 2022 19:48:14 +0530 Subject: [PATCH 08/51] Add a status line element that shows just the basename of the file (#5318) --- book/src/configuration.md | 1 + helix-term/src/ui/statusline.rs | 21 +++++++++++++++++++++ helix-view/src/editor.rs | 5 ++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index 0890d283..a35482e6 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -97,6 +97,7 @@ The following statusline elements can be configured: | `mode` | The current editor mode (`mode.normal`/`mode.insert`/`mode.select`) | | `spinner` | A progress spinner indicating LSP activity | | `file-name` | The path/name of the opened file | +| `file-base-name` | The basename of the opened file | | `file-encoding` | The encoding of the opened file if it differs from UTF-8 | | `file-line-ending` | The file line endings (CRLF or LF) | | `total-line-numbers` | The total line numbers of the opened file | diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index 501faea3..a25b4540 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -139,6 +139,7 @@ where match element_id { helix_view::editor::StatusLineElement::Mode => render_mode, helix_view::editor::StatusLineElement::Spinner => render_lsp_spinner, + helix_view::editor::StatusLineElement::FileBaseName => render_file_base_name, helix_view::editor::StatusLineElement::FileName => render_file_name, helix_view::editor::StatusLineElement::FileEncoding => render_file_encoding, helix_view::editor::StatusLineElement::FileLineEnding => render_file_line_ending, @@ -426,6 +427,26 @@ where write(context, title, None); } +fn render_file_base_name(context: &mut RenderContext, write: F) +where + F: Fn(&mut RenderContext, String, Option