aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-08-06 12:12:58 +0100
committerAleksey Kladov <[email protected]>2019-08-06 13:28:31 +0100
commitf70b7e1f079e7b4a51ddd6503860eb97f1a6fcbe (patch)
tree5f9eb02484391d9780c06a3d0ecb52ef5b4bdbce
parent34203256bf8f8ea12b233e0fb49b42bd8c423281 (diff)
rename config
-rw-r--r--crates/ra_lsp_server/src/config.rs (renamed from crates/ra_lsp_server/src/init.rs)14
-rw-r--r--crates/ra_lsp_server/src/lib.rs5
-rw-r--r--crates/ra_lsp_server/src/main.rs4
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs10
4 files changed, 14 insertions, 19 deletions
diff --git a/crates/ra_lsp_server/src/init.rs b/crates/ra_lsp_server/src/config.rs
index b894b449d..a16cc292e 100644
--- a/crates/ra_lsp_server/src/init.rs
+++ b/crates/ra_lsp_server/src/config.rs
@@ -3,7 +3,7 @@ use serde::{Deserialize, Deserializer};
3/// Client provided initialization options 3/// Client provided initialization options
4#[derive(Deserialize, Clone, Copy, Debug, PartialEq, Eq)] 4#[derive(Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
5#[serde(rename_all = "camelCase", default)] 5#[serde(rename_all = "camelCase", default)]
6pub struct InitializationOptions { 6pub struct ServerConfig {
7 /// Whether the client supports our custom highlighting publishing decorations. 7 /// Whether the client supports our custom highlighting publishing decorations.
8 /// This is different to the highlightingOn setting, which is whether the user 8 /// This is different to the highlightingOn setting, which is whether the user
9 /// wants our custom highlighting to be used. 9 /// wants our custom highlighting to be used.
@@ -21,13 +21,9 @@ pub struct InitializationOptions {
21 pub lru_capacity: Option<usize>, 21 pub lru_capacity: Option<usize>,
22} 22}
23 23
24impl Default for InitializationOptions { 24impl Default for ServerConfig {
25 fn default() -> InitializationOptions { 25 fn default() -> ServerConfig {
26 InitializationOptions { 26 ServerConfig { publish_decorations: false, show_workspace_loaded: true, lru_capacity: None }
27 publish_decorations: false,
28 show_workspace_loaded: true,
29 lru_capacity: None,
30 }
31 } 27 }
32} 28}
33 29
@@ -56,7 +52,7 @@ mod test {
56 #[test] 52 #[test]
57 fn deserialize_init_options_defaults() { 53 fn deserialize_init_options_defaults() {
58 // check that null == default for both fields 54 // check that null == default for both fields
59 let default = InitializationOptions::default(); 55 let default = ServerConfig::default();
60 assert_eq!(default, serde_json::from_str(r#"{}"#).unwrap()); 56 assert_eq!(default, serde_json::from_str(r#"{}"#).unwrap());
61 assert_eq!( 57 assert_eq!(
62 default, 58 default,
diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs
index 2ae6300c8..795f86383 100644
--- a/crates/ra_lsp_server/src/lib.rs
+++ b/crates/ra_lsp_server/src/lib.rs
@@ -5,11 +5,10 @@ mod main_loop;
5mod markdown; 5mod markdown;
6mod project_model; 6mod project_model;
7pub mod req; 7pub mod req;
8pub mod init; 8pub mod config;
9mod world; 9mod world;
10 10
11pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; 11pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
12pub use crate::{ 12pub use crate::{
13 caps::server_capabilities, init::InitializationOptions, main_loop::main_loop, 13 caps::server_capabilities, config::ServerConfig, main_loop::main_loop, main_loop::LspError,
14 main_loop::LspError,
15}; 14};
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index c1f8243be..1a2ab1bc2 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -2,7 +2,7 @@ use flexi_logger::{Duplicate, Logger};
2use gen_lsp_server::{run_server, stdio_transport}; 2use gen_lsp_server::{run_server, stdio_transport};
3use serde::Deserialize; 3use serde::Deserialize;
4 4
5use ra_lsp_server::{InitializationOptions, Result}; 5use ra_lsp_server::{Result, ServerConfig};
6use ra_prof; 6use ra_prof;
7 7
8fn main() -> Result<()> { 8fn main() -> Result<()> {
@@ -48,7 +48,7 @@ fn main_inner() -> Result<()> {
48 48
49 let opts = params 49 let opts = params
50 .initialization_options 50 .initialization_options
51 .and_then(|v| InitializationOptions::deserialize(v).ok()) 51 .and_then(|v| ServerConfig::deserialize(v).ok())
52 .unwrap_or_default(); 52 .unwrap_or_default();
53 53
54 ra_lsp_server::main_loop(workspace_roots, params.capabilities, opts, r, s) 54 ra_lsp_server::main_loop(workspace_roots, params.capabilities, opts, r, s)
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 9a38d43d2..8ab501828 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -23,7 +23,7 @@ use crate::{
23 project_model::workspace_loader, 23 project_model::workspace_loader,
24 req, 24 req,
25 world::{Options, WorldSnapshot, WorldState}, 25 world::{Options, WorldSnapshot, WorldState},
26 InitializationOptions, Result, 26 Result, ServerConfig,
27}; 27};
28 28
29const THREADPOOL_SIZE: usize = 8; 29const THREADPOOL_SIZE: usize = 8;
@@ -52,7 +52,7 @@ impl Error for LspError {}
52pub fn main_loop( 52pub fn main_loop(
53 ws_roots: Vec<PathBuf>, 53 ws_roots: Vec<PathBuf>,
54 client_caps: ClientCapabilities, 54 client_caps: ClientCapabilities,
55 options: InitializationOptions, 55 config: ServerConfig,
56 msg_receiver: &Receiver<RawMessage>, 56 msg_receiver: &Receiver<RawMessage>,
57 msg_sender: &Sender<RawMessage>, 57 msg_sender: &Sender<RawMessage>,
58) -> Result<()> { 58) -> Result<()> {
@@ -81,10 +81,10 @@ pub fn main_loop(
81 let mut state = WorldState::new( 81 let mut state = WorldState::new(
82 ws_roots, 82 ws_roots,
83 workspaces, 83 workspaces,
84 options.lru_capacity, 84 config.lru_capacity,
85 Options { 85 Options {
86 publish_decorations: options.publish_decorations, 86 publish_decorations: config.publish_decorations,
87 show_workspace_loaded: options.show_workspace_loaded, 87 show_workspace_loaded: config.show_workspace_loaded,
88 supports_location_link: client_caps 88 supports_location_link: client_caps
89 .text_document 89 .text_document
90 .and_then(|it| it.definition) 90 .and_then(|it| it.definition)