Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move adapters to remote #18359

Merged
merged 3 commits into from
Sep 25, 2024
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 37 additions & 17 deletions crates/languages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ workspace = true

[features]
test-support = []
load-grammars = [
"tree-sitter-bash",
"tree-sitter-c",
"tree-sitter-cpp",
"tree-sitter-css",
"tree-sitter-go",
"tree-sitter-go-mod",
"tree-sitter-gowork",
"tree-sitter-jsdoc",
"tree-sitter-json",
"tree-sitter-md",
"protols-tree-sitter-proto",
"tree-sitter-python",
"tree-sitter-regex",
"tree-sitter-rust",
"tree-sitter-typescript",
"tree-sitter-yaml",
"tree-sitter"
]

[dependencies]
anyhow.workspace = true
Expand All @@ -36,25 +55,26 @@ settings.workspace = true
smol.workspace = true
task.workspace = true
toml.workspace = true
tree-sitter-bash.workspace = true
tree-sitter-c.workspace = true
tree-sitter-cpp.workspace = true
tree-sitter-css.workspace = true
tree-sitter-go.workspace = true
tree-sitter-go-mod.workspace = true
tree-sitter-gowork.workspace = true
tree-sitter-jsdoc.workspace = true
tree-sitter-json.workspace = true
tree-sitter-md.workspace = true
protols-tree-sitter-proto.workspace = true
tree-sitter-python.workspace = true
tree-sitter-regex.workspace = true
tree-sitter-rust.workspace = true
tree-sitter-typescript.workspace = true
tree-sitter-yaml.workspace = true
tree-sitter.workspace = true
util.workspace = true

tree-sitter-bash = {workspace = true, optional = true}
tree-sitter-c = {workspace = true, optional = true}
tree-sitter-cpp = {workspace = true, optional = true}
tree-sitter-css = {workspace = true, optional = true}
tree-sitter-go = {workspace = true, optional = true}
tree-sitter-go-mod = {workspace = true, optional = true}
tree-sitter-gowork = {workspace = true, optional = true}
tree-sitter-jsdoc = {workspace = true, optional = true}
tree-sitter-json = {workspace = true, optional = true}
tree-sitter-md = {workspace = true, optional = true}
protols-tree-sitter-proto = {workspace = true, optional = true}
tree-sitter-python = {workspace = true, optional = true}
tree-sitter-regex = {workspace = true, optional = true}
tree-sitter-rust = {workspace = true, optional = true}
tree-sitter-typescript = {workspace = true, optional = true}
tree-sitter-yaml = {workspace = true, optional = true}
tree-sitter = {workspace = true, optional = true}

[dev-dependencies]
text.workspace = true
theme = { workspace = true, features = ["test-support"] }
Expand Down
17 changes: 15 additions & 2 deletions crates/languages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ mod yaml;
struct LanguageDir;

pub fn init(languages: Arc<LanguageRegistry>, node_runtime: NodeRuntime, cx: &mut AppContext) {
#[cfg(feature = "load-grammars")]
languages.register_native_grammars([
("bash", tree_sitter_bash::LANGUAGE),
("c", tree_sitter_c::LANGUAGE),
Expand Down Expand Up @@ -282,9 +283,21 @@ fn load_config(name: &str) -> LanguageConfig {
)
.unwrap();

::toml::from_str(&config_toml)
#[allow(unused_mut)]
let mut config: LanguageConfig = ::toml::from_str(&config_toml)
.with_context(|| format!("failed to load config.toml for language {name:?}"))
.unwrap()
.unwrap();

#[cfg(not(feature = "load-grammars"))]
{
config = LanguageConfig {
name: config.name,
matcher: config.matcher,
..Default::default()
}
}

config
}

fn load_queries(name: &str) -> LanguageQueries {
Expand Down
Loading
Loading