@@ -13,7 +13,7 @@ use helix_core::{Position, Transaction};
13use helix_view::Editor;
13use helix_view::Editor;
15use crate::commands;
15use crate::commands;
16−use crate::ui::{Menu, Popup, PromptEvent};
16+use crate::ui::{Markdown, Menu, Popup, PromptEvent};
18use helix_lsp::lsp;
18use helix_lsp::lsp;
19use lsp::CompletionItem;
19use lsp::CompletionItem;
@@ -173,6 +173,47 @@ impl Component for Completion {
175 fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
175 fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
176− self.popup.render(area, surface, cx)
176+ self.popup.render(area, surface, cx);
178+ // TODO: if we have a selection, render a markdown popup on top/below with info
179+ if let Some(option) = self.popup.contents().selection() {
183+ // option.documentation
184+ match &option.documentation {
185+ Some(lsp::Documentation::String(s))
186+ | Some(lsp::Documentation::MarkupContent(lsp::MarkupContent {
187+ kind: lsp::MarkupKind::PlainText,
190+ // TODO: convert to wrapped text
193+ Some(lsp::Documentation::MarkupContent(lsp::MarkupContent {
194+ kind: lsp::MarkupKind::Markdown,
197+ let doc = Markdown::new(contents.clone());
198+ let half = area.height / 2;
199+ let height = 15.min(half);
200+ // -2 to subtract command line + statusline. a bit of a hack, because of splits.
201+ let area = Rect::new(0, area.height - height - 2, area.width, height);
204+ let background = cx.editor.theme.get("ui.popup");
205+ for y in area.top()..area.bottom() {
206+ for x in area.left()..area.right() {
207+ let cell = surface.get_mut(x, y);
209+ // cell.symbol.clear();
210+ cell.set_style(background);
213+ doc.render(area, surface, cx);