Skip to content

Commit

Permalink
Use markup scopes for the Markdown component (#1363)
Browse files Browse the repository at this point in the history
  • Loading branch information
cossonleo committed Jan 24, 2022
1 parent 4044c70 commit d49e532
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 153 deletions.
12 changes: 12 additions & 0 deletions book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ We use a similar set of scopes as

These scopes are used for theming the editor interface.

- `markup`
- `normal`
- `completion` - for completion doc popup ui
- `hover` - for hover popup ui
- `heading`
- `completion` - for completion doc popup ui
- `hover` - for hover popup ui
- `raw`
- `inline`
- `completion` - for completion doc popup ui
- `hover` - for hover popup ui


| Key | Notes |
| --- | --- |
Expand Down
3 changes: 2 additions & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5455,7 +5455,8 @@ fn hover(cx: &mut Context) {

// skip if contents empty

let contents = ui::Markdown::new(contents, editor.syn_loader.clone());
let contents =
ui::Markdown::new(contents, editor.syn_loader.clone()).style_group("hover");
let popup = Popup::new("hover", contents);
if let Some(doc_popup) = compositor.find_id("hover") {
*doc_popup = popup;
Expand Down
9 changes: 6 additions & 3 deletions helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,17 @@ impl Component for Completion {
let cursor_pos = doc.selection(view.id).primary().cursor(text);
let coords = helix_core::visual_coords_at_pos(text, cursor_pos, doc.tab_width());
let cursor_pos = (coords.row - view.offset.row) as u16;

let markdown_ui =
|content, syn_loader| Markdown::new(content, syn_loader).style_group("completion");
let mut markdown_doc = match &option.documentation {
Some(lsp::Documentation::String(contents))
| Some(lsp::Documentation::MarkupContent(lsp::MarkupContent {
kind: lsp::MarkupKind::PlainText,
value: contents,
})) => {
// TODO: convert to wrapped text
Markdown::new(
markdown_ui(
format!(
"```{}\n{}\n```\n{}",
language,
Expand All @@ -326,7 +329,7 @@ impl Component for Completion {
value: contents,
})) => {
// TODO: set language based on doc scope
Markdown::new(
markdown_ui(
format!(
"```{}\n{}\n```\n{}",
language,
Expand All @@ -340,7 +343,7 @@ impl Component for Completion {
// TODO: copied from above

// TODO: set language based on doc scope
Markdown::new(
markdown_ui(
format!(
"```{}\n{}\n```",
language,
Expand Down
Loading

0 comments on commit d49e532

Please sign in to comment.