Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve markdown's ui theme #1363

Merged
merged 1 commit into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, but do we need these extra scopes? We can simplify and remove hover/completion suffix

Copy link
Contributor Author

@cossonleo cossonleo Dec 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markup.raw.inlinemarkup.heading not only used in editor veiw but also used in popup ui. The two ui has own background. Some theme maybe conflict on these.

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