lsp-types 0.97.0

Types for interaction with a language server, using VSCode's Language Server Protocol
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};

use crate::{LSPObject, Uri};

pub use notification_params::*;

/// A notebook document.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NotebookDocument {
    /// The notebook document's URI.
    pub uri: Uri,
    /// The type of the notebook.
    pub notebook_type: String,
    /// The version number of this document (it will increase after each
    /// change, including undo/redo).
    pub version: i32,
    /// Additional metadata stored with the notebook
    /// document.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub metadata: Option<LSPObject>,
    /// The cells of a notebook.
    pub cells: Vec<NotebookCell>,
}

/// A notebook cell.
///
/// A cell's document URI must be unique across ALL notebook
/// cells and can therefore be used to uniquely identify a
/// notebook cell or the cell's text document.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NotebookCell {
    /// The cell's kind
    pub kind: NotebookCellKind,
    /// The URI of the cell's text document content.
    pub document: Uri,
    /// Additional metadata stored with the cell.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub metadata: Option<LSPObject>,
    /// Additional execution summary information
    /// if supported by the client.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub execution_summary: Option<ExecutionSummary>,
}

#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ExecutionSummary {
    /// A strict monotonically increasing value
    /// indicating the execution order of a cell
    /// inside a notebook.
    pub execution_order: u32,
    /// Whether the execution was successful or
    /// not if known by the client.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub success: Option<bool>,
}

#[derive(Debug, Eq, PartialEq, Clone, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum NotebookCellKind {
    /// A markup-cell is formatted source that is used for display.
    Markup = 1,
    /// A code-cell is source code.
    Code = 2,
}

/// Capabilities specific to the notebook document support.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NotebookDocumentClientCapabilities {
    /// Capabilities specific to notebook document synchronization
    ///
    /// @since 3.17.0
    pub synchronization: NotebookDocumentSyncClientCapabilities,
}

/// Notebook specific client capabilities.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NotebookDocumentSyncClientCapabilities {
    /// Whether implementation supports dynamic registration. If this is
    /// set to `true` the client supports the new
    /// `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`
    /// return value for the corresponding server capability as well.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub dynamic_registration: Option<bool>,

    /// The client supports sending execution summary data per cell.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub execution_summary_report: Option<bool>,
}

///  Options specific to a notebook plus its cells
///  to be synced to the server.
///
///  If a selector provides a notebook document
///  filter but no cell selector all cells of a
///  matching notebook document will be synced.
///
///  If a selector provides no notebook document
///  filter but only a cell selector all notebook
///  documents that contain at least one matching
///  cell will be synced.
///
///  @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NotebookDocumentSyncOptions {
    /// The notebooks to be synced
    pub notebook_selector: Vec<NotebookSelector>,
    /// Whether save notification should be forwarded to
    /// the server. Will only be honored if mode === `notebook`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub save: Option<bool>,
}

/// Registration options specific to a notebook.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NotebookDocumentSyncRegistrationOptions {
    /// The notebooks to be synced
    pub notebook_selector: Vec<NotebookSelector>,
    /// Whether save notification should be forwarded to
    /// the server. Will only be honored if mode === `notebook`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub save: Option<bool>,
    /// The id used to register the request. The id can be used to deregister
    /// the request again. See also Registration#id.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
}

/// A notebook cell text document filter denotes a cell text
/// document by different properties.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NotebookCellTextDocumentFilter {
    /// A filter that matches against the notebook
    /// containing the notebook cell. If a string
    /// value is provided it matches against the
    /// notebook type. '*' matches every notebook.
    pub notebook: Notebook,
    /// A language id like `python`.
    ///
    /// Will be matched against the language id of the
    /// notebook cell document. '*' matches every language.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub language: Option<String>,
}

#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase", untagged)]
pub enum NotebookSelector {
    ByNotebook {
        /// The notebook to be synced. If a string
        /// value is provided it matches against the
        /// notebook type. '*' matches every notebook.
        notebook: Notebook,
        /// The cells of the matching notebook to be synced.
        #[serde(skip_serializing_if = "Option::is_none")]
        cells: Option<Vec<NotebookCellSelector>>,
    },
    ByCells {
        /// The notebook to be synced. If a string
        /// value is provided it matches against the
        /// notebook type. '*' matches every notebook.
        #[serde(skip_serializing_if = "Option::is_none")]
        notebook: Option<Notebook>,
        /// The cells of the matching notebook to be synced.
        cells: Vec<NotebookCellSelector>,
    },
}

#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NotebookCellSelector {
    pub language: String,
}

#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum Notebook {
    String(String),
    NotebookDocumentFilter(NotebookDocumentFilter),
}

