lsp_types/
hover.rs
1use serde::{Deserialize, Serialize};
2
3use crate::{
4 MarkedString, MarkupContent, MarkupKind, Range, TextDocumentPositionParams,
5 TextDocumentRegistrationOptions, WorkDoneProgressOptions, WorkDoneProgressParams,
6};
7
8#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
9#[serde(rename_all = "camelCase")]
10pub struct HoverClientCapabilities {
11 #[serde(skip_serializing_if = "Option::is_none")]
13 pub dynamic_registration: Option<bool>,
14
15 #[serde(skip_serializing_if = "Option::is_none")]
18 pub content_format: Option<Vec<MarkupKind>>,
19}
20
21#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
23#[serde(rename_all = "camelCase")]
24pub struct HoverOptions {
25 #[serde(flatten)]
26 pub work_done_progress_options: WorkDoneProgressOptions,
27}
28
29#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
30#[serde(rename_all = "camelCase")]
31pub struct HoverRegistrationOptions {
32 #[serde(flatten)]
33 pub text_document_registration_options: TextDocumentRegistrationOptions,
34
35 #[serde(flatten)]
36 pub hover_options: HoverOptions,
37}
38
39#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
40#[serde(untagged)]
41pub enum HoverProviderCapability {
42 Simple(bool),
43 Options(HoverOptions),
44}
45
46impl From<HoverOptions> for HoverProviderCapability {
47 fn from(from: HoverOptions) -> Self {
48 Self::Options(from)
49 }
50}
51
52impl From<bool> for HoverProviderCapability {
53 fn from(from: bool) -> Self {
54 Self::Simple(from)
55 }
56}
57
58#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
59#[serde(rename_all = "camelCase")]
60pub struct HoverParams {
61 #[serde(flatten)]
62 pub text_document_position_params: TextDocumentPositionParams,
63
64 #[serde(flatten)]
65 pub work_done_progress_params: WorkDoneProgressParams,
66}
67
68#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
70pub struct Hover {
71 pub contents: HoverContents,
73 #[serde(skip_serializing_if = "Option::is_none")]
76 pub range: Option<Range>,
77}
78
79#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum HoverContents {
83 Scalar(MarkedString),
84 Array(Vec<MarkedString>),
85 Markup(MarkupContent),
86}