aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorTamo2021-12-26 01:04:33 +0000
committerGitHub2021-12-26 01:04:33 +0000
commita306a1052a51c686b24a6f339190878b8029a894 (patch)
treefd90aed859d8ee645ec8c10d87373508d215a628 /helix-term/src/commands.rs
parent6af0d51dc5510be43dd6688ee1053ce01b601d83 (diff)
Update settings at runtime (#798)
* feat: Update settings at runtime fix the clippy warning * update the documentation * use to_value instead of to_vec+from_value * drop the equal * remove an useless comment * apply suggestion
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index ee6a5989..7b1235f8 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -2637,6 +2637,36 @@ pub mod cmd {
let (view, doc) = current!(cx.editor);
view.ensure_cursor_in_view(doc, line);
+ Ok(())
+ }
+
+ fn setting(
+ cx: &mut compositor::Context,
+ args: &[Cow<str>],
+ _event: PromptEvent,
+ ) -> anyhow::Result<()> {
+ let runtime_config = &mut cx.editor.config;
+
+ if args.len() != 2 {
+ anyhow::bail!("Bad arguments. Usage: `:set key field`");
+ }
+
+ let (key, arg) = (&args[0].to_lowercase(), &args[1]);
+
+ match key.as_ref() {
+ "scrolloff" => runtime_config.scrolloff = arg.parse()?,
+ "scroll-lines" => runtime_config.scroll_lines = arg.parse()?,
+ "mouse" => runtime_config.mouse = arg.parse()?,
+ "line-number" => runtime_config.line_number = arg.parse()?,
+ "middle-click_paste" => runtime_config.middle_click_paste = arg.parse()?,
+ "smart-case" => runtime_config.smart_case = arg.parse()?,
+ "auto-pairs" => runtime_config.auto_pairs = arg.parse()?,
+ "auto-completion" => runtime_config.auto_completion = arg.parse()?,
+ "completion-trigger-len" => runtime_config.completion_trigger_len = arg.parse()?,
+ "auto-info" => runtime_config.auto_info = arg.parse()?,
+ "true-color" => runtime_config.true_color = arg.parse()?,
+ _ => anyhow::bail!("Unknown key `{}`.", args[0]),
+ }
Ok(())
}
@@ -2928,6 +2958,13 @@ pub mod cmd {
doc: "Go to line number.",
fun: goto_line_number,
completer: None,
+ },
+ TypableCommand {
+ name: "set-option",
+ aliases: &["set"],
+ doc: "Set a config option at runtime",
+ fun: setting,
+ completer: Some(completers::setting),
}
];