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

helix 22.12: custom theme fails to deserialize #5043

Closed
dssgabriel opened this issue Dec 7, 2022 · 4 comments
Closed

helix 22.12: custom theme fails to deserialize #5043

dssgabriel opened this issue Dec 7, 2022 · 4 comments

Comments

@dssgabriel
Copy link

dssgabriel commented Dec 7, 2022

Hi! I updated today to helix 22.12 and my custom theme fails to load, although it worked fine under helix 22.08.1.

Looking at the log file, I get the following warning at helix's startup:

2022-12-07T14:05:08.163 helix_term::application [WARN] failed to load theme `chocolate` - Failed to deserialize theme

I rebuilt helix from source today (latest commit to master at the moment of writing):

$ hx --version
helix 22.12 (a4de86e7)

I have no idea where this issue can come from. Reading through the changelog, I do not see anything in the breaking changes that could have messed up my theme configuration. Any idea of what could be causing this?
Otherwise, my config works fine.

Below is my theme config file, just in case I missed something in there:
# Chocolate (dark)
# Author: Gabriel Dos Santos <dss.gabriel@protonmail.com>
# Originally made by snakedye: https://gitlab.com/snakedye/chocolate
# License: MIT License
# -----------------------------------------------------------------------------

# User interface
# -----------------------------------------------------------------------------
"markup.heading" = "yellow"
"markup.list" = "beige"
"markup.bold" = { fg = "yellow", modifiers = ["bold"] }
"markup.italic" = { fg = "yellow", modifiers = ["italic"] }
"markup.link.url" = { fg = "aqua", modifiers = ["underlined"] }
"markup.link.text" = "aqua"
"markup.quote" = "beige"
"markup.raw" = "green"

"ui.background" = { fg = "white", bg = "black" }
"ui.background.separator" = "lightgray"

"ui.cursor" = { fg = "black", bg = "white" }
"ui.cursor.select" = { fg = "white", bg = "lightgray" }
"ui.cursor.match" = { fg = "white", bg = "lightgray" }
"ui.cursor.primary" = { fg = "black", bg = "white" }

"ui.linenr" = "lightgray"
"ui.linenr.selected" = { fg = "yellow", modifiers = ["bold"] }

"ui.statusline" = { fg = "white", bg = "gray" }
"ui.statusline.insert" = { fg = "gray", bg = "aqua" }
"ui.statusline.select" = { fg = "gray", bg = "magenta" }

"ui.popup" = { fg = "white", bg = "gray" }
"ui.window" = { fg = "white", bg = "darkgray" }
"ui.help" = { fg = "white", bg = "lightgray", modifiers = ["bold", "italic"] }

"ui.text" = "white"
"ui.text.focus" = { fg = "white", bg = "lightgray" }
"ui.text.info" = { fg = "white", bg = "gray" }

"ui.virtual.ruler" = { bg = "darkgray" }
"ui.virtual.whitespace" = "darkergray"
"ui.virtual.indent-guide" = "darkergray"

"ui.menu" = { fg = "white", bg = "lightgray" }
"ui.menu.selected" = { fg = "yellow", bg = "gray", modifiers = ["bold"] }
"ui.menu.scroll" = { fg = "white", bg = "gray" }

"ui.selection" = { bg = "gray" }

"ui.cursorline.primary" = { bg = "darkgray" }
"ui.cursorline.secondary" = { bg = "darkergray" }

"warning" = "orange"
"error" = "red"
"info" = "green"
"hint" = "aqua"
"diagnostic" = "magenta"

# Syntax highlighting
# -----------------------------------------------------------------------------
"keyword.directive" = "magenta"
"keyword.operator" = "aqua"
"keyword.storage.type" = "red"
"keyword.storage.modifier" = "aqua"
"keyword" = "red"

"namespace" = "green"
"type" = "yellow"
"constructor" = "aqua"
"attribute" = "magenta"

"function.macro" = "magenta"
"function.special" = "magenta"
"function.special" = "aqua"
"function" = "blue"

"variable.builtin" = "orange"
"variable.other" = "magenta"
"variable.parameter" = "green"
"variable" = "beige"

"string.url" = { fg = "aqua", modifiers = ["italic", "underlined"] }
"string" = "green"

"constant" = "orange"
"label" = "magenta"
"tag" = "beige"
"comment" = "lightergray"
"operator" = "white"
"punctuation" = "white"
"escape" = { fg = "gray", bg = "gray" }

"diff.plus" = "green"
"diff.minus" = "red"
"diff.delta" = "yellow"

# Color palette
# -----------------------------------------------------------------------------
[palette]
black = "#252221"
red = "#c65f5f"
green = "#859e82"
yellow = "#d9b27c"
blue = "#728797"
magenta = "#998396"
aqua = "#829e9b"
gray = "#3d3837"
orange = "#d08b65"
beige = "#ab9382"
lightgray = "#413c3a"
lightergray = "#645f5d"
darkgray = "#2f2c2b"
darkergray = "#2b2827"
white = "#c8baa4"
@the-mikedavis
Copy link
Member

It looks like the toml parser doesn't like the duplicated "function.special" key on L73-L74, though 22.08.1 does accept this theme 🤔

@dssgabriel
Copy link
Author

That was the culprit! Thank you very much, my theme is back 🙂
In case something like this happens again, is there a way for me to check what went wrong during the TOML parsing (e.g. in this case the duplicated key)?

@pascalkuthe
Copy link
Member

That was the culprit! Thank you very much, my theme is back slightly_smiling_face In case something like this happens again, is there a way for me to check what went wrong during the TOML parsing (e.g. in this case the duplicated key)?

I would recommended tablo for generic toml validation: https://taplo.tamasfe.dev/.
It can be installed as a standalone CLI or you can install it as an LSP and use it directly with helix while editing a file

@pascalkuthe
Copy link
Member

The change in behaviour is caused by #3067 which switched the theme reading to serialize to a toml::Value first and converts that to a Theme later instead of deserializing to a Theme directly. Usually serde is permissive about duplicate map keys (unless you specify an option to be strict). However since toml does not allow duplicate keys toml::Value uses this option. I believe that it should have always been an error and that the current behavior is more correct then this used to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants