From 14cd995ba23c338ce471004e7ebaa24b23c92234 Mon Sep 17 00:00:00 2001 From: mattwparas Date: Fri, 5 Jul 2024 13:11:02 -0700 Subject: [PATCH] update instructions, include steel submodule --- .gitmodules | 3 +++ STEEL.md | 31 ++++++--------------- helix-term/src/commands.rs | 4 +++ steel | 1 + xtask/src/main.rs | 55 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 23 deletions(-) create mode 100644 .gitmodules create mode 160000 steel diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..a301bb907 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "steel"] + path = steel + url = https://github.com/mattwparas/steel.git diff --git a/STEEL.md b/STEEL.md index 012d937ad..9729ffd3c 100644 --- a/STEEL.md +++ b/STEEL.md @@ -1,42 +1,27 @@ # Building -You will need a handful of things: +You will need: * A clone of this fork, on the branch `steel-event-system` -* A clone of the steel git repo -> https://github.com/mattwparas/steel, on the branch `master` (default) -I also cannot promise that this will work on windows. I develop off of ubuntu and mac, so for now you can probably safely assume it will work on unix. - -The `Cargo.toml` for helix points to a local development version of steel. Set this up so that it points to wherever you've cloned steel: - -``` -[workspace.dependencies] -# CHANGE 'path = ...' to point to the path to steel-core -steel-core = { path = "/home/matt/code/scratch/steel/crates/steel-core", version = "0.6.0", features = ["anyhow", "dylibs"] } -``` - -Since I'm actively developing steel alongside the helix integration in order to make things as smooth as possible, its not referencing a published version yet. - -## Installing Steel - -Follow the instructions here https://github.com/mattwparas/steel and https://github.com/mattwparas/steel/issues/71 - -Setting a `STEEL_HOME` env var, then running `cargo run -- cogs/install.scm` in the root of that repo will set up the steel core libraries so that helix can reference them. +`steel` is included as a git submodule for ease of building. ## Installing helix -Once you're set up with steel, just run +Just run + +`cargo xtask steel` -`cargo install --path helix-term --locked` +To install the `hx` executable, with steel as a plugin language. This also includes: -To install the `hx` executable, with steel as the plugin language. +The `steel` executable, the steel language server, the steel dylib installer, and the steel standard library. ## Setting up configurations for helix Note, this API is entirely subjet to change, and I promise absolutely 0 backwards compatibility while this is in development. -There are 2 important files you'll want: +There are 2 important files you'll want, which should be auto generated during the installation process: * `~/.config/helix/helix.scm` * `~/.config/helix/init.scm` diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index f0e95aba7..472b4ec5c 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -13,6 +13,10 @@ use helix_vcs::{FileChange, Hunk}; pub use lsp::*; pub use engine::ScriptingEngine; + +#[cfg(feature = "steel")] +pub use engine::steel::{helix_module_file, steel_init_file}; + use tui::{ text::Span, widgets::{Cell, Row}, diff --git a/steel b/steel new file mode 160000 index 000000000..b1618afc5 --- /dev/null +++ b/steel @@ -0,0 +1 @@ +Subproject commit b1618afc56ab755360222ecbf720f0ebfa6806ca diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 92af73532..d71343f8c 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -15,6 +15,8 @@ pub mod tasks { use crate::querycheck::query_check; use crate::DynError; + use std::path::{Path, PathBuf}; + pub fn docgen() -> Result<(), DynError> { write(TYPABLE_COMMANDS_MD_OUTPUT, &typable_commands()?); write(LANG_SUPPORT_MD_OUTPUT, &lang_features()?); @@ -30,7 +32,60 @@ pub mod tasks { } pub fn install_steel() { + fn workspace_dir() -> PathBuf { + let output = std::process::Command::new(env!("CARGO")) + .arg("locate-project") + .arg("--workspace") + .arg("--message-format=plain") + .output() + .unwrap() + .stdout; + let cargo_path = Path::new(std::str::from_utf8(&output).unwrap().trim()); + cargo_path.parent().unwrap().to_path_buf() + } + + // Update the steel submodule + std::process::Command::new("git") + .args(["submodule", "init"]) + .spawn() + .unwrap() + .wait() + .unwrap(); + + std::process::Command::new("git") + .args(["submodule", "foreach", "git", "pull", "origin", "master"]) + .spawn() + .unwrap() + .wait() + .unwrap(); + + let mut workspace_dir = workspace_dir(); + + workspace_dir.push("steel"); + + std::process::Command::new("cargo") + .args(["xtask", "install"]) + .current_dir(workspace_dir) + .spawn() + .unwrap() + .wait() + .unwrap(); + + println!("=> Finished installing steel"); + code_gen(); + + let helix_scm_path = helix_term::commands::helix_module_file(); + let steel_init_path = helix_term::commands::steel_init_file(); + + if !helix_scm_path.exists() { + std::fs::File::create(helix_scm_path).expect("Unable to create new helix.scm file!"); + } + + if !steel_init_path.exists() { + std::fs::File::create(steel_init_path).expect("Unable to create new init.scm file!"); + } + std::process::Command::new("cargo") .args(["install", "--path", "helix-term", "--locked", "--force"]) .spawn()