diff options
Diffstat (limited to 'crates/ra_lsp_server')
-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.rs | 5 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main.rs | 4 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 10 |
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)] |
6 | pub struct InitializationOptions { | 6 | pub 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 | ||
24 | impl Default for InitializationOptions { | 24 | impl 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; | |||
5 | mod markdown; | 5 | mod markdown; |
6 | mod project_model; | 6 | mod project_model; |
7 | pub mod req; | 7 | pub mod req; |
8 | pub mod init; | 8 | pub mod config; |
9 | mod world; | 9 | mod world; |
10 | 10 | ||
11 | pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; | 11 | pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; |
12 | pub use crate::{ | 12 | pub 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}; | |||
2 | use gen_lsp_server::{run_server, stdio_transport}; | 2 | use gen_lsp_server::{run_server, stdio_transport}; |
3 | use serde::Deserialize; | 3 | use serde::Deserialize; |
4 | 4 | ||
5 | use ra_lsp_server::{InitializationOptions, Result}; | 5 | use ra_lsp_server::{Result, ServerConfig}; |
6 | use ra_prof; | 6 | use ra_prof; |
7 | 7 | ||
8 | fn main() -> Result<()> { | 8 | fn 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 | ||
29 | const THREADPOOL_SIZE: usize = 8; | 29 | const THREADPOOL_SIZE: usize = 8; |
@@ -52,7 +52,7 @@ impl Error for LspError {} | |||
52 | pub fn main_loop( | 52 | pub 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) |