aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock20
-rw-r--r--crates/ra_cli/Cargo.toml2
-rw-r--r--crates/ra_hir/Cargo.toml4
-rw-r--r--crates/ra_ide_api/Cargo.toml2
-rw-r--r--crates/ra_ide_api_light/Cargo.toml2
-rw-r--r--crates/ra_lsp_server/Cargo.toml2
-rw-r--r--crates/ra_lsp_server/src/init.rs39
-rw-r--r--crates/ra_lsp_server/src/lib.rs3
-rw-r--r--crates/ra_lsp_server/src/main.rs20
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs48
-rw-r--r--crates/ra_lsp_server/src/req.rs7
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/main.rs10
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/support.rs21
-rw-r--r--editors/code/package.json5
-rw-r--r--editors/code/src/config.ts7
-rw-r--r--editors/code/src/server.ts4
16 files changed, 126 insertions, 70 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 13760339c..4551ffc44 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -359,7 +359,7 @@ dependencies = [
359 359
360[[package]] 360[[package]]
361name = "flexi_logger" 361name = "flexi_logger"
362version = "0.10.7" 362version = "0.11.0"
363source = "registry+https://github.com/rust-lang/crates.io-index" 363source = "registry+https://github.com/rust-lang/crates.io-index"
364dependencies = [ 364dependencies = [
365 "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 365 "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -509,7 +509,7 @@ dependencies = [
509 509
510[[package]] 510[[package]]
511name = "insta" 511name = "insta"
512version = "0.6.3" 512version = "0.7.0"
513source = "registry+https://github.com/rust-lang/crates.io-index" 513source = "registry+https://github.com/rust-lang/crates.io-index"
514dependencies = [ 514dependencies = [
515 "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 515 "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -939,7 +939,7 @@ version = "0.1.0"
939dependencies = [ 939dependencies = [
940 "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", 940 "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
941 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 941 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
942 "flexi_logger 0.10.7 (registry+https://github.com/rust-lang/crates.io-index)", 942 "flexi_logger 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
943 "indicatif 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 943 "indicatif 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
944 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 944 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
945 "ra_batch 0.1.0", 945 "ra_batch 0.1.0",
@@ -977,8 +977,8 @@ version = "0.1.0"
977dependencies = [ 977dependencies = [
978 "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", 978 "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
979 "ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 979 "ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
980 "flexi_logger 0.10.7 (registry+https://github.com/rust-lang/crates.io-index)", 980 "flexi_logger 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
981 "insta 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", 981 "insta 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
982 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 982 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
983 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 983 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
984 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", 984 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -997,7 +997,7 @@ name = "ra_ide_api"
997version = "0.1.0" 997version = "0.1.0"
998dependencies = [ 998dependencies = [
999 "fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 999 "fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
1000 "insta 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", 1000 "insta 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
1001 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 1001 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
1002 "jemalloc-ctl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 1002 "jemalloc-ctl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
1003 "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", 1003 "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1021,7 +1021,7 @@ dependencies = [
1021name = "ra_ide_api_light" 1021name = "ra_ide_api_light"
1022version = "0.1.0" 1022version = "0.1.0"
1023dependencies = [ 1023dependencies = [
1024 "insta 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", 1024 "insta 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
1025 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 1025 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
1026 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 1026 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
1027 "proptest 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", 1027 "proptest 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1040,7 +1040,7 @@ dependencies = [
1040 "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 1040 "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
1041 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 1041 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
1042 "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 1042 "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
1043 "flexi_logger 0.10.7 (registry+https://github.com/rust-lang/crates.io-index)", 1043 "flexi_logger 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
1044 "gen_lsp_server 0.1.0", 1044 "gen_lsp_server 0.1.0",
1045 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 1045 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
1046 "lsp-types 0.56.0 (registry+https://github.com/rust-lang/crates.io-index)", 1046 "lsp-types 0.56.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1932,7 +1932,7 @@ dependencies = [
1932"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" 1932"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
1933"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" 1933"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
1934"checksum filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a2df5c1a8c4be27e7707789dc42ae65976e60b394afd293d1419ab915833e646" 1934"checksum filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a2df5c1a8c4be27e7707789dc42ae65976e60b394afd293d1419ab915833e646"
1935"checksum flexi_logger 0.10.7 (registry+https://github.com/rust-lang/crates.io-index)" = "617bc8ff0e391c36e197f32c0c449ca1651e5b1b24f41107c6a469948b5038b5" 1935"checksum flexi_logger 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4554f652e4673c25dba4deebbc52d5ceefcb19958eec8a34417af320b8a0746"
1936"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" 1936"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
1937"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674" 1937"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
1938"checksum fsevent 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c4bbbf71584aeed076100b5665ac14e3d85eeb31fdbb45fbd41ef9a682b5ec05" 1938"checksum fsevent 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c4bbbf71584aeed076100b5665ac14e3d85eeb31fdbb45fbd41ef9a682b5ec05"
@@ -1950,7 +1950,7 @@ dependencies = [
1950"checksum indicatif 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c60da1c9abea75996b70a931bba6c750730399005b61ccd853cee50ef3d0d0c" 1950"checksum indicatif 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c60da1c9abea75996b70a931bba6c750730399005b61ccd853cee50ef3d0d0c"
1951"checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" 1951"checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718"
1952"checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" 1952"checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0"
1953"checksum insta 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc3ee8d49a583b9c4ecb1b50777b65eec0a568e49dddfac37109ef320175533" 1953"checksum insta 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c6c10b8c7e7607bab7cac8f360c111fa3a7afa331dafa2703754b540f5e08f4"
1954"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" 1954"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
1955"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" 1955"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
1956"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" 1956"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml
index 042e42067..ff30bf0b3 100644
--- a/crates/ra_cli/Cargo.toml
+++ b/crates/ra_cli/Cargo.toml
@@ -9,7 +9,7 @@ publish = false
9clap = "2.32.0" 9clap = "2.32.0"
10failure = "0.1.4" 10failure = "0.1.4"
11join_to_string = "0.1.1" 11join_to_string = "0.1.1"
12flexi_logger = "0.10.0" 12flexi_logger = "0.11.0"
13indicatif = "0.11.0" 13indicatif = "0.11.0"
14 14
15ra_syntax = { path = "../ra_syntax" } 15ra_syntax = { path = "../ra_syntax" }
diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml
index f2242fe1f..501308acc 100644
--- a/crates/ra_hir/Cargo.toml
+++ b/crates/ra_hir/Cargo.toml
@@ -21,5 +21,5 @@ tt = { path = "../ra_tt", package = "ra_tt" }
21test_utils = { path = "../test_utils" } 21test_utils = { path = "../test_utils" }
22 22
23[dev-dependencies] 23[dev-dependencies]
24flexi_logger = "0.10.0" 24flexi_logger = "0.11.0"
25insta = "0.6.1" 25insta = "0.7.0"
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml
index 1d907bda2..40b7a8d0a 100644
--- a/crates/ra_ide_api/Cargo.toml
+++ b/crates/ra_ide_api/Cargo.toml
@@ -27,7 +27,7 @@ test_utils = { path = "../test_utils" }
27ra_assists = { path = "../ra_assists" } 27ra_assists = { path = "../ra_assists" }
28 28
29[dev-dependencies] 29[dev-dependencies]
30insta = "0.6.1" 30insta = "0.7.0"
31 31
32[features] 32[features]
33jemalloc = [ "jemallocator", "jemalloc-ctl" ] 33jemalloc = [ "jemallocator", "jemalloc-ctl" ]
diff --git a/crates/ra_ide_api_light/Cargo.toml b/crates/ra_ide_api_light/Cargo.toml
index 29c1f4639..a30833dc3 100644
--- a/crates/ra_ide_api_light/Cargo.toml
+++ b/crates/ra_ide_api_light/Cargo.toml
@@ -18,4 +18,4 @@ ra_fmt = { path = "../ra_fmt" }
18[dev-dependencies] 18[dev-dependencies]
19test_utils = { path = "../test_utils" } 19test_utils = { path = "../test_utils" }
20proptest = "0.9.0" 20proptest = "0.9.0"
21insta = "0.6.1" 21insta = "0.7.0"
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml
index ef6dea393..a36e6b5ae 100644
--- a/crates/ra_lsp_server/Cargo.toml
+++ b/crates/ra_lsp_server/Cargo.toml
@@ -12,7 +12,7 @@ failure_derive = "0.1.4"
12serde_json = "1.0.34" 12serde_json = "1.0.34"
13serde = "1.0.83" 13serde = "1.0.83"
14crossbeam-channel = "0.3.5" 14crossbeam-channel = "0.3.5"
15flexi_logger = "0.10.0" 15flexi_logger = "0.11.0"
16log = "0.4.3" 16log = "0.4.3"
17url_serde = "0.2.0" 17url_serde = "0.2.0"
18lsp-types = "0.56.0" 18lsp-types = "0.56.0"
diff --git a/crates/ra_lsp_server/src/init.rs b/crates/ra_lsp_server/src/init.rs
new file mode 100644
index 000000000..0b7a47a0b
--- /dev/null
+++ b/crates/ra_lsp_server/src/init.rs
@@ -0,0 +1,39 @@
1use serde::{Deserialize, Deserializer};
2
3/// Client provided initialization options
4#[derive(Deserialize, Clone, Copy, Debug)]
5#[serde(rename_all = "camelCase")]
6pub struct InitializationOptions {
7 /// Whether the client supports our custom highlighting publishing decorations.
8 /// This is different to the highlightingOn setting, which is whether the user
9 /// wants our custom highlighting to be used.
10 ///
11 /// Defaults to `true`
12 #[serde(default = "bool_true", deserialize_with = "nullable_bool_true")]
13 pub publish_decorations: bool,
14
15 /// Whether or not the workspace loaded notification should be sent
16 ///
17 /// Defaults to `true`
18 #[serde(default = "bool_true", deserialize_with = "nullable_bool_true")]
19 pub show_workspace_loaded: bool,
20}
21
22impl Default for InitializationOptions {
23 fn default() -> InitializationOptions {
24 InitializationOptions { publish_decorations: true, show_workspace_loaded: true }
25 }
26}
27
28fn bool_true() -> bool {
29 true
30}
31
32/// Deserializes a null value to a bool true by default
33fn nullable_bool_true<'de, D>(deserializer: D) -> Result<bool, D::Error>
34where
35 D: Deserializer<'de>,
36{
37 let opt = Option::deserialize(deserializer)?;
38 Ok(opt.unwrap_or(true))
39}
diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs
index 5b5f3b948..59e16a47c 100644
--- a/crates/ra_lsp_server/src/lib.rs
+++ b/crates/ra_lsp_server/src/lib.rs
@@ -5,7 +5,8 @@ mod main_loop;
5mod markdown; 5mod markdown;
6mod project_model; 6mod project_model;
7pub mod req; 7pub mod req;
8pub mod init;
8mod server_world; 9mod server_world;
9 10
10pub type Result<T> = ::std::result::Result<T, ::failure::Error>; 11pub type Result<T> = ::std::result::Result<T, ::failure::Error>;
11pub use crate::{caps::server_capabilities, main_loop::main_loop, main_loop::LspError}; 12pub use crate::{caps::server_capabilities, main_loop::main_loop, main_loop::LspError, init::InitializationOptions};
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index 03f83c7be..5a2905207 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -2,7 +2,7 @@ use serde::Deserialize;
2use flexi_logger::{Duplicate, Logger}; 2use flexi_logger::{Duplicate, Logger};
3use gen_lsp_server::{run_server, stdio_transport}; 3use gen_lsp_server::{run_server, stdio_transport};
4 4
5use ra_lsp_server::Result; 5use ra_lsp_server::{Result, InitializationOptions};
6 6
7fn main() -> Result<()> { 7fn main() -> Result<()> {
8 ::std::env::set_var("RUST_BACKTRACE", "short"); 8 ::std::env::set_var("RUST_BACKTRACE", "short");
@@ -24,26 +24,18 @@ fn main() -> Result<()> {
24 } 24 }
25} 25}
26 26
27#[derive(Deserialize)]
28#[serde(rename_all = "camelCase")]
29struct InitializationOptions {
30 // Whether the client supports our custom highlighting publishing decorations.
31 // This is different to the highlightingOn setting, which is whether the user
32 // wants our custom highlighting to be used.
33 publish_decorations: Option<bool>,
34}
35
36fn main_inner() -> Result<()> { 27fn main_inner() -> Result<()> {
37 let (receiver, sender, threads) = stdio_transport(); 28 let (receiver, sender, threads) = stdio_transport();
38 let cwd = ::std::env::current_dir()?; 29 let cwd = ::std::env::current_dir()?;
39 run_server(ra_lsp_server::server_capabilities(), receiver, sender, |params, r, s| { 30 run_server(ra_lsp_server::server_capabilities(), receiver, sender, |params, r, s| {
40 let root = params.root_uri.and_then(|it| it.to_file_path().ok()).unwrap_or(cwd); 31 let root = params.root_uri.and_then(|it| it.to_file_path().ok()).unwrap_or(cwd);
41 let supports_decorations = params 32
33 let opts = params
42 .initialization_options 34 .initialization_options
43 .and_then(|v| InitializationOptions::deserialize(v).ok()) 35 .and_then(|v| InitializationOptions::deserialize(v).ok())
44 .and_then(|it| it.publish_decorations) 36 .unwrap_or(InitializationOptions::default());
45 == Some(true); 37
46 ra_lsp_server::main_loop(false, root, supports_decorations, r, s) 38 ra_lsp_server::main_loop(root, opts, r, s)
47 })?; 39 })?;
48 log::info!("shutting down IO..."); 40 log::info!("shutting down IO...");
49 threads.join()?; 41 threads.join()?;
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 0f8ef10b9..d0c2a95ef 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -22,6 +22,7 @@ use crate::{
22 req, 22 req,
23 server_world::{ServerWorld, ServerWorldState}, 23 server_world::{ServerWorld, ServerWorldState},
24 Result, 24 Result,
25 InitializationOptions,
25}; 26};
26 27
27#[derive(Debug, Fail)] 28#[derive(Debug, Fail)]
@@ -46,9 +47,8 @@ enum Task {
46const THREADPOOL_SIZE: usize = 8; 47const THREADPOOL_SIZE: usize = 8;
47 48
48pub fn main_loop( 49pub fn main_loop(
49 internal_mode: bool,
50 ws_root: PathBuf, 50 ws_root: PathBuf,
51 supports_decorations: bool, 51 options: InitializationOptions,
52 msg_receiver: &Receiver<RawMessage>, 52 msg_receiver: &Receiver<RawMessage>,
53 msg_sender: &Sender<RawMessage>, 53 msg_sender: &Sender<RawMessage>,
54) -> Result<()> { 54) -> Result<()> {
@@ -63,11 +63,12 @@ pub fn main_loop(
63 Ok(ws) => vec![ws], 63 Ok(ws) => vec![ws],
64 Err(e) => { 64 Err(e) => {
65 log::error!("loading workspace failed: {}", e); 65 log::error!("loading workspace failed: {}", e);
66 let msg = RawNotification::new::<req::ShowMessage>(&req::ShowMessageParams { 66
67 typ: req::MessageType::Error, 67 show_message(
68 message: format!("rust-analyzer failed to load workspace: {}", e), 68 req::MessageType::Error,
69 }); 69 format!("rust-analyzer failed to load workspace: {}", e),
70 msg_sender.send(msg.into()).unwrap(); 70 msg_sender,
71 );
71 Vec::new() 72 Vec::new()
72 } 73 }
73 } 74 }
@@ -80,8 +81,7 @@ pub fn main_loop(
80 let mut pending_requests = FxHashSet::default(); 81 let mut pending_requests = FxHashSet::default();
81 let mut subs = Subscriptions::new(); 82 let mut subs = Subscriptions::new();
82 let main_res = main_loop_inner( 83 let main_res = main_loop_inner(
83 internal_mode, 84 options,
84 supports_decorations,
85 &pool, 85 &pool,
86 msg_sender, 86 msg_sender,
87 msg_receiver, 87 msg_receiver,
@@ -148,8 +148,7 @@ impl fmt::Debug for Event {
148} 148}
149 149
150fn main_loop_inner( 150fn main_loop_inner(
151 internal_mode: bool, 151 options: InitializationOptions,
152 supports_decorations: bool,
153 pool: &ThreadPool, 152 pool: &ThreadPool,
154 msg_sender: &Sender<RawMessage>, 153 msg_sender: &Sender<RawMessage>,
155 msg_receiver: &Receiver<RawMessage>, 154 msg_receiver: &Receiver<RawMessage>,
@@ -163,6 +162,7 @@ fn main_loop_inner(
163 // time to always have a thread ready to react to input. 162 // time to always have a thread ready to react to input.
164 let mut in_flight_libraries = 0; 163 let mut in_flight_libraries = 0;
165 let mut pending_libraries = Vec::new(); 164 let mut pending_libraries = Vec::new();
165 let mut send_workspace_notification = true;
166 166
167 let (libdata_sender, libdata_receiver) = unbounded(); 167 let (libdata_sender, libdata_receiver) = unbounded();
168 loop { 168 loop {
@@ -190,7 +190,6 @@ fn main_loop_inner(
190 state_changed = true; 190 state_changed = true;
191 } 191 }
192 Event::Lib(lib) => { 192 Event::Lib(lib) => {
193 feedback(internal_mode, "library loaded", msg_sender);
194 state.add_lib(lib); 193 state.add_lib(lib);
195 in_flight_libraries -= 1; 194 in_flight_libraries -= 1;
196 } 195 }
@@ -244,15 +243,23 @@ fn main_loop_inner(
244 }); 243 });
245 } 244 }
246 245
247 if state.roots_to_scan == 0 && pending_libraries.is_empty() && in_flight_libraries == 0 { 246 if send_workspace_notification
248 feedback(internal_mode, "workspace loaded", msg_sender); 247 && state.roots_to_scan == 0
248 && pending_libraries.is_empty()
249 && in_flight_libraries == 0
250 {
251 if options.show_workspace_loaded {
252 show_message(req::MessageType::Info, "workspace loaded", msg_sender);
253 }
254 // Only send the notification first time
255 send_workspace_notification = false;
249 } 256 }
250 257
251 if state_changed { 258 if state_changed {
252 update_file_notifications_on_threadpool( 259 update_file_notifications_on_threadpool(
253 pool, 260 pool,
254 state.snapshot(), 261 state.snapshot(),
255 supports_decorations, 262 options.publish_decorations,
256 task_sender.clone(), 263 task_sender.clone(),
257 subs.subscriptions(), 264 subs.subscriptions(),
258 ) 265 )
@@ -501,11 +508,12 @@ fn update_file_notifications_on_threadpool(
501 }); 508 });
502} 509}
503 510
504fn feedback(intrnal_mode: bool, msg: &str, sender: &Sender<RawMessage>) { 511fn show_message<M: Into<String>>(typ: req::MessageType, msg: M, sender: &Sender<RawMessage>) {
505 if !intrnal_mode { 512 let not = RawNotification::new::<req::ShowMessage>(&req::ShowMessageParams {
506 return; 513 typ,
507 } 514 message: msg.into(),
508 let not = RawNotification::new::<req::InternalFeedback>(&msg.to_string()); 515 });
516
509 sender.send(not.into()).unwrap(); 517 sender.send(not.into()).unwrap();
510} 518}
511 519
diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs
index 484fde7e5..e0571fd78 100644
--- a/crates/ra_lsp_server/src/req.rs
+++ b/crates/ra_lsp_server/src/req.rs
@@ -172,10 +172,3 @@ pub struct SourceChange {
172 pub workspace_edit: WorkspaceEdit, 172 pub workspace_edit: WorkspaceEdit,
173 pub cursor_position: Option<TextDocumentPositionParams>, 173 pub cursor_position: Option<TextDocumentPositionParams>,
174} 174}
175
176pub enum InternalFeedback {}
177
178impl Notification for InternalFeedback {
179 const METHOD: &'static str = "internalFeedback";
180 type Params = String;
181}
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs
index 996bf8e01..1c099a78f 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/main.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs
@@ -31,7 +31,7 @@ version = "0.0.0"
31use std::collections::Spam; 31use std::collections::Spam;
32"#, 32"#,
33 ); 33 );
34 server.wait_for_feedback("workspace loaded"); 34 server.wait_for_message("workspace loaded");
35 eprintln!("loading took {:?}", project_start.elapsed()); 35 eprintln!("loading took {:?}", project_start.elapsed());
36 let completion_start = Instant::now(); 36 let completion_start = Instant::now();
37 let res = server.send_request::<Completion>(CompletionParams { 37 let res = server.send_request::<Completion>(CompletionParams {
@@ -53,7 +53,7 @@ fn foo() {
53} 53}
54", 54",
55 ); 55 );
56 server.wait_for_feedback("workspace loaded"); 56 server.wait_for_message("workspace loaded");
57 server.request::<Runnables>( 57 server.request::<Runnables>(
58 RunnablesParams { text_document: server.doc_id("lib.rs"), position: None }, 58 RunnablesParams { text_document: server.doc_id("lib.rs"), position: None },
59 json!([ 59 json!([
@@ -107,7 +107,7 @@ pub fn foo() {}
107fn test_eggs() {} 107fn test_eggs() {}
108"#, 108"#,
109 ); 109 );
110 server.wait_for_feedback("workspace loaded"); 110 server.wait_for_message("workspace loaded");
111 server.request::<Runnables>( 111 server.request::<Runnables>(
112 RunnablesParams { 112 RunnablesParams {
113 text_document: server.doc_id("tests/spam.rs"), 113 text_document: server.doc_id("tests/spam.rs"),
@@ -167,7 +167,7 @@ fn main() {
167pub use std::collections::HashMap; 167pub use std::collections::HashMap;
168"#, 168"#,
169 ); 169 );
170 server.wait_for_feedback("workspace loaded"); 170 server.wait_for_message("workspace loaded");
171 171
172 server.request::<Formatting>( 172 server.request::<Formatting>(
173 DocumentFormattingParams { 173 DocumentFormattingParams {
@@ -216,7 +216,7 @@ mod bar;
216fn main() {} 216fn main() {}
217"#, 217"#,
218 ); 218 );
219 server.wait_for_feedback("workspace loaded"); 219 server.wait_for_message("workspace loaded");
220 let empty_context = || CodeActionContext { diagnostics: Vec::new(), only: None }; 220 let empty_context = || CodeActionContext { diagnostics: Vec::new(), only: None };
221 server.request::<CodeActionRequest>( 221 server.request::<CodeActionRequest>(
222 CodeActionParams { 222 CodeActionParams {
diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs
index f4e7eaf75..8bfc8d622 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/support.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs
@@ -13,6 +13,7 @@ use lsp_types::{
13 notification::DidOpenTextDocument, 13 notification::DidOpenTextDocument,
14 request::{Request, Shutdown}, 14 request::{Request, Shutdown},
15 DidOpenTextDocumentParams, TextDocumentIdentifier, TextDocumentItem, Url, 15 DidOpenTextDocumentParams, TextDocumentIdentifier, TextDocumentItem, Url,
16 notification::{Notification, ShowMessage},
16}; 17};
17use serde::Serialize; 18use serde::Serialize;
18use serde_json::{to_string_pretty, Value}; 19use serde_json::{to_string_pretty, Value};
@@ -22,6 +23,7 @@ use test_utils::{parse_fixture, find_mismatch};
22 23
23use ra_lsp_server::{ 24use ra_lsp_server::{
24 main_loop, req, 25 main_loop, req,
26 InitializationOptions,
25}; 27};
26 28
27pub fn project(fixture: &str) -> Server { 29pub fn project(fixture: &str) -> Server {
@@ -56,7 +58,13 @@ impl Server {
56 "test server", 58 "test server",
57 128, 59 128,
58 move |mut msg_receiver, mut msg_sender| { 60 move |mut msg_receiver, mut msg_sender| {
59 main_loop(true, path, true, &mut msg_receiver, &mut msg_sender).unwrap() 61 main_loop(
62 path,
63 InitializationOptions::default(),
64 &mut msg_receiver,
65 &mut msg_sender,
66 )
67 .unwrap()
60 }, 68 },
61 ); 69 );
62 let res = Server { 70 let res = Server {
@@ -133,13 +141,14 @@ impl Server {
133 } 141 }
134 panic!("no response"); 142 panic!("no response");
135 } 143 }
136 pub fn wait_for_feedback(&self, feedback: &str) { 144 pub fn wait_for_message(&self, message: &str) {
137 self.wait_for_feedback_n(feedback, 1) 145 self.wait_for_message_n(message, 1)
138 } 146 }
139 pub fn wait_for_feedback_n(&self, feedback: &str, n: usize) { 147 pub fn wait_for_message_n(&self, message: &str, n: usize) {
140 let f = |msg: &RawMessage| match msg { 148 let f = |msg: &RawMessage| match msg {
141 RawMessage::Notification(n) if n.method == "internalFeedback" => { 149 RawMessage::Notification(n) if n.method == ShowMessage::METHOD => {
142 return n.clone().cast::<req::InternalFeedback>().unwrap() == feedback; 150 let msg = n.clone().cast::<req::ShowMessage>().unwrap();
151 msg.message == message
143 } 152 }
144 _ => false, 153 _ => false,
145 }; 154 };
diff --git a/editors/code/package.json b/editors/code/package.json
index fda411810..47eaac878 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -150,6 +150,11 @@
150 "default": false, 150 "default": false,
151 "description": "Highlight Rust code (overrides built-in syntax highlighting)" 151 "description": "Highlight Rust code (overrides built-in syntax highlighting)"
152 }, 152 },
153 "rust-analyzer.showWorkspaceLoadedNotification": {
154 "type": "boolean",
155 "default": true,
156 "description": "Show notification when workspace was loaded"
157 },
153 "rust-analyzer.enableEnhancedTyping": { 158 "rust-analyzer.enableEnhancedTyping": {
154 "type": "boolean", 159 "type": "boolean",
155 "default": true, 160 "default": true,
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 4e353798c..afc5cc6af 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -8,6 +8,7 @@ export class Config {
8 public highlightingOn = true; 8 public highlightingOn = true;
9 public enableEnhancedTyping = true; 9 public enableEnhancedTyping = true;
10 public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server'; 10 public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server';
11 public showWorkspaceLoadedNotification = true;
11 12
12 private prevEnhancedTyping: null | boolean = null; 13 private prevEnhancedTyping: null | boolean = null;
13 14
@@ -24,6 +25,12 @@ export class Config {
24 this.highlightingOn = config.get('highlightingOn') as boolean; 25 this.highlightingOn = config.get('highlightingOn') as boolean;
25 } 26 }
26 27
28 if (config.has('showWorkspaceLoadedNotification')) {
29 this.showWorkspaceLoadedNotification = config.get(
30 'showWorkspaceLoadedNotification'
31 ) as boolean;
32 }
33
27 if (!this.highlightingOn && Server) { 34 if (!this.highlightingOn && Server) {
28 Server.highlighter.removeHighlights(); 35 Server.highlighter.removeHighlights();
29 } 36 }
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index 9ead87fae..50461b0c6 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -26,7 +26,9 @@ export class Server {
26 const clientOptions: lc.LanguageClientOptions = { 26 const clientOptions: lc.LanguageClientOptions = {
27 documentSelector: [{ scheme: 'file', language: 'rust' }], 27 documentSelector: [{ scheme: 'file', language: 'rust' }],
28 initializationOptions: { 28 initializationOptions: {
29 publishDecorations: true 29 publishDecorations: true,
30 showWorkspaceLoaded:
31 Server.config.showWorkspaceLoadedNotification
30 }, 32 },
31 traceOutputChannel 33 traceOutputChannel
32 }; 34 };