refactor: derive Ruby action namespaces from Rust catalog
This commit is contained in:
+17
-4
@@ -463,15 +463,26 @@ struct Host {
|
||||
|
||||
impl Host {
|
||||
fn spawn(mode: &str, path: &Path, options: &serde_json::Value) -> Result<Self, String> {
|
||||
let mut encoded_options = FrameWriter(Vec::new());
|
||||
serde_json::to_writer(&mut encoded_options, options)
|
||||
.map_err(|error| format!("Cannot encode bounded Ruby plugin options: {error}"))?;
|
||||
#[derive(Serialize)]
|
||||
struct Startup<'a> {
|
||||
core_actions: crate::editor::CoreActionCatalog,
|
||||
options: &'a serde_json::Value,
|
||||
}
|
||||
let mut encoded_startup = FrameWriter(Vec::new());
|
||||
serde_json::to_writer(
|
||||
&mut encoded_startup,
|
||||
&Startup {
|
||||
core_actions: crate::editor::CoreActionCatalog,
|
||||
options,
|
||||
},
|
||||
)
|
||||
.map_err(|error| format!("Cannot encode bounded Ruby plugin options: {error}"))?;
|
||||
let executable = env::var_os("VAMP_RUBY").unwrap_or_else(|| "ruby".into());
|
||||
let mut command = Command::new(&executable);
|
||||
command
|
||||
.args(["-e", RUNNER, "--", mode])
|
||||
.arg(path)
|
||||
.arg(String::from_utf8(encoded_options.0).expect("JSON is UTF-8"))
|
||||
.arg(String::from_utf8(encoded_startup.0).expect("JSON is UTF-8"))
|
||||
.current_dir(path.parent().expect("absolute file has a parent"))
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
@@ -879,6 +890,8 @@ end
|
||||
"config.core.lsp_diagnostics",
|
||||
"config.core.lsp.hvoer",
|
||||
"config.core.lsp",
|
||||
"config.core.lsp.hover.tap { |action| action.name = 'core.delete' }",
|
||||
"config.core.lsp.tap { |namespace| namespace.define_singleton_method(:bogus) { namespace.hover } }.bogus",
|
||||
] {
|
||||
let invalid = fixture.file(
|
||||
"invalid_action.rb",
|
||||
|
||||
Reference in New Issue
Block a user