gpt4 book ai didi

plugins - HighlightWords Sublime 插件的颜色列表

转载 作者:行者123 更新时间:2023-12-03 13:35:10 31 4
gpt4 key购买 nike

我知道如何为 HighlightWords 添加新颜色插件列表。但是,我无法在其中添加比默认选项更多的选项。

你能帮我在列表中添加更多颜色吗?

这是我目前拥有的:
enter image description here

"colors_by_scope": [
"string",
"entity.name.class",
"variable.parameter",
"invalid.deprecated",
"invalid",
"support.function",
"source.json meta.structure.dictionary.json comment.line.double-slash.js ",
"source.json meta.structure.dictionary.json meta.structure.dictionary.value.json constant.language.json "
],

最佳答案

简答

您可以使用的可用范围列表由您当前使用的配色方案决定,因此需要您查看配色方案文件以查看当前可用的范围。

为此,您可以引用您的用户设置以查看 color_scheme 的内容。首选项设置为,然后使用 PackageResourceViewer打开该文件并查看它定义的范围。

或者,我的答案底部有示例插件代码,它试图加载您当前的配色方案并按名称告诉您所有唯一范围。

旁注:想到您的 Theme 是一个常见的陷阱。作为您的Color Scheme ,但它们是不同的东西; Theme设置 Sublime 的整体外观(例如选项卡的形状),而 Color Scheme设置语法高亮颜色。

长答案

范围与 Sublime 中的语法高亮如何工作有关,类似于:

  • 当前文件的语法规范使用规则根据文件内容在该类型文件中所代表的内容将文件内容分成几部分
  • 文件的不同部分被分配一个或多个 scopes唯一标识他们
  • 配色方案通过将颜色分配给范围
  • 为您的代码分配颜色

    例如,在 HTML 文件中,HTML 语法表示 html<html>范围为 entity.name.tag ,但您的配色方案表明范围 entity.name.tag应该是红色的。同样, <>具有表明它们是标点符号的范围,并且配色方案表明标点符号应该是白色的。

    Sublime 使用 tmTheme格式(取自 TextMate)以指定哪些颜色与哪些范围相关联。它是 Plist 格式的 XML 格式文件。如果您使用上面提到的 PackageResourceViewer 打开您当前使用的配色方案,您将看到(除其他外)一堆看起来像这样的部分:

    <dict>
    <key>name</key>
    <string>Comment</string>
    <key>scope</key>
    <string>comment</string>
    <key>settings</key>
    <dict>
    <key>foreground</key>
    <string>#75715E</string>
    </dict>
    </dict>

    这表明对于范围 comment ,文本的前景色应该是 #75715E .也可以更改字体样式(粗体或斜体)以及背景颜色。

    为您省去尝试从 tmTheme 的 XML 中挖掘正确信息的麻烦。文件,您可以选择 Tools > Developer > New Plugin...从菜单中,然后将您看到的 stub 代码替换为以下python代码并将其保存为 explore_scopes.py在 Sublime 默认的位置:

    import sublime
    import sublime_plugin
    import xml.etree.ElementTree as ET

    class ExploreScopesCommand(sublime_plugin.WindowCommand):
    def run(self):
    try:
    settings = self.window.active_view().settings()
    scheme = settings.get("color_scheme")
    xml = sublime.load_resource(scheme)
    self.process_scheme(ET.fromstring(xml))
    except:
    sublime.status_message("Error loading color scheme")
    raise

    def process_scheme(self, color_scheme):
    settings = color_scheme.find("./dict/array")
    if settings is None:
    return sublime.status_message("No color scheme settings found")

    scopes = list()
    for child in settings:
    self.get_scope(scopes, child)

    new_view = self.window.new_file()
    new_view.set_scratch(True)
    new_view.set_name("Available Scopes")
    new_view.run_command("append", {"characters": "\n".join(scopes)})

    def get_scope(self, scopes, setting):
    for i in range(0, len(setting), 2):
    if setting[i].tag == "key" and setting[i].text == "scope":
    scopes.append(setting[i + 1].text)

    有了它,您可以将 key 绑定(bind)到 explore_scopes命令,或者使用 View > Show Console 打开 Sublime 控制台或 Ctrl+` 并输入以下内容:
    window.run_command("explore_scopes")

    这将在当前窗口中打开一个名为 Available Scopes 的新选项卡。这将向您显示当前设置的配色方案中存在的所有范围。您看到的内容取决于您安装的 Sublime 版本以及您的配色方案设置。

    正如所写,这支持从窗口中当前聚焦的任何文件(如果有)中提取颜色方案。因此,如果您为不同类型的文件设置了不同的配色方案,请在运行命令之前选择正确的文件类型。

    关于plugins - HighlightWords Sublime 插件的颜色列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45734287/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com