Load theme for raw code (#1675)

This commit is contained in:
Myriad-Dreamin 2023-07-17 22:43:33 +08:00 committed by GitHub
parent e0e797c27d
commit 9b72ee4d22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 1012 additions and 15 deletions

41
Cargo.lock generated
View file

@ -942,7 +942,7 @@ dependencies = [
"log",
"num-format",
"once_cell",
"quick-xml",
"quick-xml 0.26.0",
"rgb",
"str_stack",
]
@ -1122,6 +1122,15 @@ version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4"
[[package]]
name = "line-wrap"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9"
dependencies = [
"safemem",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
@ -1450,6 +1459,20 @@ dependencies = [
"ttf-parser",
]
[[package]]
name = "plist"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bd9647b268a3d3e14ff09c23201133a62589c658db02bb7388c7246aafe0590"
dependencies = [
"base64",
"indexmap",
"line-wrap",
"quick-xml 0.28.2",
"serde",
"time",
]
[[package]]
name = "png"
version = "0.17.8"
@ -1518,6 +1541,15 @@ dependencies = [
"memchr",
]
[[package]]
name = "quick-xml"
version = "0.28.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce5e73202a820a31f8a0ee32ada5e21029c81fd9e3ebf668a40832e4219d9d1"
dependencies = [
"memchr",
]
[[package]]
name = "quote"
version = "1.0.27"
@ -1783,6 +1815,12 @@ version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
[[package]]
name = "safemem"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
[[package]]
name = "same-file"
version = "1.0.6"
@ -2053,6 +2091,7 @@ dependencies = [
"fnv",
"lazy_static",
"once_cell",
"plist",
"regex-syntax 0.6.29",
"serde",
"serde_derive",

4
NOTICE
View file

@ -25,6 +25,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
================================================================================
The MIT License applies to:
* The tmTheme in `assets/files/halcyon.tmTheme`
Copyright (c) 2018 Brittany Chiang
in the Sublime Text package `Halcyon` (https://github.com/bchiang7/Halcyon)
* The default color set defined in `crates/typst/src/geom/color.rs` which is
adapted from the colors.css project
(https://clrs.cc/)

View file

@ -0,0 +1,865 @@
<?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>Brittany Chiang</string>
<key>colorSpaceName</key>
<string>sRGB</string>
<key>name</key>
<string>ayu</string>
<key>semanticClass</key>
<string>halcyon</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#1d2433</string>
<key>foreground</key>
<string>#a2aabc</string>
<key>caret</key>
<string>#FFCC66</string>
<key>findHighlight</key>
<string>#8695b7</string>
<key>findHighlightForeground</key>
<string>#d7dce2</string>
<key>guide</key>
<string>#2f3b54</string>
<key>activeGuide</key>
<string>#2f3b54</string>
<key>stackGuide</key>
<string>#2f3b54</string>
<key>gutter</key>
<string>#1d2433</string>
<key>gutterForeground</key>
<string>#8695b755</string>
<key>inactiveBackground</key>
<string>#1d2433</string>
<key>inactiveSelection</key>
<string>#2f3b54</string>
<key>invisibles</key>
<string>#6679a4</string>
<key>lineHighlight</key>
<string>#2f3b54</string>
<key>popupCss</key>
<string>
html, body {
background-color: #1d2433;
font-size: 12px;
color: #a2aabc;
padding: 0;
}
body {
padding: 5px;
}
div {
padding-bottom: -3px;
}
b, strong {
font-weight: normal;
}
a {
color: rgba(92, 207, 230, .7);
line-height: 16px;
}
.type {
color: #ef6b73;
}
.name {
color: #ffd580;
}
.param {
color: #FFD580;
}
.current {
text-decoration: underline;
}
</string>
<key>selection</key>
<string>#2f3b54</string>
<key>selectionBorder</key>
<string>#a2aabc35</string>
<key>shadow</key>
<string>#00000010</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>comment, punctuation.definition.comment</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#8695b799</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variable</string>
<key>scope</key>
<string>variable</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#a2aabc</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keyword</string>
<key>scope</key>
<string>keyword, keyword.operator</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FFAE57</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage</string>
<key>scope</key>
<string>storage.type, storage.modifier</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#c3a6ff</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Operator, Misc</string>
<key>scope</key>
<string>constant.other.color, meta.tag, punctuation.separator.inheritance.php, punctuation.section.embedded, keyword.other.substitution</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Tag</string>
<key>scope</key>
<string>entity.name.tag, meta.tag.sgml</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Git Gutter Deleted</string>
<key>scope</key>
<string>markup.deleted.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#ef6b73</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Function, Special Method, Block Level</string>
<key>scope</key>
<string>entity.name, entity.name.class, entity.other.inherited-class, variable.function, support.function, keyword.other.special-method, meta.block-level</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FFD580</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Other Variable, String Link</string>
<key>scope</key>
<string>support.other.variable, string.other.link</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#ef6b73</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Number, Constant, Function Argument, Tag Attribute, Embedded</string>
<key>scope</key>
<string>constant.numeric, constant.language, constant.character, keyword.other.unit</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#c3a6ff</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Number, Constant, Function Argument, Tag Attribute, Embedded</string>
<key>scope</key>
<string>support.constant, meta.jsx.js, punctuation.section, string.unquoted.label</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#a2aabc</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>String, Symbols, Inherited Class, Markup Heading</string>
<key>scope</key>
<string>string, keyword.other.template, constant.other.symbol, constant.other.key, entity.other.inherited-class, markup.heading, markup.inserted.git_gutter, meta.group.braces.curly</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>normal</string>
<key>foreground</key>
<string>#bae67e</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Class, Support</string>
<key>scope</key>
<string>entity.name.type.class, support.type, support.class, support.orther.namespace.use.php, meta.use.php, support.other.namespace.php, markup.changed.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Sub-methods</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>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Language methods</string>
<key>scope</key>
<string>variable.language</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#5ccfe6</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>#ef6b73</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Deprecated</string>
<key>scope</key>
<string>invalid.deprecated</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#FFAE57</string>
<key>foreground</key>
<string>#d7dce2</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Html punctuations tags</string>
<key>scope</key>
<string>punctuation.definition.tag.end, punctuation.definition.tag.begin, punctuation.definition.tag, meta.group.braces.curly.js, meta.property-value, meta.jsx.js</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#a2aabc</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Attributes</string>
<key>scope</key>
<string>entity.other.attribute-name, meta.attribute-with-value.style, constant.other.color.rgb-value, meta.at-rule.media, support.constant.mathematical-symbols,
punctuation.separator.key-value</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FFAE57</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>#bae67e</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>#5ccfe6</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>#FFAE57</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Regular Expressions and Escape Characters</string>
<key>scope</key>
<string>string.regexp, constant.character.escape</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#95E6CB</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>Search Results Nums</string>
<key>scope</key>
<string>constant.numeric.line-number.find-in-files - match</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#8695b7</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Search Results Lines</string>
<key>scope</key>
<string>entity.name.filename.find-in-files</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#bae67e</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>#ffd580</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>ES7 Bind Operator</string>
<key>scope</key>
<string>constant.other.object.key</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>entity.name.method</string>
<key>scope</key>
<string>entity.name.method</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#ffd580</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>meta.method.js</string>
<key>scope</key>
<string>entity.name.function, variable.function.constructor</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#ffd580</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>#ef6b73</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Bold</string>
<key>scope</key>
<string>markup.bold</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#ef6b73</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Underline</string>
<key>scope</key>
<string>markup.underline</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>underline</string>
<key>foreground</key>
<string>#c3a6ff</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>#ffd580</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>#80D4FF</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Raw Block</string>
<key>scope</key>
<string>markup.raw.block</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FFAE57</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup - Table</string>
<key>scope</key>
<string>markup.table</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#1d2433aa</string>
<key>foreground</key>
<string>#5ccfe6</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>#a2aabc</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Markup Raw Inline</string>
<key>scope</key>
<string>text.html.markdown markup.raw.inline</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Line Break</string>
<key>scope</key>
<string>text.html.markdown meta.dummy.line-break</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#8695b7</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</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#bae67e</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Blockquote</string>
<key>scope</key>
<string>markup.quote, punctuation.definition.blockquote.markdown</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#80D4FF</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Link</string>
<key>scope</key>
<string>string.other.link.title.markdown</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>underline</string>
<key>foreground</key>
<string>#ffd580</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Raw Block Fenced</string>
<key>scope</key>
<string>markup.raw.block.fenced.markdown</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#d7dce210</string>
<key>foreground</key>
<string>#a2aabc</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Fenced Bode Block</string>
<key>scope</key>
<string>punctuation.definition.fenced.markdown, variable.language.fenced.markdown</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#d7dce210</string>
<key>foreground</key>
<string>#8695b7</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Fenced Language</string>
<key>scope</key>
<string>variable.language.fenced.markdown</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#8695b7</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown - Separator</string>
<key>scope</key>
<string>meta.separator</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#d7dce210</string>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#8695b7</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 0</string>
<key>scope</key>
<string>source.json meta.structure.dictionary.json string.quoted.double.json - meta.structure.dictionary.json meta.structure.dictionary.value.json string.quoted.double.json, source.json meta.structure.dictionary.json punctuation.definition.string - meta.structure.dictionary.json meta.structure.dictionary.value.json punctuation.definition.string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 1</string>
<key>scope</key>
<string>source.json meta meta.structure.dictionary.json string.quoted.double.json - meta meta.structure.dictionary.json meta.structure.dictionary.value.json string.quoted.double.json, source.json meta meta.structure.dictionary.json punctuation.definition.string - meta meta.structure.dictionary.json meta.structure.dictionary.value.json punctuation.definition.string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 2</string>
<key>scope</key>
<string>source.json meta meta meta meta.structure.dictionary.json string.quoted.double.json - meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json string.quoted.double.json, source.json meta meta meta meta.structure.dictionary.json punctuation.definition.string - meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json punctuation.definition.string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#ffae57</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 3</string>
<key>scope</key>
<string>source.json meta meta meta meta meta meta.structure.dictionary.json string.quoted.double.json - meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json string.quoted.double.json, source.json meta meta meta meta meta meta.structure.dictionary.json punctuation.definition.string - meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json punctuation.definition.string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 4</string>
<key>scope</key>
<string>source.json meta meta meta meta meta meta meta meta.structure.dictionary.json string.quoted.double.json - meta meta meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json string.quoted.double.json, source.json meta meta meta meta meta meta meta meta.structure.dictionary.json punctuation.definition.string - meta meta meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json punctuation.definition.string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#ffae57</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 5</string>
<key>scope</key>
<string>source.json meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json string.quoted.double.json - meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json string.quoted.double.json, source.json meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json punctuation.definition.string - meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json punctuation.definition.string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 6</string>
<key>scope</key>
<string>source.json meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json string.quoted.double.json - meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json string.quoted.double.json, source.json meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json punctuation.definition.string - meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json punctuation.definition.string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#ffae57</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 7</string>
<key>scope</key>
<string>source.json meta meta meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json string.quoted.double.json - meta meta meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json string.quoted.double.json, source.json meta meta meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json punctuation.definition.string - meta meta meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json punctuation.definition.string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>JSON Key - Level 8</string>
<key>scope</key>
<string>source.json meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json string.quoted.double.json - meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json string.quoted.double.json, source.json meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json punctuation.definition.string - meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta meta.structure.dictionary.json meta.structure.dictionary.value.json punctuation.definition.string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#ffae57</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>AceJump Label - Blue</string>
<key>scope</key>
<string>acejump.label.blue</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#5ccfe6</string>
<key>foreground</key>
<string>#d7dce2</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>AceJump Label - Green</string>
<key>scope</key>
<string>acejump.label.green</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#bae67e</string>
<key>foreground</key>
<string>#d7dce2</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>AceJump Label - Orange</string>
<key>scope</key>
<string>acejump.label.orange</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#FFAE57</string>
<key>foreground</key>
<string>#d7dce2</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>AceJump Label - Purple</string>
<key>scope</key>
<string>acejump.label.purple</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#ef6b73</string>
<key>foreground</key>
<string>#d7dce2</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>SublimeLinter Warning</string>
<key>scope</key>
<string>sublimelinter.mark.warning</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#5ccfe6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>SublimeLinter Gutter Mark</string>
<key>scope</key>
<string>sublimelinter.gutter-mark</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#d7dce2</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>SublimeLinter Error</string>
<key>scope</key>
<string>sublimelinter.mark.error</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#ef6b73</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>#8695b7</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>#8695b7</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>GutterColor</string>
<key>scope</key>
<string>gutter_color</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#d7dce2</string>
</dict>
</dict>
</array>
<key>uuid</key>
<string>0e709986-46a0-40a0-b3bf-c8dfe525c455</string>
</dict>
</plist>

View file

@ -39,7 +39,7 @@ rustybuzz = "0.7"
serde_json = "1"
serde_yaml = "0.8"
smallvec = "1.10"
syntect = { version = "5", default-features = false, features = ["parsing", "regex-fancy", "yaml-load"] }
syntect = { version = "5", default-features = false, features = ["parsing", "regex-fancy", "plist-load", "yaml-load"] }
time = { version = "0.3.20", features = ["formatting"] }
toml = { version = "0.7.3", default-features = false, features = ["parse"] }
tracing = "0.1.37"

View file

@ -149,17 +149,39 @@ pub struct RawElem {
/// ```
/// ````
#[parse(
let (syntaxes, data) = parse_syntaxes(vm, args)?;
let (syntaxes, syntaxes_data) = parse_syntaxes(vm, args)?;
syntaxes
)]
#[fold]
pub syntaxes: SyntaxPaths,
/// The raw file buffers.
/// The raw file buffers of syntax definition files.
#[internal]
#[parse(data)]
#[parse(syntaxes_data)]
#[fold]
pub data: Vec<Bytes>,
pub syntaxes_data: Vec<Bytes>,
/// The theme to use for syntax highlighting. Theme files should be in the in the
/// `tmTheme` file format.
///
/// ````example
/// #set raw(theme: "halcyon.tmTheme")
///
/// ```typ
/// = Chapter 1
/// #let hi = "Hello World"
/// ```
/// ````
#[parse(
let (theme_path, theme_data) = parse_theme(vm, args)?;
theme_path.map(Some)
)]
pub theme: Option<EcoString>,
/// The raw file buffer of syntax theme file.
#[internal]
#[parse(theme_data.map(Some))]
pub theme_data: Option<Bytes>,
}
impl RawElem {
@ -190,16 +212,28 @@ impl Show for RawElem {
#[tracing::instrument(name = "RawElem::show", skip_all)]
fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
let text = self.text();
let lang = self.lang(styles).as_ref().map(|s| s.to_lowercase());
let foreground = THEME
let lang = self
.lang(styles)
.as_ref()
.map(|s| s.to_lowercase())
.or(Some("txt".into()));
let extra_syntaxes = UnsyncLazy::new(|| {
load_syntaxes(&self.syntaxes(styles), &self.syntaxes_data(styles)).unwrap()
});
let theme = self.theme(styles).map(|theme_path| {
load_theme(theme_path, self.theme_data(styles).unwrap()).unwrap()
});
let theme = theme.as_deref().unwrap_or(&THEME);
let foreground = theme
.settings
.foreground
.map(to_typst)
.map_or(Color::BLACK, Color::from);
let extra_syntaxes =
UnsyncLazy::new(|| load(&self.syntaxes(styles), &self.data(styles)).unwrap());
let mut realized = if matches!(lang.as_deref(), Some("typ" | "typst" | "typc")) {
let root = match lang.as_deref() {
Some("typc") => syntax::parse_code(&text),
@ -207,7 +241,7 @@ impl Show for RawElem {
};
let mut seq = vec![];
let highlighter = synt::Highlighter::new(&THEME);
let highlighter = synt::Highlighter::new(theme);
highlight_themed(
&LinkedNode::new(&root),
vec![],
@ -229,7 +263,7 @@ impl Show for RawElem {
})
}) {
let mut seq = vec![];
let mut highlighter = syntect::easy::HighlightLines::new(syntax, &THEME);
let mut highlighter = syntect::easy::HighlightLines::new(syntax, theme);
for (i, line) in text.lines().enumerate() {
if i != 0 {
seq.push(LinebreakElem::new().pack());
@ -385,7 +419,7 @@ impl Fold for SyntaxPaths {
/// Load a syntax set from a list of syntax file paths.
#[comemo::memoize]
fn load(paths: &SyntaxPaths, bytes: &[Bytes]) -> StrResult<Arc<SyntaxSet>> {
fn load_syntaxes(paths: &SyntaxPaths, bytes: &[Bytes]) -> StrResult<Arc<SyntaxSet>> {
let mut out = SyntaxSetBuilder::new();
// We might have multiple sublime-syntax/yaml files
@ -423,11 +457,42 @@ fn parse_syntaxes(
.collect::<SourceResult<Vec<Bytes>>>()?;
// Check that parsing works.
let _ = load(&paths, &data).at(span)?;
let _ = load_syntaxes(&paths, &data).at(span)?;
Ok((Some(paths), Some(data)))
}
#[comemo::memoize]
fn load_theme(path: EcoString, bytes: Bytes) -> StrResult<Arc<synt::Theme>> {
let mut cursor = std::io::Cursor::new(bytes.as_slice());
synt::ThemeSet::load_from_reader(&mut cursor)
.map(Arc::new)
.map_err(|e| eco_format!("failed to parse theme file `{path}`: {e}"))
}
/// Function to parse the theme argument.
/// Much nicer than having it be part of the `element` macro.
fn parse_theme(
vm: &mut Vm,
args: &mut Args,
) -> SourceResult<(Option<EcoString>, Option<Bytes>)> {
let Some(Spanned { v: path, span }) =
args.named::<Spanned<EcoString>>("theme")?
else {
return Ok((None, None));
};
// Load theme file.
let id = vm.location().join(&path).at(span)?;
let data = vm.world().file(id).at(span)?;
// Check that parsing works.
let _ = load_theme(path.clone(), data.clone()).at(span)?;
Ok((Some(path), Some(data)))
}
/// The syntect syntax definitions.
///
/// Code for syntax set generation is below. The `syntaxes` directory is from

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -0,0 +1,24 @@
// Test code highlighting with custom theme.
---
#set page(width: 180pt)
#set text(6pt)
#set raw(theme: "/files/halcyon.tmTheme")
#show raw: it => {
set text(fill: rgb("a2aabc"))
rect(
width: 100%,
inset: (x: 4pt, y: 5pt),
radius: 4pt,
fill: rgb("1d2433"),
place(right, text(luma(240), it.lang)) + it,
)
}
```typ
= Chapter 1
#lorem(100)
#let hi = "Hello World"
#show heading: emph
```