提问人:PhewphewMathew 提问时间:10/28/2023 最后编辑:PhewphewMathew 更新时间:10/31/2023 访问量:34
如何修复 Sublime Text 中无法读取其配色方案的包?
How to fix a package from Sublime Text that doesn't read its color scheme?
问:
note
> note.sublime-color-scheme
> note.sublime-syntax
> note.tmTheme
> sample.note
这就是我的包结构的样子。我创建了我的名称 my.own.scope 并将其注册到文件中的特定文本模式上,它工作正常,我的文件中没有任何问题。note
custom scope
.sublime-syntax
sample.note
现在,我正在尝试使用 file 将文本样式设置为 my.own.scope 所钩接的内容,但 ST 根本不设置文本样式。.sublime-color-scheme
如何解决此错误?我创建了一个新文件来解决这个问题,但也没有发生任何事情。.tmTheme
代码来自.sublime-syntax
;
%YAML 1.2
---
file_extensions:
- note
scope: text.plain.note
contexts:
main:
- match: '^-\s{1,}\w+'
scope: my.own.scope
代码来自.sublime-color-scheme
;
{
"name": "Note",
"variables": {
"black": "hsl(0, 0%, 0%)",
},
"globals": {
"foreground": "",
"background": "",
"accent": "",
"selection": "",
},
"rules": [
{
"name": "myOwnScope",
"scope": "my.own.scope",
"foreground": "var(black)",
}
]
}
文件中的代码;.tmTheme
<plist version="1.0">
<dict>
<key>name</key>
<string>note</string>
<key>scopeName</key>
<string>source.base_scope</string>
<key>settings</key>
<array>
<dict>
<key>name</key>
<string>myOwnScope</string>
<key>scope</key>
<string>my.own.scope</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#000000</string>
</dict>
</dict>
</array>
<key>uuid</key>
<string>41f141d6-0432-43ef-87d0-d509ac95f110</string>
</dict>
</plist>
答:
首先要注意的是,一旦加载,就会被处理成相同的,所以在这种情况下,在一个中起作用的东西也会在另一个中起作用。具有相同名称的两种类型的文件将在加载时合并为一个。因此,在两种类型中拥有同名的文件可能会让您在未来感到困惑和心痛;您应该选择一个并删除另一个。一般的建议是,除非你有令人信服的理由,否则不要使用,因为有更多的功能(例如变量)。tmTheme
sublime-color-scheme
tmTheme
sublime-color-scheme
不过,更大的问题是,根据您的问题,您可能会认为,因为语法是命名的,因此您需要创建一个才能为其设置颜色,但事实并非如此。note.sublime-syntax
note.sublime-color-scheme
Sublime 使用的配色方案由 ;因此,要激活您的配色方案,您需要编辑您的首选项并设置为 ,例如。color_scheme
Preferences.sublime-settings
color_scheme
note.sublime-color-scheme
不过,您可能不想这样做。上面的示例仅包含一条颜色规则,该规则将使该文本变黑。当配色方案为空时,默认值为背景和文本,因此,如果该配色方案实际上处于活动状态,则默认情况下,您将看到一个白色窗口,其中所有文本都是黑色的,而您的范围匹配的文本同样是黑色的,因此您将无法注意到任何差异。white
black
您在这里要做的很可能是从命令面板或菜单中选择,然后将上面的单个条目添加到将在右侧窗格中打开的文件部分中。UI: Customize Color Scheme
Preferences > Customize Color Scheme
rule
rule
这样做将扩充现有配色方案,使其具有额外的规则,用于为添加到示例语法的范围着色。
评论
sublime-color-scheme