Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ languages = ["Ruby", "ERB"]
name = "Rubocop"
languages = ["Ruby"]

[language_servers.standard]
name = "Standard"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering whether to call this Standard Ruby to avoid confusion with https://github.com/standard.

languages = ["Ruby"]

[grammars.ruby]
repository = "https://github.com/tree-sitter/tree-sitter-ruby"
commit = "71bd32fb7607035768799732addba884a37a6210"
Expand Down
2 changes: 2 additions & 0 deletions src/language_servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ mod language_server;
mod rubocop;
mod ruby_lsp;
mod solargraph;
mod standard;

pub use language_server::LanguageServer;
pub use rubocop::*;
pub use ruby_lsp::*;
pub use solargraph::*;
pub use standard::*;
43 changes: 43 additions & 0 deletions src/language_servers/standard.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use super::LanguageServer;

pub struct Standard {}

impl LanguageServer for Standard {
const SERVER_ID: &str = "standard";
const EXECUTABLE_NAME: &str = "standardrb";

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

impl Standard {
pub fn new() -> Self {
Self {}
}
}

#[cfg(test)]
mod tests {
use crate::language_servers::{LanguageServer, Standard};

#[test]
fn test_server_id() {
assert_eq!(Standard::SERVER_ID, "standard");
}

#[test]
fn test_executable_name() {
assert_eq!(Standard::EXECUTABLE_NAME, "standardrb");
}

#[test]
fn test_executable_args() {
assert_eq!(Standard::get_executable_args(), vec!["--lsp"]);
}

#[test]
fn test_default_use_bundler() {
assert!(Standard::default_use_bundler());
}
}
7 changes: 6 additions & 1 deletion src/ruby.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod language_servers;
use language_servers::{LanguageServer, Rubocop, RubyLsp, Solargraph};
use language_servers::{LanguageServer, Rubocop, RubyLsp, Solargraph, Standard};

use zed::lsp::{Completion, Symbol};
use zed::settings::LspSettings;
Expand All @@ -11,6 +11,7 @@ struct RubyExtension {
solargraph: Option<Solargraph>,
ruby_lsp: Option<RubyLsp>,
rubocop: Option<Rubocop>,
standard: Option<Standard>,
}

impl zed::Extension for RubyExtension {
Expand All @@ -36,6 +37,10 @@ impl zed::Extension for RubyExtension {
let rubocop = self.rubocop.get_or_insert_with(Rubocop::new);
rubocop.language_server_command(language_server_id, worktree)
}
Standard::SERVER_ID => {
let standard = self.standard.get_or_insert_with(Standard::new);
standard.language_server_command(language_server_id, worktree)
}
language_server_id => Err(format!("unknown language server: {language_server_id}")),
}
}
Expand Down