From 15886dec3f37bd93ee6dcd49fbd1fc279aead510 Mon Sep 17 00:00:00 2001 From: mattwparas Date: Wed, 31 May 2023 06:24:31 -0700 Subject: [PATCH] more integration --- Cargo.lock | 12 +----------- Cargo.toml | 1 - helix-term/src/commands/engine.rs | 23 +++++++++++++++++++++-- helix-term/src/commands/typed.rs | 6 +++--- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37f9439c6..f049027b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -500,17 +500,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "custom-commands" -version = "0.1.0" -dependencies = [ - "anyhow", - "helix-core", - "helix-term", - "helix-view", - "steel-core", -] - [[package]] name = "cxx" version = "1.0.94" @@ -2662,6 +2651,7 @@ dependencies = [ "thiserror", "ureq", "weak-table", + "which", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 1ebd46e1b..48f83d965 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ members = [ "helix-loader", "helix-vcs", "helix-parsec", - "custom-commands", "xtask", ] diff --git a/helix-term/src/commands/engine.rs b/helix-term/src/commands/engine.rs index bf59c2f68..34dc9ecd9 100644 --- a/helix-term/src/commands/engine.rs +++ b/helix-term/src/commands/engine.rs @@ -25,7 +25,7 @@ use crate::{ compositor::{self, Component, Compositor}, job::{self, Callback}, keymap::{merge_keys, Keymap}, - ui::{self, overlay::overlaid, Popup, PromptEvent}, + ui::{self, menu::Item, overlay::overlaid, Popup, PromptEvent}, }; use super::{ @@ -127,6 +127,23 @@ impl StatusLineMessage { } } +impl Item for SteelVal { + type Data = (); + + // TODO: This shouldn't copy the data every time + fn format(&self, _data: &Self::Data) -> tui::widgets::Row { + let formatted = self.to_string(); + + formatted + .strip_prefix("\"") + .unwrap_or(&formatted) + .strip_suffix("\"") + .unwrap_or(&formatted) + .to_owned() + .into() + } +} + /// In order to send events from the engine back to the configuration, we can created a shared /// queue that the engine and the config push and pull from. Alternatively, we could use a channel /// directly, however this was easy enough to set up. @@ -547,7 +564,7 @@ impl Component for BoxDynComponent { fn configure_engine() -> std::rc::Rc> { let mut engine = steel::steel_vm::engine::Engine::new(); - println!("Loading engine!"); + log::info!("Loading engine!"); // Load native modules from the directory. Another idea - have a separate dlopen loading system // in place that does not use the type id, and instead we generate the module after the dylib @@ -620,6 +637,8 @@ fn configure_engine() -> std::rc::Rc| todo!()); + // engine.register_fn( // "Picker::new", // |contents: &mut Wrapped diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index acb80e060..6638b532f 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -2905,12 +2905,12 @@ pub(super) fn command_mode(cx: &mut Context) { // TODO: @Matt - Add completion for added scripting commands here // Handle typable commands + + // Register callback functions here - if the prompt event is validate, + // Grab the function run and run through the hooks. if let Some(cmd) = typed::TYPABLE_COMMAND_MAP.get(parts[0]) { let shellwords = Shellwords::from(input); let args = shellwords.words(); - - log::warn!("calling builtin: {}...", parts[0]); - if let Err(e) = (cmd.fun)(cx, &args[1..], event) { cx.editor.set_error(format!("{}", e)); }