Skip to content

Commit

Permalink
Fetch server config after initilalization instead of getting it in `I…
Browse files Browse the repository at this point in the history
…nitializationOptions`
  • Loading branch information
SpontanCombust committed Aug 16, 2024
1 parent dd4d013 commit 9fc6a27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
12 changes: 3 additions & 9 deletions crates/lsp/src/providers/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ use crate::{notifications, Backend};
#[serde(rename_all = "camelCase")]
struct InitializationOptions {
rayon_threads: i32,
native_content_path: PathBuf,
game_directory: PathBuf,
content_repositories: Vec<PathBuf>,
enable_syntax_analysis: bool
native_content_path: PathBuf
}

impl Backend {
Expand Down Expand Up @@ -55,11 +52,6 @@ impl Backend {
self.reporter.log_error("Invalid native_content_path").await;
}
}

let mut config = self.config.write().await;
config.game_directory = val.game_directory;
config.content_repositories = val.content_repositories;
config.enable_syntax_analysis = val.enable_syntax_analysis;
},
Err(err) => {
self.reporter.log_error(format!("InitializationOptions deserialization fail: {}", err)).await;
Expand Down Expand Up @@ -162,6 +154,8 @@ impl Backend {
register_options: None
}
]).await.unwrap();

self.fetch_config().await;

self.setup_workspace_content_scanners().await;
self.setup_repository_content_scanners().await;
Expand Down
10 changes: 2 additions & 8 deletions editors/vscode/src/lsp/lang_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ export async function createLanguageClient(ctx: vscode.ExtensionContext, cfg: co

const initializationOptions: InitializationOptions = {
rayonThreads: cfg.rayonThreads,
nativeContentPath: nativeContentPath,
gameDirectory: cfg.gameDirectory,
contentRepositories: cfg.contentRepositories,
enableSyntaxAnalysis: cfg.enableSyntaxAnalysis
nativeContentPath: nativeContentPath
};

const clientOptions: lsp.LanguageClientOptions = {
Expand Down Expand Up @@ -93,10 +90,7 @@ export async function createLanguageClient(ctx: vscode.ExtensionContext, cfg: co
// Configuration needed by the server. The format in both client and server must match!
interface InitializationOptions {
rayonThreads: number,
nativeContentPath: string,
gameDirectory: string,
contentRepositories: string[]
enableSyntaxAnalysis: boolean
nativeContentPath: string
}


Expand Down

0 comments on commit 9fc6a27

Please sign in to comment.