feat: set ANSI theme as default

This commit is contained in:
Sam Mohr 2023-12-28 12:38:25 -08:00
parent 0a27d6e180
commit 182b22dbfd
2 changed files with 772 additions and 3 deletions

View file

@ -0,0 +1,762 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Chiel ten Brinke</string>
<key>colorSpaceName</key>
<string>sRGB</string>
<key>comment</key>
<string>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.</string>
<key>name</key>
<string>Neo-ansi Terminal Theme for Bat</string>
<key>semanticClass</key>
<string>theme.neo-ansi</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#00000001</string>
<key>foreground</key>
<string>#00000001</string>
<key>gutter</key>
<string>#00000001</string>
<key>gutterForeground</key>
<string>#00000001</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Invalid</string>
<key>scope</key>
<string>invalid, invalid.illegal</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Invalid deprecated</string>
<key>scope</key>
<string>invalid.deprecated</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0b000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>URL</string>
<key>scope</key>
<string>*url*, *link*, *uri*</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>underline</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage operators</string>
<key>scope</key>
<string>storage.modifier.pointer, storage.modifier.reference</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0c000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Pointer access</string>
<key>scope</key>
<string>punctuation.separator.pointer-access</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0c000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>CSS Class and Support</string>
<key>scope</key>
<string>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</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>CSS Classes</string>
<key>scope</key>
<string>entity.other.attribute-name.pseudo-class, entity.other.attribute-name.pseudo-element</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0b000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>CSS Variables</string>
<key>scope</key>
<string>source.css variable</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0f000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>CSS Properties</string>
<key>scope</key>
<string>source.css support.type.property-name</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>COMMENT</string>
<key>scope</key>
<string>comment, punctuation.definition.comment, string.quoted.docstring</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>VALUE TYPE, BUILTIN TYPE, TAG</string>
<key>scope</key>
<string>keyword.type, entity.name.tag, meta.tag.sgml, entity.name.type.struct, support.type, support.class, support.type.sys-types, support.type.built-in</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>STRING, SYMBOL</string>
<key>scope</key>
<string>string, constant.other.symbol</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>TYPE, ATTRIBUTE</string>
<key>scope</key>
<string>entity.name, entity.other.attribute-name</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>FUNCTION, METHOD, OPERATOR</string>
<key>scope</key>
<string>entity.name.function, variable.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>KEYWORD, STORAGE</string>
<key>scope</key>
<string>keyword, storage</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>SUPPORT, SPECIAL, BUILTIN OTHER</string>
<key>scope</key>
<string>support, keyword.other.special-method, variable.language, string.regexp, constant.character.escape, support.other.variable</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>TEXT</string>
<key>scope</key>
<string>source, text, variable, entity.name.variable, entity.name.namespace, constant.other.placeholder</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>CONSTANT</string>
<key>scope</key>
<string>constant.numeric, constant.language, support.constant, constant.character, constant.escape, keyword.other.unit</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>STRING LINK</string>
<key>scope</key>
<string>string.other.link</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0a000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>ALT TYPE</string>
<key>scope</key>
<string>entity.name.type.parameter, entity.name.type.type-parameter, variable.other.generic-type</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0b000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>ALT FUNCTION</string>
<key>scope</key>
<string>keyword.operator, support.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0c000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>ALT KEYWORD</string>
<key>scope</key>
<string>keyword.other</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0d000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>PUNCTUATION</string>
<key>scope</key>
<string>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</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0e000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>ALT VARIABLE</string>
<key>scope</key>
<string>entity.name.variable.field, entity.name.variable.property, variable.other.property, variable.other.field</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0f000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Inserted</string>
<key>scope</key>
<string>markup.inserted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Changed</string>
<key>scope</key>
<string>markup.changed</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>GitGutter deleted</string>
<key>scope</key>
<string>markup.deleted.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>GitGutter inserted</string>
<key>scope</key>
<string>markup.inserted.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>GitGutter changed</string>
<key>scope</key>
<string>markup.changed.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>GitGutter untracked</string>
<key>scope</key>
<string>markup.untracked.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>GitGutter ignored</string>
<key>scope</key>
<string>markup.ignored.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#08000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Values</string>
<key>scope</key>
<string>constant.other.haskell</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Types</string>
<key>scope</key>
<string>storage.type.haskell</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage</string>
<key>scope</key>
<string>source.js storage, source.js keyword.declaration</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>String, Symbols</string>
<key>scope</key>
<string>constant.other.key meta.group.braces.curly constant.other.object.key.js string.unquoted.label.js</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JS import</string>
<key>scope</key>
<string>entity.name.module.js, variable.import.parameter.js, variable.other.class.js</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Decorators</string>
<key>scope</key>
<string>tag.decorator.js entity.name.tag.js, tag.decorator.js punctuation.definition.tag.js</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 0</string>
<key>scope</key>
<string>source.json meta.structure.dictionary.json support.type.property-name.json</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 1</string>
<key>scope</key>
<string>source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 2</string>
<key>scope</key>
<string>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</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0b000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 3</string>
<key>scope</key>
<string>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</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 4</string>
<key>scope</key>
<string>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</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 5</string>
<key>scope</key>
<string>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</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 6</string>
<key>scope</key>
<string>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</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 7</string>
<key>scope</key>
<string>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</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 8</string>
<key>scope</key>
<string>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</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0f000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Bold</string>
<key>scope</key>
<string>markup.bold, markup.bold string</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Italic</string>
<key>scope</key>
<string>markup.italic</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Underline and Link</string>
<key>scope</key>
<string>markup.underline</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>underline</string>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Strike</string>
<key>scope</key>
<string>markup.strike</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>strike</string>
<key>foreground</key>
<string>#08000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Bold-Italic</string>
<key>scope</key>
<string>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</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Heading</string>
<key>scope</key>
<string>markdown.heading, markup.heading, markup.heading entity.name, markup.heading.markdown punctuation.definition.heading.markdown, markup.heading.setext</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Link Anchor and Title</string>
<key>scope</key>
<string>constant.other.reference.link.markdown, string.other.link.title.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Raw &amp; Fenced Block</string>
<key>scope</key>
<string>markup.raw, markup.fenced_code, markup.inline.raw</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Link Description</string>
<key>scope</key>
<string>string.other.link.description.title.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Table</string>
<key>scope</key>
<string>markup.table</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Quote</string>
<key>scope</key>
<string>markup.quote</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Plain</string>
<key>scope</key>
<string>text.html.markdown, punctuation.definition.list_item.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Fenced Bode Block Variable</string>
<key>scope</key>
<string>variable.language.fenced.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0f000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Types</string>
<key>scope</key>
<string>source.purescript entity.name.type</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>source.purescript entity.name.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0b000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>String types</string>
<key>scope</key>
<string>storage.type.string.python</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0e000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Lifetime types</string>
<key>scope</key>
<string>source.rust entity.name.type.lifetime, source.rust punctuation.definition.lifetime</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0b000000</string>
</dict>
</dict>
</array>
<key>uuid</key>
<string>uuid</string>
</dict>
</plist>

View file

@ -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());