diff --git a/.travis.yml b/.travis.yml index f26a8ad..82b8379 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,12 @@ language: Rust cache: cargo sudo: false + rust: -- nightly + - stable + - nightly +env: + - FEATURES="" + - FEATURES="proposed" + +script: cargo build --verbose; cargo test --verbose --features ${FEATURES:-""} diff --git a/Cargo.toml b/Cargo.toml index 9f0b58e..3a1c26d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,3 +24,8 @@ serde_json = "1.0.0" url = "1.1.0" url_serde = "0.2.0" +[features] +default = [] +# Enables proposed LSP extensions. +# NOTE: No semver compatibility is guaranteed for types enabled by this feature. +proposed = [] diff --git a/src/lib.rs b/src/lib.rs index 3fbbd0e..ffb749f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1360,6 +1360,19 @@ pub struct TextDocumentClientCapabilities { pub folding_range: Option, } +/** + * Window specific client capabilities. + */ +#[derive(Debug, PartialEq, Default, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct WindowClientCapabilities { + /** + * Whether `window/progress` server notifications are supported. + */ + #[cfg(feature = "proposed")] + pub progress: Option, +} + /** * Where ClientCapabilities are currently empty: */ @@ -1378,6 +1391,12 @@ pub struct ClientCapabilities { #[serde(skip_serializing_if = "Option::is_none")] pub text_document: Option, + /** + * Window specific client capabilities. + */ + #[serde(skip_serializing_if = "Option::is_none")] + pub window: Option, + /** * Experimental client capabilities. */ @@ -3350,6 +3369,35 @@ pub struct MarkupContent { pub value: String, } +#[cfg(feature = "proposed")] +/// The progress notification is sent from the server to the client to ask +/// the client to indicate progress. +#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)] +pub struct ProgressParams { + /// A unique identifier to associate multiple progress notifications + /// with the same progress. + pub id: String, + + /// Mandatory title of the progress operation. Used to briefly inform + /// about the kind of operation being performed. + /// Examples: "Indexing" or "Linking dependencies". + pub title: String, + + /// Optional, more detailed associated progress message. Contains + /// complementary information to the `title`. + /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". + /// If unset, the previous progress message (if any) is still valid. + pub message: Option, + + /// Optional progress percentage to display (value 100 is considered 100%). + /// If unset, the previous progress percentage (if any) is still valid. + pub percentage: Option, + + /// Set to true on the final progress update. + /// No more progress notifications with the same ID should be sent. + pub done: Option, +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/notification.rs b/src/notification.rs index 67d2722..c2f2ea7 100644 --- a/src/notification.rs +++ b/src/notification.rs @@ -59,6 +59,11 @@ macro_rules! lsp_notification { ("workspace/didChangeWorkspaceFolders") => { $crate::notification::DidChangeWorkspaceFolders }; + + // Requires #[cfg(feature = "proposed")] + ("window/progress") => { + $crate::notification::Progress + }; } /// The base protocol now offers support for request cancellation. To cancel a request, @@ -252,6 +257,18 @@ impl Notification for PublishDiagnostics { const METHOD: &'static str = "textDocument/publishDiagnostics"; } +#[cfg(feature = "proposed")] +/// The progress notification is sent from the server to the client to ask +/// the client to indicate progress. +#[derive(Debug)] +pub enum Progress {} + +#[cfg(feature = "proposed")] +impl Notification for Progress { + type Params = ProgressParams; + const METHOD: &'static str = "window/progress"; +} + #[cfg(test)] mod test { use super::*; @@ -290,5 +307,8 @@ mod test { check_macro!("workspace/didChangeConfiguration"); check_macro!("workspace/didChangeWatchedFiles"); check_macro!("workspace/didChangeWorkspaceFolders"); + + #[cfg(feature = "proposed")] + check_macro!("window/progress"); } }