From 182b22dbfd88aa7828901a53616859d0f1fe0dd7 Mon Sep 17 00:00:00 2001 From: Sam Mohr Date: Thu, 28 Dec 2023 12:38:25 -0800 Subject: [PATCH] feat: set ANSI theme as default --- yazi-config/preset/ansi.tmTheme | 762 ++++++++++++++++++++++++ yazi-plugin/src/external/highlighter.rs | 13 +- 2 files changed, 772 insertions(+), 3 deletions(-) create mode 100644 yazi-config/preset/ansi.tmTheme diff --git a/yazi-config/preset/ansi.tmTheme b/yazi-config/preset/ansi.tmTheme new file mode 100644 index 00000000..b84fcbfa --- /dev/null +++ b/yazi-config/preset/ansi.tmTheme @@ -0,0 +1,762 @@ + + + + + author + Chiel ten Brinke + colorSpaceName + sRGB + comment + Generated from the neo-ansi template at https://github.com/chtenb/neo-ansi. The colors in this theme are encoded as RRGGBBAA where RR is an ANSI palette number from 00 to 0f (the 8 colors and their bright versions), and AA is the special value 00 to indicate this encoding is being used. + name + Neo-ansi Terminal Theme for Bat + semanticClass + theme.neo-ansi + settings + + + settings + + background + #00000001 + foreground + #00000001 + gutter + #00000001 + gutterForeground + #00000001 + + + + name + Invalid + scope + invalid, invalid.illegal + settings + + foreground + #09000000 + + + + name + Invalid deprecated + scope + invalid.deprecated + settings + + foreground + #0b000000 + + + + name + URL + scope + *url*, *link*, *uri* + settings + + fontStyle + underline + + + + name + Storage operators + scope + storage.modifier.pointer, storage.modifier.reference + settings + + foreground + #0c000000 + + + + name + Pointer access + scope + punctuation.separator.pointer-access + settings + + foreground + #0c000000 + + + + name + CSS Class and Support + scope + source.css support.type.property-name, source.sass support.type.property-name, source.scss support.type.property-name, source.less support.type.property-name, source.stylus support.type.property-name, source.postcss support.type.property-name + settings + + foreground + #06000000 + + + + name + CSS Classes + scope + entity.other.attribute-name.pseudo-class, entity.other.attribute-name.pseudo-element + settings + + foreground + #0b000000 + + + + name + CSS Variables + scope + source.css variable + settings + + foreground + #0f000000 + + + + name + CSS Properties + scope + source.css support.type.property-name + settings + + foreground + #07000000 + + + + name + COMMENT + scope + comment, punctuation.definition.comment, string.quoted.docstring + settings + + fontStyle + italic + foreground + #00000000 + + + + name + VALUE TYPE, BUILTIN TYPE, TAG + scope + keyword.type, entity.name.tag, meta.tag.sgml, entity.name.type.struct, support.type, support.class, support.type.sys-types, support.type.built-in + settings + + foreground + #01000000 + + + + name + STRING, SYMBOL + scope + string, constant.other.symbol + settings + + foreground + #02000000 + + + + name + TYPE, ATTRIBUTE + scope + entity.name, entity.other.attribute-name + settings + + foreground + #03000000 + + + + name + FUNCTION, METHOD, OPERATOR + scope + entity.name.function, variable.function + settings + + foreground + #04000000 + + + + name + KEYWORD, STORAGE + scope + keyword, storage + settings + + fontStyle + + foreground + #05000000 + + + + name + SUPPORT, SPECIAL, BUILTIN OTHER + scope + support, keyword.other.special-method, variable.language, string.regexp, constant.character.escape, support.other.variable + settings + + foreground + #06000000 + + + + name + TEXT + scope + source, text, variable, entity.name.variable, entity.name.namespace, constant.other.placeholder + settings + + foreground + #07000000 + + + + name + CONSTANT + scope + constant.numeric, constant.language, support.constant, constant.character, constant.escape, keyword.other.unit + settings + + foreground + #09000000 + + + + name + STRING LINK + scope + string.other.link + settings + + foreground + #0a000000 + + + + name + ALT TYPE + scope + entity.name.type.parameter, entity.name.type.type-parameter, variable.other.generic-type + settings + + foreground + #0b000000 + + + + name + ALT FUNCTION + scope + keyword.operator, support.function + settings + + foreground + #0c000000 + + + + name + ALT KEYWORD + scope + keyword.other + settings + + foreground + #0d000000 + + + + name + PUNCTUATION + scope + punctuation.definition.tag, punctuation.definition, punctuation, punctuation.definition.tag.html, punctuation.definition.tag.begin.html, punctuation.definition.tag.end.html, punctuation.section.embedded, keyword.other.template, keyword.other.substitution, meta.separator + settings + + foreground + #0e000000 + + + + name + ALT VARIABLE + scope + entity.name.variable.field, entity.name.variable.property, variable.other.property, variable.other.field + settings + + foreground + #0f000000 + + + + name + Inserted + scope + markup.inserted + settings + + foreground + #02000000 + + + + name + Deleted + scope + markup.deleted + settings + + foreground + #01000000 + + + + name + Changed + scope + markup.changed + settings + + foreground + #03000000 + + + + name + GitGutter deleted + scope + markup.deleted.git_gutter + settings + + foreground + #01000000 + + + + name + GitGutter inserted + scope + markup.inserted.git_gutter + settings + + foreground + #02000000 + + + + name + GitGutter changed + scope + markup.changed.git_gutter + settings + + foreground + #03000000 + + + + name + GitGutter untracked + scope + markup.untracked.git_gutter + settings + + foreground + #09000000 + + + + name + GitGutter ignored + scope + markup.ignored.git_gutter + settings + + foreground + #08000000 + + + + name + Values + scope + constant.other.haskell + settings + + foreground + #01000000 + + + + name + Types + scope + storage.type.haskell + settings + + fontStyle + + foreground + #03000000 + + + + name + Storage + scope + source.js storage, source.js keyword.declaration + settings + + foreground + #03000000 + + + + name + String, Symbols + scope + constant.other.key meta.group.braces.curly constant.other.object.key.js string.unquoted.label.js + settings + + fontStyle + + foreground + #02000000 + + + + name + JS import + scope + entity.name.module.js, variable.import.parameter.js, variable.other.class.js + settings + + foreground + #06000000 + + + + name + Decorators + scope + tag.decorator.js entity.name.tag.js, tag.decorator.js punctuation.definition.tag.js + settings + + fontStyle + italic + foreground + #06000000 + + + + name + JSON Key - Level 0 + scope + source.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #01000000 + + + + name + JSON Key - Level 1 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #03000000 + + + + name + JSON Key - Level 2 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #0b000000 + + + + name + JSON Key - Level 3 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #02000000 + + + + name + JSON Key - Level 4 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #04000000 + + + + name + JSON Key - Level 5 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #06000000 + + + + name + JSON Key - Level 6 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #05000000 + + + + name + JSON Key - Level 7 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #07000000 + + + + name + JSON Key - Level 8 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #0f000000 + + + + name + Markup - Bold + scope + markup.bold, markup.bold string + settings + + fontStyle + + foreground + #01000000 + + + + name + Markup - Italic + scope + markup.italic + settings + + fontStyle + italic + foreground + #05000000 + + + + name + Markup - Underline and Link + scope + markup.underline + settings + + fontStyle + underline + foreground + #02000000 + + + + name + Markup - Strike + scope + markup.strike + settings + + fontStyle + strike + foreground + #08000000 + + + + name + Markup - Bold-Italic + scope + markup.bold markup.italic, markup.italic markup.bold, markup.quote markup.bold, markup.bold markup.italic string, markup.italic markup.bold string, markup.quote markup.bold string + settings + + fontStyle + + foreground + #09000000 + + + + name + Markdown - Heading + scope + markdown.heading, markup.heading, markup.heading entity.name, markup.heading.markdown punctuation.definition.heading.markdown, markup.heading.setext + settings + + fontStyle + + foreground + #01000000 + + + + name + Markdown - Link Anchor and Title + scope + constant.other.reference.link.markdown, string.other.link.title.markdown + settings + + foreground + #03000000 + + + + name + Markup - Raw & Fenced Block + scope + markup.raw, markup.fenced_code, markup.inline.raw + settings + + foreground + #04000000 + + + + name + Markdown - Link Description + scope + string.other.link.description.title.markdown + settings + + foreground + #05000000 + + + + name + Markup - Table + scope + markup.table + settings + + foreground + #06000000 + + + + name + Markup - Quote + scope + markup.quote + settings + + fontStyle + italic + foreground + #06000000 + + + + name + Markdown - Plain + scope + text.html.markdown, punctuation.definition.list_item.markdown + settings + + foreground + #07000000 + + + + name + Markdown - Fenced Bode Block Variable + scope + variable.language.fenced.markdown + settings + + foreground + #0f000000 + + + + name + Types + scope + source.purescript entity.name.type + settings + + foreground + #03000000 + + + + name + Classes + scope + source.purescript entity.name.class + settings + + foreground + #0b000000 + + + + name + String types + scope + storage.type.string.python + settings + + foreground + #0e000000 + + + + name + Lifetime types + scope + source.rust entity.name.type.lifetime, source.rust punctuation.definition.lifetime + settings + + foreground + #0b000000 + + + + uuid + uuid + + diff --git a/yazi-plugin/src/external/highlighter.rs b/yazi-plugin/src/external/highlighter.rs index 65ef2218..09237b96 100644 --- a/yazi-plugin/src/external/highlighter.rs +++ b/yazi-plugin/src/external/highlighter.rs @@ -26,9 +26,16 @@ impl Highlighter { Ok(ThemeSet::load_from_reader(&mut std::io::BufReader::new(file))?) } - let theme = SYNTECT_THEME.get_or_init(|| { - from_file().unwrap_or_else(|_| ThemeSet::load_defaults().themes["base16-ocean.dark"].clone()) - }); + #[inline] + fn load_default_theme() -> Theme { + let default_theme = include_str!("../../../yazi-config/preset/ansi.tmTheme"); + let mut theme_cursor = std::io::Cursor::new(default_theme.as_bytes()); + + ThemeSet::load_from_reader(&mut theme_cursor).expect("Failed to load default ANSI theme") + } + + let theme = + SYNTECT_THEME.get_or_init(|| from_file().unwrap_or_else(|_err| load_default_theme())); let syntaxes = SYNTECT_SYNTAX.get_or_init(|| from_uncompressed_data(yazi_prebuild::syntaxes()).unwrap());