Add hover actions as LSP extension

This commit is contained in:
vsrs
2020-06-03 14:15:54 +03:00
parent 913a623281
commit 7d0dd17b09
11 changed files with 351 additions and 56 deletions

View File

@@ -260,3 +260,37 @@ pub struct SnippetTextEdit {
#[serde(skip_serializing_if = "Option::is_none")]
pub insert_text_format: Option<lsp_types::InsertTextFormat>,
}
pub enum HoverRequest {}
impl Request for HoverRequest {
type Params = lsp_types::HoverParams;
type Result = Option<Hover>;
const METHOD: &'static str = "textDocument/hover";
}
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
pub struct Hover {
pub contents: lsp_types::HoverContents,
#[serde(skip_serializing_if = "Option::is_none")]
pub range: Option<Range>,
#[serde(skip_serializing_if = "Option::is_none")]
pub actions: Option<Vec<CommandLinkGroup>>,
}
#[derive(Debug, PartialEq, Eq, Clone, Default, Deserialize, Serialize)]
pub struct CommandLinkGroup {
pub title: Option<String>,
pub commands: Vec<CommandLink>,
}
// LSP v3.15 Command does not have a `tooltip` field, vscode supports one.
#[derive(Debug, PartialEq, Eq, Clone, Default, Deserialize, Serialize)]
pub struct CommandLink {
pub title: String,
pub command: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub tooltip: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub arguments: Option<Vec<serde_json::Value>>,
}