mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Add showWorkspaceLoadedNotification to vscode client
This allows users to control whether or not they want to see the "workspace loaded" notification. This is done on the server side using InitializationOptions which are provided by the client. By default show_workspace_loaded is true, meaning the notification is sent.
This commit is contained in:
parent
ce118da149
commit
0dcb1cb569
8 changed files with 78 additions and 22 deletions
|
@ -2,7 +2,7 @@ use serde::Deserialize;
|
|||
use flexi_logger::{Duplicate, Logger};
|
||||
use gen_lsp_server::{run_server, stdio_transport};
|
||||
|
||||
use ra_lsp_server::Result;
|
||||
use ra_lsp_server::{Result, InitializationOptions};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
::std::env::set_var("RUST_BACKTRACE", "short");
|
||||
|
@ -24,26 +24,18 @@ fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct InitializationOptions {
|
||||
// Whether the client supports our custom highlighting publishing decorations.
|
||||
// This is different to the highlightingOn setting, which is whether the user
|
||||
// wants our custom highlighting to be used.
|
||||
publish_decorations: Option<bool>,
|
||||
}
|
||||
|
||||
fn main_inner() -> Result<()> {
|
||||
let (receiver, sender, threads) = stdio_transport();
|
||||
let cwd = ::std::env::current_dir()?;
|
||||
run_server(ra_lsp_server::server_capabilities(), receiver, sender, |params, r, s| {
|
||||
let root = params.root_uri.and_then(|it| it.to_file_path().ok()).unwrap_or(cwd);
|
||||
let supports_decorations = params
|
||||
|
||||
let opts = params
|
||||
.initialization_options
|
||||
.and_then(|v| InitializationOptions::deserialize(v).ok())
|
||||
.and_then(|it| it.publish_decorations)
|
||||
== Some(true);
|
||||
ra_lsp_server::main_loop(root, supports_decorations, r, s)
|
||||
.unwrap_or(InitializationOptions::default());
|
||||
|
||||
ra_lsp_server::main_loop(root, opts, r, s)
|
||||
})?;
|
||||
log::info!("shutting down IO...");
|
||||
threads.join()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue