From c65a12a553c5c5b4d8dd942d57e7beb7ceddbd17 Mon Sep 17 00:00:00 2001 From: wojciechkepka Date: Sat, 19 Jun 2021 13:27:32 +0200 Subject: [PATCH] Add `:theme ` command --- helix-term/src/commands.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 1243a86f32cd..1e8b1d6d688d 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1312,6 +1312,17 @@ mod cmd { quit_all_impl(editor, args, event, true) } + fn theme(editor: &mut Editor, args: &[&str], event: PromptEvent) { + let theme = if let Some(theme) = args.first() { + theme + } else { + editor.set_error("theme name not provided".into()); + return; + }; + + editor.set_theme_from_name(theme); + } + pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ TypableCommand { name: "quit", @@ -1425,6 +1436,13 @@ mod cmd { fun: force_quit_all, completer: None, }, + TypableCommand { + name: "theme", + alias: None, + doc: "Change the theme of current view. Requires theme name as argument (:theme )", + fun: theme, + completer: Some(completers::theme), + }, ]; @@ -2847,7 +2865,7 @@ fn hover(cx: &mut Context) { // skip if contents empty - let contents = ui::Markdown::new(contents); + let contents = ui::Markdown::new(contents, editor.syn_loader.clone()); let mut popup = Popup::new(contents); compositor.push(Box::new(popup)); }