mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
rename config
This commit is contained in:
parent
34203256bf
commit
f70b7e1f07
4 changed files with 14 additions and 19 deletions
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Deserializer};
|
||||||
/// Client provided initialization options
|
/// Client provided initialization options
|
||||||
#[derive(Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "camelCase", default)]
|
#[serde(rename_all = "camelCase", default)]
|
||||||
pub struct InitializationOptions {
|
pub struct ServerConfig {
|
||||||
/// Whether the client supports our custom highlighting publishing decorations.
|
/// Whether the client supports our custom highlighting publishing decorations.
|
||||||
/// This is different to the highlightingOn setting, which is whether the user
|
/// This is different to the highlightingOn setting, which is whether the user
|
||||||
/// wants our custom highlighting to be used.
|
/// wants our custom highlighting to be used.
|
||||||
|
@ -21,13 +21,9 @@ pub struct InitializationOptions {
|
||||||
pub lru_capacity: Option<usize>,
|
pub lru_capacity: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for InitializationOptions {
|
impl Default for ServerConfig {
|
||||||
fn default() -> InitializationOptions {
|
fn default() -> ServerConfig {
|
||||||
InitializationOptions {
|
ServerConfig { publish_decorations: false, show_workspace_loaded: true, lru_capacity: None }
|
||||||
publish_decorations: false,
|
|
||||||
show_workspace_loaded: true,
|
|
||||||
lru_capacity: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +52,7 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize_init_options_defaults() {
|
fn deserialize_init_options_defaults() {
|
||||||
// check that null == default for both fields
|
// check that null == default for both fields
|
||||||
let default = InitializationOptions::default();
|
let default = ServerConfig::default();
|
||||||
assert_eq!(default, serde_json::from_str(r#"{}"#).unwrap());
|
assert_eq!(default, serde_json::from_str(r#"{}"#).unwrap());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
default,
|
default,
|
|
@ -5,11 +5,10 @@ mod main_loop;
|
||||||
mod markdown;
|
mod markdown;
|
||||||
mod project_model;
|
mod project_model;
|
||||||
pub mod req;
|
pub mod req;
|
||||||
pub mod init;
|
pub mod config;
|
||||||
mod world;
|
mod world;
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
caps::server_capabilities, init::InitializationOptions, main_loop::main_loop,
|
caps::server_capabilities, config::ServerConfig, main_loop::main_loop, main_loop::LspError,
|
||||||
main_loop::LspError,
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ use flexi_logger::{Duplicate, Logger};
|
||||||
use gen_lsp_server::{run_server, stdio_transport};
|
use gen_lsp_server::{run_server, stdio_transport};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use ra_lsp_server::{InitializationOptions, Result};
|
use ra_lsp_server::{Result, ServerConfig};
|
||||||
use ra_prof;
|
use ra_prof;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
|
@ -48,7 +48,7 @@ fn main_inner() -> Result<()> {
|
||||||
|
|
||||||
let opts = params
|
let opts = params
|
||||||
.initialization_options
|
.initialization_options
|
||||||
.and_then(|v| InitializationOptions::deserialize(v).ok())
|
.and_then(|v| ServerConfig::deserialize(v).ok())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
ra_lsp_server::main_loop(workspace_roots, params.capabilities, opts, r, s)
|
ra_lsp_server::main_loop(workspace_roots, params.capabilities, opts, r, s)
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::{
|
||||||
project_model::workspace_loader,
|
project_model::workspace_loader,
|
||||||
req,
|
req,
|
||||||
world::{Options, WorldSnapshot, WorldState},
|
world::{Options, WorldSnapshot, WorldState},
|
||||||
InitializationOptions, Result,
|
Result, ServerConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
const THREADPOOL_SIZE: usize = 8;
|
const THREADPOOL_SIZE: usize = 8;
|
||||||
|
@ -52,7 +52,7 @@ impl Error for LspError {}
|
||||||
pub fn main_loop(
|
pub fn main_loop(
|
||||||
ws_roots: Vec<PathBuf>,
|
ws_roots: Vec<PathBuf>,
|
||||||
client_caps: ClientCapabilities,
|
client_caps: ClientCapabilities,
|
||||||
options: InitializationOptions,
|
config: ServerConfig,
|
||||||
msg_receiver: &Receiver<RawMessage>,
|
msg_receiver: &Receiver<RawMessage>,
|
||||||
msg_sender: &Sender<RawMessage>,
|
msg_sender: &Sender<RawMessage>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
@ -81,10 +81,10 @@ pub fn main_loop(
|
||||||
let mut state = WorldState::new(
|
let mut state = WorldState::new(
|
||||||
ws_roots,
|
ws_roots,
|
||||||
workspaces,
|
workspaces,
|
||||||
options.lru_capacity,
|
config.lru_capacity,
|
||||||
Options {
|
Options {
|
||||||
publish_decorations: options.publish_decorations,
|
publish_decorations: config.publish_decorations,
|
||||||
show_workspace_loaded: options.show_workspace_loaded,
|
show_workspace_loaded: config.show_workspace_loaded,
|
||||||
supports_location_link: client_caps
|
supports_location_link: client_caps
|
||||||
.text_document
|
.text_document
|
||||||
.and_then(|it| it.definition)
|
.and_then(|it| it.definition)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue