Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions crates/starpls/src/commands/server.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use clap::Args;
use log::info;
use lsp_server::Connection;
use lsp_types::notification::Notification;
use lsp_types::notification::Progress;
use lsp_types::CompletionOptions;
use lsp_types::DeclarationCapability;
use lsp_types::HoverProviderCapability;
use lsp_types::OneOf;
use lsp_types::ProgressParams;
use lsp_types::ServerCapabilities;
use lsp_types::SignatureHelpOptions;
use lsp_types::TextDocumentSyncCapability;
Expand All @@ -18,6 +21,8 @@ use crate::make_trigger_characters;
const COMPLETION_TRIGGER_CHARACTERS: &[char] = &['.', '"', '\'', '/', ':', '@'];
const SIGNATURE_HELP_TRIGGER_CHARACTERS: &[char] = &['(', ',', ')'];

pub(crate) const INITIALIZATION_TOKEN: &str = "Initializing";

#[derive(Args, Default)]
pub(crate) struct ServerCommand {
/// Path to the Bazel binary.
Expand Down Expand Up @@ -52,6 +57,19 @@ impl ServerCommand {

// Create the transport over stdio.
let (connection, io_threads) = Connection::stdio();
let not = lsp_server::Notification::new(
Progress::METHOD.to_string(),
ProgressParams {
token: lsp_types::NumberOrString::String(INITIALIZATION_TOKEN.to_string()),
value: lsp_types::ProgressParamsValue::WorkDone(
lsp_types::WorkDoneProgress::Begin(lsp_types::WorkDoneProgressBegin {
title: "Initializing".to_string(),
..Default::default()
}),
),
},
);
connection.sender.send(not.into()).unwrap();

// Initialize the connection with server capabilities. For now, this consists
// only of `TextDocumentSyncKind.Full`.
Expand Down
21 changes: 21 additions & 0 deletions crates/starpls/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use log::error;
use log::info;
use lsp_server::Connection;
use lsp_server::ReqQueue;
use lsp_types::notification::Notification;
use lsp_types::notification::Progress;
use lsp_types::ProgressParams;
use parking_lot::RwLock;
use rustc_hash::FxHashSet;
use starpls_bazel::build_language::decode_rules;
Expand All @@ -28,6 +31,7 @@ use starpls_ide::Change;
use starpls_ide::InferenceOptions;

use crate::bazel::BazelContext;
use crate::commands::server::INITIALIZATION_TOKEN;
use crate::config::ServerConfig;
use crate::debouncer::AnalysisDebouncer;
use crate::diagnostics::DiagnosticsManager;
Expand Down Expand Up @@ -189,6 +193,23 @@ impl Server {
if has_bazel_init_err {
server.send_error_message(BAZEL_INIT_ERR_MESSAGE);
}
let initialization_msg = if has_bazel_init_err {
BAZEL_INIT_ERR_MESSAGE
} else {
"Initialization complete"
};
let not = lsp_server::Notification::new(
Progress::METHOD.to_string(),
ProgressParams {
token: lsp_types::NumberOrString::String(INITIALIZATION_TOKEN.to_string()),
value: lsp_types::ProgressParamsValue::WorkDone(lsp_types::WorkDoneProgress::End(
lsp_types::WorkDoneProgressEnd {
message: Some(initialization_msg.to_string()),
},
)),
},
);
server.connection.sender.send(not.into()).unwrap();

Ok(server)
}
Expand Down
Loading