簡體   English   中英

VS Code:如何在顏色主題中使用語義標記?

[英]VS Code : how to use a semantic token in color theme?

我嘗試更新我為 VS Code 制作的顏色主題(簡單的焦點),但我從未找到任何主題創建者關於如何使用新語義標記的指南......

我在我的主題中設置了"semanticHighlighting": true

例如,我想為類着色,並且 class 定義( entity.name.type.class.js )和創建( entity.name.type.js )有特定的 textMate 范圍,但是當使用MyClass.props = {}時,否則 - 如 MyClass.4 MyClass.props = {} – 唯一的 scope 是一個通用variable.other.object.js 。other.object.js 我不想碰它,因為它會弄亂其他東西。 因此,當我檢查范圍時,我看到語義標記class也匹配所有類定義和創建,但我們應該如何使用它?

我天真地嘗試添加一個 scope “類”,但它不起作用。

我能找到的關於語義標記的所有信息都與創建自定義語言有關,對主題創建者沒有任何意義,所以我的猜測是它只是假設它像 textMate 范圍一樣工作,但事實並非如此。 請有人賜教!

檢查范圍

在您的主題文件中,您需要添加semanticTokenColors ,據我所知,這些將覆蓋您在 tokenColors 中設置的tokenColors 語法類似於tokenColors但您也可以為每個標記指定修飾符,例如class.defaultLibraryclass.declaration您也可以通過設置*.declaration一次設置所有修飾符

這是一個示例

樣本

   "semanticTokenColors": {
      "namespace": "#ffffff",
      "type": "#ffffff",
      "struct": "#ffffff",
      "class": "#ffffff",
      "class.readonly": {
         "foreground": "#ffffff",
         "fontStyle": "bold italic"
      },
      "*.declaration" : {
         "fontStyle": "bold"
      },
      "*.readonly" : "#ffffff",
  }

您可以在此處找到所有范圍和修飾符

標准語義標記類型:

namespace
type, class, enum, interface, struct, typeParameter
parameter, variable, property, enumMember, event
function, member, macro
label
comment, string, keyword, number, regexp, operator

標准語義標記修飾符:

declaration
readonly, static, deprecated, abstract
async, modification, documentation, defaultLibrary

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM