Completion: Render non-markdown docs too
This commit is contained in:
parent
2c48d65b15
commit
3810650a6b
1 changed files with 36 additions and 16 deletions
|
@ -230,20 +230,43 @@ impl Component for Completion {
|
|||
// option.detail
|
||||
// ---
|
||||
// option.documentation
|
||||
match &option.documentation {
|
||||
Some(lsp::Documentation::String(s))
|
||||
|
||||
let doc = match &option.documentation {
|
||||
Some(lsp::Documentation::String(contents))
|
||||
| Some(lsp::Documentation::MarkupContent(lsp::MarkupContent {
|
||||
kind: lsp::MarkupKind::PlainText,
|
||||
value: s,
|
||||
value: contents,
|
||||
})) => {
|
||||
// TODO: convert to wrapped text
|
||||
let doc = s;
|
||||
Markdown::new(format!(
|
||||
"```rust\n{}\n```\n{}",
|
||||
option.detail.as_deref().unwrap_or_default(),
|
||||
contents.clone()
|
||||
))
|
||||
}
|
||||
Some(lsp::Documentation::MarkupContent(lsp::MarkupContent {
|
||||
kind: lsp::MarkupKind::Markdown,
|
||||
value: contents,
|
||||
})) => {
|
||||
let doc = Markdown::new(contents.clone());
|
||||
// TODO: set language based on doc scope
|
||||
Markdown::new(format!(
|
||||
"```rust\n{}\n```\n{}",
|
||||
option.detail.as_deref().unwrap_or_default(),
|
||||
contents.clone()
|
||||
))
|
||||
}
|
||||
None if option.detail.is_some() => {
|
||||
// TODO: copied from above
|
||||
|
||||
// TODO: set language based on doc scope
|
||||
Markdown::new(format!(
|
||||
"```rust\n{}\n```",
|
||||
option.detail.as_deref().unwrap_or_default(),
|
||||
))
|
||||
}
|
||||
None => return,
|
||||
};
|
||||
|
||||
let half = area.height / 2;
|
||||
let height = 15.min(half);
|
||||
// -2 to subtract command line + statusline. a bit of a hack, because of splits.
|
||||
|
@ -254,8 +277,5 @@ impl Component for Completion {
|
|||
surface.clear_with(area, background);
|
||||
doc.render(area, surface, cx);
|
||||
}
|
||||
None => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue