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

syntax-highlighter: load all tree-sitter highlight configurations at startup #50394

Merged
merged 1 commit into from
Apr 5, 2023
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
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"cody.codebase": "github.com/sourcegraph/sourcegraph"
"cody.codebase": "github.com/sourcegraph/sourcegraph",
"rust-analyzer.linkedProjects": ["docker-images/syntax-highlighter/Cargo.toml"]
}
1 change: 1 addition & 0 deletions docker-images/syntax-highlighter/Cargo.lock

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

2 changes: 1 addition & 1 deletion docker-images/syntax-highlighter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rustyline = "9.1.2"

sg-syntax = { path = "./crates/sg-syntax" }
scip-treesitter = { path = "./crates/scip-treesitter" }

scip-treesitter-languages = { path = "./crates/scip-treesitter-languages" }
# March 20, 2023 - Pinned explicitly with features that match the features
# required by rocket. Once bazel rules correctly roll up all the features,
# we can remove this, but until then, this works just fine for building
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ macro_rules! create_configurations {
}

lazy_static::lazy_static! {
static ref CONFIGURATIONS: HashMap<BundledParser, HighlightConfiguration> = {
pub static ref CONFIGURATIONS: HashMap<BundledParser, HighlightConfiguration> = {
// NOTE: typescript/tsx crates are included, even though not listed below.

// You can add any new crate::parsers::Parser variants here.
Expand Down
6 changes: 6 additions & 0 deletions docker-images/syntax-highlighter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ fn not_found() -> JsonValue {

#[launch]
fn rocket() -> _ {
// load configurations on-startup instead of on-first-request.
// TODO: load individual languages lazily on-request instead, currently
// CONFIGURATIONS.get will load every configured configuration together.
scip_treesitter_languages::highlights::CONFIGURATIONS
.get(&scip_treesitter_languages::parsers::BundledParser::Go);

// Only list features if QUIET != "true"
match std::env::var("QUIET") {
Ok(v) if v == "true" => {}
Expand Down