Default rulers color to red (#2669)

* Default rulers color to red

Currently if the theme a user is using doesn't have `ui.virtual.rulers`
set and they set up a ruler it just fails silently making it really hard
to figure out what went wrong. Did they set incorrectly set the ruler?
Are they using an outdated version of Helix that doesn't support rulers?

This happened to me today, I even switched to the default theme with
the assumption that maybe my theme just doesn't have the rulers setup
properly and it still didn't work.

Not sure if this is a good idea or not, feel free to suggest better
alternatives!

* Use builtin Style methods instead of Bevy style defaults

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

* Only default the style if there's no ui or ui.virtual

* Update themes style from ui.virtual to ui.virtual.whitespace

* Revert ui.virtual change in onelight theme

* Prefer unwrap_or_else

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
pull/2359/head^2
Mathspy 2 years ago committed by GitHub
parent 9f676dab57
commit fa4934cff9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -20,7 +20,7 @@ use helix_core::{
use helix_view::{ use helix_view::{
document::{Mode, SCRATCH_BUFFER_NAME}, document::{Mode, SCRATCH_BUFFER_NAME},
editor::{CompleteAction, CursorShapeConfig}, editor::{CompleteAction, CursorShapeConfig},
graphics::{CursorKind, Modifier, Rect, Style}, graphics::{Color, CursorKind, Modifier, Rect, Style},
input::KeyEvent, input::KeyEvent,
keyboard::{KeyCode, KeyModifiers}, keyboard::{KeyCode, KeyModifiers},
Document, Editor, Theme, View, Document, Editor, Theme, View,
@ -170,7 +170,9 @@ impl EditorView {
theme: &Theme, theme: &Theme,
) { ) {
let editor_rulers = &editor.config().rulers; let editor_rulers = &editor.config().rulers;
let ruler_theme = theme.get("ui.virtual.ruler"); let ruler_theme = theme
.try_get("ui.virtual.ruler")
.unwrap_or_else(|| Style::default().bg(Color::Red));
let rulers = doc let rulers = doc
.language_config() .language_config()

@ -1,7 +1,7 @@
# Author: RayGervais <raygervais@hotmail.ca> # Author: RayGervais <raygervais@hotmail.ca>
"ui.background" = { bg = "base00" } "ui.background" = { bg = "base00" }
"ui.virtual" = "base03" "ui.virtual.whitespace" = "base03"
"ui.menu" = { fg = "base05", bg = "base01" } "ui.menu" = { fg = "base05", bg = "base01" }
"ui.menu.selected" = { fg = "base01", bg = "base04" } "ui.menu.selected" = { fg = "base01", bg = "base04" }
"ui.linenr" = { fg = "base03", bg = "base01" } "ui.linenr" = { fg = "base03", bg = "base01" }

@ -12,7 +12,7 @@
"ui.statusline" = { fg = "base04", bg = "base01" } "ui.statusline" = { fg = "base04", bg = "base01" }
"ui.cursor" = { fg = "base04", modifiers = ["reversed"] } "ui.cursor" = { fg = "base04", modifiers = ["reversed"] }
"ui.cursor.primary" = { fg = "base05", modifiers = ["reversed"] } "ui.cursor.primary" = { fg = "base05", modifiers = ["reversed"] }
"ui.virtual" = "base03" "ui.virtual.whitespace" = "base03"
"ui.text" = "base05" "ui.text" = "base05"
"operator" = "base05" "operator" = "base05"
"ui.text.focus" = "base05" "ui.text.focus" = "base05"

@ -13,7 +13,7 @@
"ui.help" = { fg = "white", bg = "black" } "ui.help" = { fg = "white", bg = "black" }
"ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] } "ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] }
"ui.cursor.primary" = { fg = "light-gray", modifiers = ["reversed"] } "ui.cursor.primary" = { fg = "light-gray", modifiers = ["reversed"] }
"ui.virtual" = "light-gray" "ui.virtual.whitespace" = "light-gray"
"variable" = "light-red" "variable" = "light-red"
"constant.numeric" = "yellow" "constant.numeric" = "yellow"
"constant" = "yellow" "constant" = "yellow"

@ -53,7 +53,7 @@
"ui.text" = { fg = "#e5ded6" } "ui.text" = { fg = "#e5ded6" }
"ui.text.focus" = { fg = "#e5ded6", modifiers= ["bold"] } "ui.text.focus" = { fg = "#e5ded6", modifiers= ["bold"] }
"ui.virtual" = "#627d9d" "ui.virtual.whitespace" = "#627d9d"
"ui.selection" = { bg = "#313f4e" } "ui.selection" = { bg = "#313f4e" }
# "ui.cursor.match" # TODO might want to override this because dimmed is not widely supported # "ui.cursor.match" # TODO might want to override this because dimmed is not widely supported

@ -44,7 +44,7 @@
"ui.menu" = { fg = "lilac", bg = "berry_saturated" } "ui.menu" = { fg = "lilac", bg = "berry_saturated" }
"ui.menu.selected" = { fg = "mint", bg = "berry_saturated" } "ui.menu.selected" = { fg = "mint", bg = "berry_saturated" }
"ui.selection" = { bg = "berry_saturated" } "ui.selection" = { bg = "berry_saturated" }
"ui.virtual" = { fg = "berry_desaturated" } "ui.virtual.whitespace" = { fg = "berry_desaturated" }
"diff.plus" = { fg = "mint" } "diff.plus" = { fg = "mint" }
"diff.delta" = { fg = "gold" } "diff.delta" = { fg = "gold" }

@ -48,7 +48,7 @@ label = "peach"
"ui.text" = { fg = "pink" } "ui.text" = { fg = "pink" }
"ui.text.focus" = { fg = "white" } "ui.text.focus" = { fg = "white" }
"ui.virtual" = { fg = "gray_0" } "ui.virtual.whitespace" = { fg = "gray_0" }
"ui.selection" = { bg = "#540099" } "ui.selection" = { bg = "#540099" }
"ui.selection.primary" = { bg = "#540099" } "ui.selection.primary" = { bg = "#540099" }

@ -78,7 +78,7 @@
"ui.text" = { fg = "text" } "ui.text" = { fg = "text" }
"ui.text.focus" = { fg = "white" } "ui.text.focus" = { fg = "white" }
"ui.virtual" = { fg = "dark_gray" } "ui.virtual.whitespace" = { fg = "dark_gray" }
"ui.virtual.ruler" = { bg = "borders" } "ui.virtual.ruler" = { bg = "borders" }
"warning" = { fg = "gold2" } "warning" = { fg = "gold2" }

@ -36,7 +36,7 @@
"ui.text" = { fg = "foreground" } "ui.text" = { fg = "foreground" }
"ui.text.focus" = { fg = "cyan" } "ui.text.focus" = { fg = "cyan" }
"ui.window" = { fg = "foreground" } "ui.window" = { fg = "foreground" }
"ui.virtual" = { fg = "comment" } "ui.virtual.whitespace" = { fg = "comment" }
"error" = { fg = "red" } "error" = { fg = "red" }
"warning" = { fg = "cyan" } "warning" = { fg = "cyan" }

@ -70,7 +70,7 @@
"ui.menu" = { fg = "fg", bg = "bg2" } "ui.menu" = { fg = "fg", bg = "bg2" }
"ui.menu.selected" = { fg = "bg0", bg = "green" } "ui.menu.selected" = { fg = "bg0", bg = "green" }
"ui.selection" = { bg = "bg3" } "ui.selection" = { bg = "bg3" }
"ui.virtual" = "grey0" "ui.virtual.whitespace" = "grey0"
"hint" = "blue" "hint" = "blue"
"info" = "aqua" "info" = "aqua"

@ -70,7 +70,7 @@
"ui.menu" = { fg = "fg", bg = "bg2" } "ui.menu" = { fg = "fg", bg = "bg2" }
"ui.menu.selected" = { fg = "bg0", bg = "green" } "ui.menu.selected" = { fg = "bg0", bg = "green" }
"ui.selection" = { bg = "bg3" } "ui.selection" = { bg = "bg3" }
"ui.virtual" = "grey0" "ui.virtual.whitespace" = "grey0"
"hint" = "blue" "hint" = "blue"
"info" = "aqua" "info" = "aqua"

@ -53,7 +53,7 @@
"ui.cursor.match" = { bg = "bg2" } "ui.cursor.match" = { bg = "bg2" }
"ui.menu" = { fg = "fg1", bg = "bg2" } "ui.menu" = { fg = "fg1", bg = "bg2" }
"ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] } "ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] }
"ui.virtual" = "bg2" "ui.virtual.whitespace" = "bg2"
"diagnostic" = { modifiers = ["underlined"] } "diagnostic" = { modifiers = ["underlined"] }

@ -54,7 +54,7 @@
"ui.cursor.match" = { bg = "bg2" } "ui.cursor.match" = { bg = "bg2" }
"ui.menu" = { fg = "fg1", bg = "bg2" } "ui.menu" = { fg = "fg1", bg = "bg2" }
"ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] } "ui.menu.selected" = { fg = "bg2", bg = "blue1", modifiers = ["bold"] }
"ui.virtual" = "bg2" "ui.virtual.whitespace" = "bg2"
"diagnostic" = { modifiers = ["underlined"] } "diagnostic" = { modifiers = ["underlined"] }

@ -53,7 +53,7 @@
"ui.text" = { fg = "#7B91B3" } "ui.text" = { fg = "#7B91B3" }
"ui.text.focus" = { fg = "#250E07", modifiers= ["bold"] } "ui.text.focus" = { fg = "#250E07", modifiers= ["bold"] }
"ui.virtual" = "#A6B6CE" "ui.virtual.whitespace" = "#A6B6CE"
"ui.selection" = { bg = "#540099" } "ui.selection" = { bg = "#540099" }
# "ui.cursor.match" # TODO might want to override this because dimmed is not widely supported # "ui.cursor.match" # TODO might want to override this because dimmed is not widely supported

@ -32,7 +32,7 @@
"attribute" = { fg = "fn_declaration" } "attribute" = { fg = "fn_declaration" }
"comment" = { fg = "#88846F" } "comment" = { fg = "#88846F" }
"ui.virtual" = "#88846F" "ui.virtual.whitespace" = "#88846F"
"string" = { fg = "#e6db74" } "string" = { fg = "#e6db74" }
"constant.character" = { fg = "#e6db74" } "constant.character" = { fg = "#e6db74" }

@ -6,7 +6,7 @@
"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] } "ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
"ui.menu" = { fg = "base8", bg = "base3" } "ui.menu" = { fg = "base8", bg = "base3" }
"ui.menu.selected" = { fg = "base2", bg = "yellow" } "ui.menu.selected" = { fg = "base2", bg = "yellow" }
"ui.virtual" = "base5" "ui.virtual.whitespace" = "base5"
"info" = "base8" "info" = "base8"
"hint" = "base8" "hint" = "base8"

@ -6,7 +6,7 @@
"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] } "ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
"ui.menu" = { fg = "base8", bg = "base3" } "ui.menu" = { fg = "base8", bg = "base3" }
"ui.menu.selected" = { fg = "base2", bg = "yellow" } "ui.menu.selected" = { fg = "base2", bg = "yellow" }
"ui.virtual" = "base5" "ui.virtual.whitespace" = "base5"
"info" = "base8" "info" = "base8"
"hint" = "base8" "hint" = "base8"

@ -6,7 +6,7 @@
"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] } "ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
"ui.menu" = { fg = "base8", bg = "base3" } "ui.menu" = { fg = "base8", bg = "base3" }
"ui.menu.selected" = { fg = "base2", bg = "yellow" } "ui.menu.selected" = { fg = "base2", bg = "yellow" }
"ui.virtual" = "base5" "ui.virtual.whitespace" = "base5"
"info" = "base8" "info" = "base8"
"hint" = "base8" "hint" = "base8"

@ -6,7 +6,7 @@
"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] } "ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
"ui.menu" = { fg = "base8", bg = "base3" } "ui.menu" = { fg = "base8", bg = "base3" }
"ui.menu.selected" = { fg = "base2", bg = "yellow" } "ui.menu.selected" = { fg = "base2", bg = "yellow" }
"ui.virtual" = "base5" "ui.virtual.whitespace" = "base5"
"info" = "base8" "info" = "base8"
"hint" = "base8" "hint" = "base8"

@ -6,7 +6,7 @@
"ui.text.focus" = { fg = "yellow", modifiers= ["bold"] } "ui.text.focus" = { fg = "yellow", modifiers= ["bold"] }
"ui.menu" = { fg = "base8", bg = "base3" } "ui.menu" = { fg = "base8", bg = "base3" }
"ui.menu.selected" = { fg = "base2", bg = "yellow" } "ui.menu.selected" = { fg = "base2", bg = "yellow" }
"ui.virtual" = "base5" "ui.virtual.whitespace" = "base5"
"info" = "base8" "info" = "base8"
"hint" = "base8" "hint" = "base8"

@ -4,7 +4,7 @@
"ui.text.focus" = { fg = "nord8", modifiers= ["bold"] } "ui.text.focus" = { fg = "nord8", modifiers= ["bold"] }
"ui.menu" = { fg = "nord6", bg = "#232d38" } "ui.menu" = { fg = "nord6", bg = "#232d38" }
"ui.menu.selected" = { fg = "nord8", bg = "nord2" } "ui.menu.selected" = { fg = "nord8", bg = "nord2" }
"ui.virtual" = "gray" "ui.virtual.whitespace" = "gray"
"info" = "nord8" "info" = "nord8"
"hint" = "nord8" "hint" = "nord8"

@ -14,7 +14,7 @@
"ui.text" = { fg = "text" } "ui.text" = { fg = "text" }
"ui.text.focus" = { fg = "foam", modifiers = ["bold"]} "ui.text.focus" = { fg = "foam", modifiers = ["bold"]}
"ui.text.info" = {fg = "pine", modifiers = ["bold"]} "ui.text.info" = {fg = "pine", modifiers = ["bold"]}
"ui.virtual" = "highlight" "ui.virtual.whitespace" = "highlight"
"operator" = "rose" "operator" = "rose"
"variable" = "text" "variable" = "text"
"constant.numeric" = "iris" "constant.numeric" = "iris"

@ -14,7 +14,7 @@
"ui.text" = { fg = "text" } "ui.text" = { fg = "text" }
"ui.text.focus" = { fg = "foam", modifiers = ["bold"]} "ui.text.focus" = { fg = "foam", modifiers = ["bold"]}
"ui.text.info" = {fg = "pine", modifiers = ["bold"]} "ui.text.info" = {fg = "pine", modifiers = ["bold"]}
"ui.virtual" = "highlight" "ui.virtual.whitespace" = "highlight"
"operator" = "rose" "operator" = "rose"
"variable" = "text" "variable" = "text"
"number" = "iris" "number" = "iris"

@ -50,7 +50,7 @@
"ui.menu" = { fg = "fg", bg = "bg2" } "ui.menu" = { fg = "fg", bg = "bg2" }
"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" } "ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
"ui.selection" = { bg = "bg3" } "ui.selection" = { bg = "bg3" }
"ui.virtual" = "grey2" "ui.virtual.whitespace" = "grey2"
"hint" = "blue" "hint" = "blue"
"info" = "aqua" "info" = "aqua"