/// A notebook document filter denotes a notebook document by
/// different properties.
///
/// @since 3.17.0
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase", untagged)]
pub enum NotebookDocumentFilter {
    ByType {
        /// The type of the enclosing notebook.
        notebook_type: String,
        /// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
        #[serde(skip_serializing_if = "Option::is_none")]
        scheme: Option<String>,
        /// A glob pattern.
        #[serde(skip_serializing_if = "Option::is_none")]
        pattern: Option<String>,
    },
    ByScheme {
        /// The type of the enclosing notebook.
        #[serde(skip_serializing_if = "Option::is_none")]
        notebook_type: Option<String>,
        /// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
        scheme: String,
        /// A glob pattern.
        #[serde(skip_serializing_if = "Option::is_none")]
        pattern: Option<String>,
    },
    ByPattern {
        /// The type of the enclosing notebook.
        #[serde(skip_serializing_if = "Option::is_none")]
        notebook_type: Option<String>,
        /// A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
        #[serde(skip_serializing_if = "Option::is_none")]
        scheme: Option<String>,
        /// A glob pattern.
        pattern: String,
    },
}

mod notification_params {
    use serde::{Deserialize, Serialize};

    use crate::{
        TextDocumentContentChangeEvent, TextDocumentIdentifier, TextDocumentItem,
        VersionedTextDocumentIdentifier,
    };

    use super::*;

    /// The params sent in an open notebook document notification.
    ///
    /// @since 3.17.0
    #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    pub struct DidOpenNotebookDocumentParams {
        /// The notebook document that got opened.
        pub notebook_document: NotebookDocument,
        /// The text documents that represent the content
        /// of a notebook cell.
        pub cell_text_documents: Vec<TextDocumentItem>,
    }

    /// The params sent in a change notebook document notification.
    ///
    /// @since 3.17.0
    #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    pub struct DidChangeNotebookDocumentParams {
        /// The notebook document that did change. The version number points
        /// to the version after all provided changes have been applied.
        pub notebook_document: VersionedNotebookDocumentIdentifier,

        /// The actual changes to the notebook document.
        ///
        /// The change describes single state change to the notebook document.
        /// So it moves a notebook document, its cells and its cell text document
        /// contents from state S to S'.
        ///
        /// To mirror the content of a notebook using change events use the
        /// following approach:
        /// - start with the same initial content
        /// - apply the 'notebookDocument/didChange' notifications in the order
        ///   you receive them.
        pub change: NotebookDocumentChangeEvent,
    }

    /// A versioned notebook document identifier.
    ///
    /// @since 3.17.0
    #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    pub struct VersionedNotebookDocumentIdentifier {
        /// The version number of this notebook document.
        pub version: i32,
        /// The notebook document's URI.
        pub uri: Uri,
    }

    /// A change event for a notebook document.
    ///
    /// @since 3.17.0
    #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    pub struct NotebookDocumentChangeEvent {
        /// The changed meta data if any.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub metadata: Option<LSPObject>,

        /// Changes to cells
        #[serde(skip_serializing_if = "Option::is_none")]
        pub cells: Option<NotebookDocumentCellChange>,
    }

    #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    pub struct NotebookDocumentCellChange {
        /// Changes to the cell structure to add or
        /// remove cells.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub structure: Option<NotebookDocumentCellChangeStructure>,

        /// Changes to notebook cells properties like its
        /// kind, execution summary or metadata.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub data: Option<Vec<NotebookCell>>,

        /// Changes to the text content of notebook cells.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub text_content: Option<Vec<NotebookDocumentChangeTextContent>>,
    }

    #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    pub struct NotebookDocumentChangeTextContent {
        pub document: VersionedTextDocumentIdentifier,
        pub changes: Vec<TextDocumentContentChangeEvent>,
    }

    #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    pub struct NotebookDocumentCellChangeStructure {
        /// The change to the cell array.
        pub array: NotebookCellArrayChange,
        /// Additional opened cell text documents.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub did_open: Option<Vec<TextDocumentItem>>,
        /// Additional closed cell text documents.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub did_close: Option<Vec<TextDocumentIdentifier>>,
    }

    /// A change describing how to move a `NotebookCell`
    /// array from state S to S'.
    ///
    /// @since 3.17.0
    #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    pub struct NotebookCellArrayChange {
        /// The start offset of the cell that changed.
        pub start: u32,

        /// The deleted cells
        pub delete_count: u32,

        /// The new cells, if any
        #[serde(skip_serializing_if = "Option::is_none")]
        pub cells: Option<Vec<NotebookCell>>,
    }

    /// The params sent in a save notebook document notification.
    ///
    /// @since 3.17.0
    #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    pub struct DidSaveNotebookDocumentParams {
        /// The notebook document that got saved.
        pub notebook_document: NotebookDocumentIdentifier,
    }

    /// A literal to identify a notebook document in the client.
    ///
    /// @since 3.17.0
    #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    pub struct NotebookDocumentIdentifier {
        /// The notebook document's URI.
        pub uri: Uri,
    }

    /// The params sent in a close notebook document notification.
    ///
    /// @since 3.17.0
    #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
    #[serde(rename_all = "camelCase")]
    pub struct DidCloseNotebookDocumentParams {
        /// The notebook document that got closed.
        pub notebook_document: NotebookDocumentIdentifier,

        /// The text documents that represent the content
        /// of a notebook cell that got closed.
        pub cell_text_documents: Vec<TextDocumentIdentifier>,
    }
}