lsp_types/
document_link.rs

1use crate::{
2    PartialResultParams, Range, TextDocumentIdentifier, Uri, WorkDoneProgressOptions,
3    WorkDoneProgressParams,
4};
5use serde::{Deserialize, Serialize};
6use serde_json::Value;
7
8#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
9#[serde(rename_all = "camelCase")]
10pub struct DocumentLinkClientCapabilities {
11    /// Whether document link supports dynamic registration.
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub dynamic_registration: Option<bool>,
14
15    /// Whether the client support the `tooltip` property on `DocumentLink`.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub tooltip_support: Option<bool>,
18}
19
20#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
21#[serde(rename_all = "camelCase")]
22pub struct DocumentLinkOptions {
23    /// Document links have a resolve provider as well.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub resolve_provider: Option<bool>,
26
27    #[serde(flatten)]
28    pub work_done_progress_options: WorkDoneProgressOptions,
29}
30
31#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
32#[serde(rename_all = "camelCase")]
33pub struct DocumentLinkParams {
34    /// The document to provide document links for.
35    pub text_document: TextDocumentIdentifier,
36
37    #[serde(flatten)]
38    pub work_done_progress_params: WorkDoneProgressParams,
39
40    #[serde(flatten)]
41    pub partial_result_params: PartialResultParams,
42}
43
44/// A document link is a range in a text document that links to an internal or external resource, like another
45/// text document or a web site.
46#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
47pub struct DocumentLink {
48    /// The range this link applies to.
49    pub range: Range,
50    /// The uri this link points to.
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub target: Option<Uri>,
53
54    /// The tooltip text when you hover over this link.
55    ///
56    /// If a tooltip is provided, is will be displayed in a string that includes instructions on how to
57    /// trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary depending on OS,
58    /// user settings, and localization.
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub tooltip: Option<String>,
61
62    /// A data entry field that is preserved on a document link between a DocumentLinkRequest
63    /// and a DocumentLinkResolveRequest.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub data: Option<Value>,
66}