@ -50,7 +50,7 @@
"ui.menu" = { fg = "bg0", bg = "bg3" } "ui.menu" = { fg = "bg0", bg = "bg3" }
"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" } "ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
"ui.selection" = { fg = "bg0", bg = "bg3" } "ui.selection" = { fg = "bg0", bg = "bg3" }
"ui.virtual" = { fg = "bg2" } "ui.virtual.whitespace" = { fg = "bg2" }
"hint" = "blue" "hint" = "blue"
"info" = "aqua" "info" = "aqua"

@ -38,7 +38,7 @@
"ui.text" = { fg = "foreground" } "ui.text" = { fg = "foreground" }
"ui.text.focus" = { fg = "cyan" } "ui.text.focus" = { fg = "cyan" }
"ui.window" = { fg = "foreground" } "ui.window" = { fg = "foreground" }
"ui.virtual" = { fg = "comment" } "ui.virtual.whitespace" = { fg = "comment" }
"error" = { fg = "red" } "error" = { fg = "red" }
"warning" = { fg = "cyan" } "warning" = { fg = "cyan" }

@ -39,7 +39,7 @@
# 背景 # 背景
"ui.background" = { bg = "base03" } "ui.background" = { bg = "base03" }
"ui.virtual" = { fg = "base01" } "ui.virtual.whitespace" = { fg = "base01" }
# 行号栏 # 行号栏
"ui.linenr" = { fg = "base0", bg = "base02" } "ui.linenr" = { fg = "base0", bg = "base02" }

@ -40,7 +40,7 @@
# background # background
"ui.background" = { bg = "base03" } "ui.background" = { bg = "base03" }
"ui.virtual" = { fg = "base01" } "ui.virtual.whitespace" = { fg = "base01" }
# 行号栏 # 行号栏
# line number column # line number column

@ -64,7 +64,7 @@
"ui.cursor.match" = { bg = "bg3" } "ui.cursor.match" = { bg = "bg3" }
"ui.menu" = { fg = "fg1", bg = "bg2" } "ui.menu" = { fg = "fg1", bg = "bg2" }
"ui.menu.selected" = { fg = "#655370", bg = "#d1dcdf", modifiers = ["bold"] } "ui.menu.selected" = { fg = "#655370", bg = "#d1dcdf", modifiers = ["bold"] }
"ui.virtual" = "bg2" "ui.virtual.whitespace" = "bg2"
"diagnostic" = { modifiers = ["underlined"] } "diagnostic" = { modifiers = ["underlined"] }

Loading…
Cancel
Save