Update status bar theming

Co-Authored-By: Nate Butler <iamnbutler@gmail.com>
This commit is contained in:
Conrad Irwin 2023-07-25 10:58:44 -06:00
parent baa16a2fc6
commit 1f65effe57
7 changed files with 25 additions and 28 deletions

1
Cargo.lock generated
View file

@ -8514,6 +8514,7 @@ dependencies = [
"indoc", "indoc",
"itertools", "itertools",
"language", "language",
"language_selector",
"log", "log",
"nvim-rs", "nvim-rs",
"parking_lot 0.11.2", "parking_lot 0.11.2",

View file

@ -402,7 +402,7 @@ pub struct StatusBar {
pub height: f32, pub height: f32,
pub item_spacing: f32, pub item_spacing: f32,
pub cursor_position: TextStyle, pub cursor_position: TextStyle,
pub vim_mode_indicator: TextStyle, pub vim_mode_indicator: ContainedText,
pub active_language: Interactive<ContainedText>, pub active_language: Interactive<ContainedText>,
pub auto_update_progress_message: TextStyle, pub auto_update_progress_message: TextStyle,
pub auto_update_done_message: TextStyle, pub auto_update_done_message: TextStyle,

View file

@ -33,6 +33,7 @@ search = { path = "../search" }
settings = { path = "../settings" } settings = { path = "../settings" }
workspace = { path = "../workspace" } workspace = { path = "../workspace" }
theme = { path = "../theme" } theme = { path = "../theme" }
language_selector = { path = "../language_selector"}
[dev-dependencies] [dev-dependencies]
indoc.workspace = true indoc.workspace = true

View file

@ -40,7 +40,10 @@ impl View for ModeIndicator {
Mode::Visual { line: false } => "-- VISUAL --", Mode::Visual { line: false } => "-- VISUAL --",
Mode::Visual { line: true } => "VISUAL LINE ", Mode::Visual { line: true } => "VISUAL LINE ",
}; };
Label::new(text, theme.vim_mode_indicator.clone()).into_any() Label::new(text, theme.vim_mode_indicator.text.clone())
.contained()
.with_style(theme.vim_mode_indicator.container)
.into_any()
} }
} }

View file

@ -289,9 +289,8 @@ impl Vim {
Some(cx.add_view(|_| ModeIndicator::new(vim.state.mode))); Some(cx.add_view(|_| ModeIndicator::new(vim.state.mode)));
}; };
let mode_indicator = vim.mode_indicator.as_ref().unwrap(); let mode_indicator = vim.mode_indicator.as_ref().unwrap();
// TODO: would it be better to depend on the diagnostics crate let position = status_bar
// so we can pass the type directly? .position_of_item::<language_selector::ActiveBufferLanguage>();
let position = status_bar.position_of_named_item("DiagnosticIndicator");
if let Some(position) = position { if let Some(position) = position {
status_bar.insert_item_after(position, mode_indicator.clone(), cx) status_bar.insert_item_after(position, mode_indicator.clone(), cx)
} else { } else {

View file

@ -107,17 +107,13 @@ impl StatusBar {
where where
T: StatusItemView, T: StatusItemView,
{ {
self.position_of_named_item(T::ui_name())
}
pub fn position_of_named_item(&self, name: &str) -> Option<usize> {
for (index, item) in self.left_items.iter().enumerate() { for (index, item) in self.left_items.iter().enumerate() {
if item.as_ref().ui_name() == name { if item.as_ref().ui_name() == T::ui_name() {
return Some(index); return Some(index);
} }
} }
for (index, item) in self.right_items.iter().enumerate() { for (index, item) in self.right_items.iter().enumerate() {
if item.as_ref().ui_name() == name { if item.as_ref().ui_name() == T::ui_name() {
return Some(index + self.left_items.len()); return Some(index + self.left_items.len());
} }
} }

View file

@ -1,6 +1,8 @@
import { background, border, foreground, text } from "./components" import { background, border, foreground, text } from "./components"
import { interactive, toggleable } from "../element" import { interactive, toggleable } from "../element"
import { useTheme } from "../common" import { useTheme } from "../common"
import { text_button } from "../component/text_button"
export default function status_bar(): any { export default function status_bar(): any {
const theme = useTheme() const theme = useTheme()
@ -26,21 +28,16 @@ export default function status_bar(): any {
right: 6, right: 6,
}, },
border: border(layer, { top: true, overlay: true }), border: border(layer, { top: true, overlay: true }),
cursor_position: text(layer, "sans", "variant"), cursor_position: text(layer, "sans", "variant", { size: "xs" }),
vim_mode_indicator: text(layer, "mono", "variant"), vim_mode_indicator: {
active_language: interactive({ margin: { left: 6 },
base: { ...text(layer, "mono", "variant", { size: "xs" }),
padding: { left: 6, right: 6 }, },
...text(layer, "sans", "variant"), active_language: text_button({
}, color: "variant"
state: {
hovered: {
...text(layer, "sans", "on"),
},
},
}), }),
auto_update_progress_message: text(layer, "sans", "variant"), auto_update_progress_message: text(layer, "sans", "variant", { size: "xs" }),
auto_update_done_message: text(layer, "sans", "variant"), auto_update_done_message: text(layer, "sans", "variant", { size: "xs" }),
lsp_status: interactive({ lsp_status: interactive({
base: { base: {
...diagnostic_status_container, ...diagnostic_status_container,
@ -60,9 +57,9 @@ export default function status_bar(): any {
}), }),
diagnostic_message: interactive({ diagnostic_message: interactive({
base: { base: {
...text(layer, "sans"), ...text(layer, "sans", { size: "xs" }),
}, },
state: { hovered: text(layer, "sans", "hovered") }, state: { hovered: text(layer, "sans", "hovered", { size: "xs" }) },
}), }),
diagnostic_summary: interactive({ diagnostic_summary: interactive({
base: { base: {
@ -118,7 +115,7 @@ export default function status_bar(): any {
icon_color: foreground(layer, "variant"), icon_color: foreground(layer, "variant"),
label: { label: {
margin: { left: 6 }, margin: { left: 6 },
...text(layer, "sans", { size: "sm" }), ...text(layer, "sans", { size: "xs" }),
}, },
}, },
state: { state: {