Skip to content

Commit

Permalink
Undo the previous mistaken change and make publish_decorations optional
Browse files Browse the repository at this point in the history
See microsoft/language-server-protocol#567
for motivations to not require `InitializationOptions`

TODO: Check if there is any other custom clientside code we use which should be disabled if not implemented
  • Loading branch information
DJMcNab committed Dec 21, 2018
1 parent 463e5af commit 674639e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions crates/ra_lsp_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ fn main() -> Result<()> {
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct InitializationOptions {
publish_decorations: bool,
// Whether the client supports our custom highlighting publishing decorations.
// This is different to the highlightingOn setting, which is whether the client
// wants highlighting to be used or sent.
publish_decorations: Option<bool>,
}

fn main_inner() -> Result<()> {
Expand All @@ -42,12 +45,12 @@ fn main_inner() -> Result<()> {
.root_uri
.and_then(|it| it.to_file_path().ok())
.unwrap_or(cwd);
let publish_decorations = params
let supports_decorations = params
.initialization_options
.and_then(|v| InitializationOptions::deserialize(v).ok())
.map(|it| it.publish_decorations)
.and_then(|it| it.publish_decorations)
== Some(true);
ra_lsp_server::main_loop(false, root, publish_decorations, r, s)
ra_lsp_server::main_loop(false, root, supports_decorations, r, s)
},
)?;
log::info!("shutting down IO...");
Expand Down
8 changes: 4 additions & 4 deletions crates/ra_lsp_server/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum Task {
pub fn main_loop(
internal_mode: bool,
ws_root: PathBuf,
publish_decorations: bool,
supports_decorations: bool,
msg_receiver: &Receiver<RawMessage>,
msg_sender: &Sender<RawMessage>,
) -> Result<()> {
Expand Down Expand Up @@ -82,7 +82,7 @@ pub fn main_loop(
let mut subs = Subscriptions::new();
let main_res = main_loop_inner(
internal_mode,
publish_decorations,
supports_decorations,
&pool,
msg_sender,
msg_receiver,
Expand Down Expand Up @@ -111,7 +111,7 @@ pub fn main_loop(

fn main_loop_inner(
internal_mode: bool,
publish_decorations: bool,
supports_decorations: bool,
pool: &ThreadPool,
msg_sender: &Sender<RawMessage>,
msg_receiver: &Receiver<RawMessage>,
Expand Down Expand Up @@ -201,7 +201,7 @@ fn main_loop_inner(
update_file_notifications_on_threadpool(
pool,
state.snapshot(),
publish_decorations,
supports_decorations,
task_sender.clone(),
subs.subscriptions(),
)
Expand Down

0 comments on commit 674639e

Please sign in to comment.