Commit 952fea55b0

952fea55b0482683dfeec5e0f5ae7c345ec29eb8

parent: 195cabfdc3

Unregistered key

vaw <git@nlih.de> · 2026-09-26 19:43 UTC
committer: <noreply@github.com>

Add `theme.completion` to style the completion menu (#755)

Layout: unified · split

docs/iamb.5 +8
@@ -835,6 +835,14 @@ to force all usernames to use the value in
835835.Sy color
836836or its inherited value from
837837.Sy "theme.default" .
838.It Sy completion
839For controlling how the completion menu is styled.
840.Bl -tag -width Ds
841.It Sy default
842Configure the default style for entries in the menu.
843.It Sy selected
844Configure how the selected entry is styled.
845.El
838846.It Sy windows
839847For controlling how the windows are styled.
840848.Bl -tag -width Ds
src/config/theme.rs +55
@@ -34,6 +34,21 @@ pub fn default_theme() -> Theme {
3434 title: Stylable::with_modifiers(StyleModifier::BOLD),
3535 ..Default::default()
3636 },
37 completion: ThemeCompletion {
38 default: Stylable {
39 color: Some(Color::Reset),
40 background: Some(Color::Reset),
41 modifiers: vec![
42 ModifierChange::Remove(StyleModifier::all()),
43 ModifierChange::Insert(StyleModifier::REVERSED),
44 ],
45 },
46 selected: Stylable {
47 color: Some(Color::Yellow),
48 background: Some(Color::Black),
49 modifiers: vec![ModifierChange::Remove(StyleModifier::REVERSED)],
50 },
51 },
3752 timeline: ThemeTimeline {
3853 date: Stylable::with_modifiers(StyleModifier::BOLD),
3954 unread_marker: Stylable::with_modifiers(StyleModifier::DIM),
@@ -241,6 +256,10 @@ pub struct Theme {
241256 /// Configuration for styling windows.
242257 #[serde(default)]
243258 windows: ThemeWindows,
259
260 /// Configuration for the completion menu.
261 #[serde(default)]
262 completion: ThemeCompletion,
244263}
245264
246265impl Theme {
@@ -256,6 +275,7 @@ impl Theme {
256275 rooms: self.rooms.merge(other.rooms),
257276 users: self.users.merge(other.users),
258277 windows: self.windows.merge(other.windows),
278 completion: self.completion.merge(other.completion),
259279 }
260280 }
261281
@@ -273,6 +293,7 @@ impl Theme {
273293 tabs: self.tabs.values(base),
274294 users: self.users.values(base),
275295 windows: self.windows.values(base),
296 completion: self.completion.values(base),
276297 }
277298 }
278299}
@@ -308,6 +329,9 @@ pub struct ThemeValues {
308329
309330 /// Styling for rendering windows.
310331 pub windows: ThemeWindowsValues,
332
333 /// Styling for the completion menu.
334 pub completion: ThemeCompletionValues,
311335}
312336
313337#[derive(Clone, Debug, Default, Deserialize)]
@@ -644,6 +668,37 @@ pub struct ThemeTimelineValues {
644668 pub unread_marker: Style,
645669}
646670
671#[derive(Clone, Debug, Default, Deserialize)]
672struct ThemeCompletion {
673 #[serde(default)]
674 default: Stylable,
675
676 #[serde(default)]
677 selected: Stylable,
678}
679
680impl ThemeCompletion {
681 fn merge(self, other: Self) -> Self {
682 Self {
683 default: self.default.merge(other.default),
684 selected: self.selected.merge(other.selected),
685 }
686 }
687
688 fn values(self, base: Style) -> ThemeCompletionValues {
689 let default = base.patch(self.default);
690 let selected = default.patch(self.selected);
691
692 ThemeCompletionValues { default, selected }
693 }
694}
695
696#[derive(Clone, Debug, Default)]
697pub struct ThemeCompletionValues {
698 pub default: Style,
699 pub selected: Style,
700}
701
647702#[derive(Clone, Debug, Default, Deserialize)]
648703struct ThemeWindows {
649704 #[serde(default)]
src/main.rs +2
@@ -318,6 +318,8 @@ impl Application {
318318 .cmdbar_style(theme.cmdbar.default)
319319 .tab_style(theme.tabs.title)
320320 .tab_style_focused(theme.tabs.title_focused)
321 .completion_style(theme.completion.default)
322 .completion_style_selected(theme.completion.selected)
321323 .focus(focused);
322324 f.render_stateful_widget(screen, area, sstate);
323325