Support types in the standard library (#5651)
* Parse an unparse type decls (and refactor impl attributes slightly) Signed-off-by: Nick Cameron <nrc@ncameron.org> * Remove special treatment of geometric types from parser and executor Signed-off-by: Nick Cameron <nrc@ncameron.org> * Generate docs for std types Signed-off-by: Nick Cameron <nrc@ncameron.org> * Hover tool-tips for types and fixup the frontend Signed-off-by: Nick Cameron <nrc@ncameron.org> * Fixes Signed-off-by: Nick Cameron <nrc@ncameron.org> --------- Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -1105,6 +1105,34 @@ impl LanguageServer for Backend {
|
||||
range: Some(range),
|
||||
}))
|
||||
}
|
||||
Hover::Type { name, range } => {
|
||||
let Some(completion) = self.stdlib_completions.get(&name) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let Some(docs) = &completion.documentation else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
let docs = match docs {
|
||||
Documentation::String(docs) => docs,
|
||||
Documentation::MarkupContent(MarkupContent { value, .. }) => value,
|
||||
};
|
||||
|
||||
let docs = if docs.len() > 320 {
|
||||
let end = docs.find("\n\n").or_else(|| docs.find("\n\r\n")).unwrap_or(320);
|
||||
&docs[..end]
|
||||
} else {
|
||||
&**docs
|
||||
};
|
||||
|
||||
Ok(Some(LspHover {
|
||||
contents: HoverContents::Markup(MarkupContent {
|
||||
kind: MarkupKind::Markdown,
|
||||
value: format!("```\n{}\n```\n\n{}", name, docs),
|
||||
}),
|
||||
range: Some(range),
|
||||
}))
|
||||
}
|
||||
Hover::KwArg {
|
||||
name,
|
||||
callee_name,
|
||||
|
Reference in New Issue
Block a user