Skip to content

Conversation

@CosmicHorrorDev
Copy link
Contributor

Resolves #478

Just a simple proof of concept for how the ideas in #478 could look. This adds in a ThemeDefaults enum and a Theme::load_default() constructor that can handle loading a single default theme

Random thoughts:

  • bincode doesn't support easily ignoring values, so all themes leading up to the one you want are still loaded
  • ThemeDefaults should be #[non_exhaustive] if you want to support adding more default themes without a semver breaking change
  • ThemeDefaults should probably derive more traits, but I left it barebones for the proof-of-concept
  • ThemeDefaults::as_theme_name() wasn't exposed publicly because of the potential confusion that the theme name should match the theme.name.unwrap() which is not the case for some of the defaults (this confused me at least)
  • Luckily this wasn't a schema change for default.themedump since bincode serializes a struct with a single field mapped to a value as just the single value

Overall this means that you can write code like this to load a single default theme which is nice when you're only dealing with single themes

use syntect::highlighting::{Theme, ThemeDefaults};

let inspired_gh = Theme::load_default(ThemeDefaults::InspiredGitHub);

@CosmicHorrorDev CosmicHorrorDev marked this pull request as ready for review May 29, 2023 18:43
@CosmicHorrorDev CosmicHorrorDev force-pushed the loading-single-default branch from 56583b8 to d567ad4 Compare May 29, 2023 18:45
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

Successfully merging this pull request may close these issues.

Allow for loading a single default theme

1 participant