Skip to content

Commit 67d8485

Browse files
committed
Add example of using new process API
1 parent a910ec7 commit 67d8485

File tree

6 files changed

+16
-5
lines changed

6 files changed

+16
-5
lines changed

Cargo.lock

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ path = "src/ruby.rs"
1010
crate-type = ["cdylib"]
1111

1212
[dependencies]
13-
zed_extension_api = "0.2.0"
13+
zed_extension_api = { path = "../zed/crates/extension_api" }

src/language_servers/language_server.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use zed_extension_api::{self as zed, settings::LspSettings, LanguageServerId, Result};
1+
use zed_extension_api::{
2+
self as zed, process::Command, settings::LspSettings, LanguageServerId, Result,
3+
};
24

35
#[derive(Clone, Debug)]
46
pub struct LanguageServerBinary {
@@ -9,6 +11,7 @@ pub struct LanguageServerBinary {
911
pub trait LanguageServer {
1012
const SERVER_ID: &str;
1113
const EXECUTABLE_NAME: &str;
14+
const GEM_NAME: &str;
1215

1316
fn default_use_bundler() -> bool {
1417
true // Default for most LSPs except Ruby LSP
@@ -37,6 +40,12 @@ pub trait LanguageServer {
3740
language_server_id: &LanguageServerId,
3841
worktree: &zed::Worktree,
3942
) -> Result<LanguageServerBinary> {
43+
let output = Command::new("ls").output()?;
44+
45+
dbg!(&output.status);
46+
dbg!(String::from_utf8_lossy(&output.stdout).to_string());
47+
dbg!(String::from_utf8_lossy(&output.stderr).to_string());
48+
4049
let lsp_settings = LspSettings::for_worktree(language_server_id.as_ref(), worktree)?;
4150

4251
if let Some(binary_settings) = lsp_settings.binary {
@@ -88,6 +97,7 @@ mod tests {
8897
impl LanguageServer for TestServer {
8998
const SERVER_ID: &'static str = "test-server";
9099
const EXECUTABLE_NAME: &'static str = "test-exe";
100+
const GEM_NAME: &'static str = "test";
91101

92102
fn get_executable_args() -> Vec<String> {
93103
vec!["--test-arg".into()]

src/language_servers/rubocop.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub struct Rubocop {}
55
impl LanguageServer for Rubocop {
66
const SERVER_ID: &str = "rubocop";
77
const EXECUTABLE_NAME: &str = "rubocop";
8+
const GEM_NAME: &str = "rubocop";
89

910
fn get_executable_args() -> Vec<String> {
1011
vec!["--lsp".to_string()]

src/language_servers/ruby_lsp.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub struct RubyLsp {}
1010
impl LanguageServer for RubyLsp {
1111
const SERVER_ID: &str = "ruby-lsp";
1212
const EXECUTABLE_NAME: &str = "ruby-lsp";
13+
const GEM_NAME: &str = "ruby-lsp";
1314

1415
fn default_use_bundler() -> bool {
1516
false

src/language_servers/solargraph.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub struct Solargraph {}
99
impl LanguageServer for Solargraph {
1010
const SERVER_ID: &str = "solargraph";
1111
const EXECUTABLE_NAME: &str = "solargraph";
12+
const GEM_NAME: &str = "solargraph";
1213

1314
fn get_executable_args() -> Vec<String> {
1415
vec!["stdio".to_string()]

0 commit comments

Comments
 (0)