vscode自定义主题语法及流程

vscode c/c++ 主题 DIY

启用自己的主题(最后步骤)

重启生效

手把手教你制作

在C:\Users\jlh.vscode\extensions下自己创建一个文件夹

里面有两个文件一个文件夹

package.json:

c 复制代码
{"name":"theme-jlh","displayName":"%displayName%","description":"%description%","version":"1.0.0","publisher":"vscode","license":"MIT","engines":{"vscode":"*"},"categories":["Themes"],"contributes":{"themes":[{"id":"JLH","label":"%themeLabel%","uiTheme":"vs-dark","path":"./themes/jlh-color-theme.json"}]},"repository":{"type":"git","url":"https://github.com/microsoft/vscode.git"}}

package.nls.json:

c 复制代码
{"displayName":"JLH Theme","description":"JLH theme for Visual Studio Code","themeLabel":"JLH"}

themes/jlh-color-theme.json

c 复制代码
{
	"$schema": "vscode://schemas/color-theme",
	"name": "jlh diy theme(c/c++)",
	"colors": {
		"editor.background": "#1E1E1E",
		"editor.foreground": "#DADADA",
		"editor.inactiveSelectionBackground": "#3A3D41",
		"editorIndentGuide.background": "#404040",
		"editorIndentGuide.activeBackground": "#707070",
		"editor.selectionHighlightBackground": "#ADD6FF26",
		"list.dropBackground": "#383B3D",
		"activityBarBadge.background": "#007ACC",
		"sideBarTitle.foreground": "#BBBBBB",
		"input.placeholderForeground": "#A6A6A6",
		"menu.background": "#303031",
		"menu.foreground": "#CCCCCC",
		"statusBarItem.remoteForeground": "#FFF",
		"statusBarItem.remoteBackground": "#16825D",
		"ports.iconRunningProcessForeground": "#369432",
		"sideBarSectionHeader.background": "#0000",
		"sideBarSectionHeader.border": "#ccc3",
		"tab.lastPinnedBorder": "#ccc3",
		"list.activeSelectionIconForeground": "#FFF",
		"editorLineNumber.foreground": "#2b91af",
		"editorLineNumber.activeForeground": "#2b91af",
		"terminal.inactiveSelectionBackground": "#3A3D41",
		"editorInlayHint.background": "#3E3E3E",
		"editorInlayHint.foreground": "#A9A8A7"
	},
	"tokenColors": [
		{
			"scope": [
				"meta.embedded",
				"source.groovy.embedded",
				"string meta.image.inline.markdown",
			],
			"settings": {
				"foreground": "#D4D4D4"
			}
		},
		{
			"scope": "emphasis",
			"settings": {
				"fontStyle": "italic"
			}
		},
		{
			"scope": "strong",
			"settings": {
				"fontStyle": "bold"
			}
		},
		{
			"scope": "header",
			"settings": {
				"foreground": "#000080"
			}
		},
		{
			"scope": "comment",
			"settings": {
				"foreground": "#6A9955"
			}
		},
		{
			"scope": "constant.language",
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": [
				"constant.numeric",
				"variable.other.enummember",
				"keyword.operator.plus.exponent",
				"keyword.operator.minus.exponent"
			],
			"settings": {
				"foreground": "#b5cea8"
			}
		},
		{
			"scope": "constant.regexp",
			"settings": {
				"foreground": "#646695"
			}
		},
		{
			"scope": "entity.name.tag",
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": "entity.name.tag.css",
			"settings": {
				"foreground": "#d7ba7d"
			}
		},
		{
			"scope": "entity.other.attribute-name",
			"settings": {
				"foreground": "#9cdcfe"
			}
		},
		{
			"scope": [
				"entity.other.attribute-name.class.css",
				"entity.other.attribute-name.class.mixin.css",
				"entity.other.attribute-name.id.css",
				"entity.other.attribute-name.parent-selector.css",
				"entity.other.attribute-name.pseudo-class.css",
				"entity.other.attribute-name.pseudo-element.css",
				"source.css.less entity.other.attribute-name.id",
				"entity.other.attribute-name.scss"
			],
			"settings": {
				"foreground": "#d7ba7d"
			}
		},
		{
			"scope": "invalid",
			"settings": {
				"foreground": "#f44747"
			}
		},
		{
			"scope": "markup.underline",
			"settings": {
				"fontStyle": "underline"
			}
		},
		{
			"scope": "markup.bold",
			"settings": {
				"fontStyle": "bold",
				"foreground": "#569cd6"
			}
		},
		{
			"scope": "markup.heading",
			"settings": {
				"fontStyle": "bold",
				"foreground": "#569cd6"
			}
		},
		{
			"scope": "markup.italic",
			"settings": {
				"fontStyle": "italic"
			}
		},
		{
			"scope": "markup.strikethrough",
			"settings": {
				"fontStyle": "strikethrough"
			}
		},
		{
			"scope": "markup.inserted",
			"settings": {
				"foreground": "#b5cea8"
			}
		},
		{
			"scope": "markup.deleted",
			"settings": {
				"foreground": "#ce9178"
			}
		},
		{
			"scope": "markup.changed",
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": "punctuation.definition.quote.begin.markdown",
			"settings": {
				"foreground": "#6A9955"
			}
		},
		{
			"scope": "punctuation.definition.list.begin.markdown",
			"settings": {
				"foreground": "#6796e6"
			}
		},
		{
			"scope": "markup.inline.raw",
			"settings": {
				"foreground": "#ce9178"
			}
		},
		{
			"name": "brackets of XML/HTML tags",
			"scope": "punctuation.definition.tag",
			"settings": {
				"foreground": "#808080"
			}
		},
		{
			"scope": [
				"meta.preprocessor",
				"entity.name.function.preprocessor"
			],
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": "meta.preprocessor.string",
			"settings": {
				"foreground": "#ce9178"
			}
		},
		{
			"scope": "meta.preprocessor.numeric",
			"settings": {
				"foreground": "#b5cea8"
			}
		},
		{
			"scope": "meta.structure.dictionary.key.python",
			"settings": {
				"foreground": "#9cdcfe"
			}
		},
		{
			"scope": "meta.diff.header",
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": "storage",
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": "storage.type",
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": [
				"storage.modifier",
				"keyword.operator.noexcept"
			],
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": [
				"string",
				"meta.embedded.assembly"
			],
			"settings": {
				"foreground": "#ce9178"
			}
		},
		{
			"scope": "string.tag",
			"settings": {
				"foreground": "#ce9178"
			}
		},
		{
			"scope": "string.value",
			"settings": {
				"foreground": "#ce9178"
			}
		},
		{
			"scope": "string.regexp",
			"settings": {
				"foreground": "#d16969"
			}
		},
		{
			"name": "String interpolation",
			"scope": [
				"punctuation.definition.template-expression.begin",
				"punctuation.definition.template-expression.end",
				"punctuation.section.embedded"
			],
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"name": "Reset JavaScript string interpolation expression",
			"scope": [
				"meta.template.expression"
			],
			"settings": {
				"foreground": "#d4d4d4"
			}
		},
		{
			"scope": [
				"support.type.vendored.property-name",
				"support.type.property-name",
				"variable.css",
				"variable.scss",
				"variable.other.less",
				"source.coffee.embedded"
			],
			"settings": {
				"foreground": "#9cdcfe"
			}
		},
		{
			"scope": "keyword",
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": "keyword.control",
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": "keyword.operator",
			"settings": {
				"foreground": "#d4d4d4"
			}
		},
		{
			"scope": [
				"keyword.operator.new",
				"keyword.operator.expression",
				"keyword.operator.cast",
				"keyword.operator.sizeof",
				"keyword.operator.alignof",
				"keyword.operator.typeid",
				"keyword.operator.alignas",
				"keyword.operator.instanceof",
				"keyword.operator.logical.python",
				"keyword.operator.wordlike"
			],
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": "keyword.other.unit",
			"settings": {
				"foreground": "#b5cea8"
			}
		},
		{
			"scope": [
				"punctuation.section.embedded.begin.php",
				"punctuation.section.embedded.end.php"
			],
			"settings": {
				"foreground": "#569cd6"
			}
		},
		{
			"scope": "support.function.git-rebase",
			"settings": {
				"foreground": "#9cdcfe"
			}
		},
		{
			"scope": "constant.sha.git-rebase",
			"settings": {
				"foreground": "#b5cea8"
			}
		},
		{
			"name": "coloring of the Java import and package identifiers",
			"scope": [
				"storage.modifier.import.java",
				"variable.language.wildcard.java",
				"storage.modifier.package.java"
			],
			"settings": {
				"foreground": "#d4d4d4"
			}
		},
		{
			"name": "this.self",
			"scope": "variable.language",
			"settings": {
				"foreground": "#569cd6"
			}
		},
	
        //===================关键字=================
		{
            "scope": "keyword.control.c",
            "settings": {
                "foreground": "#2b71f1"  // 控制语句关键字(如 if、else、for 等)
            }
        },
        {
            "scope": "keyword.control.cpp",
            "settings": {
                "foreground": "#2b71f1"  // C++ 控制语句关键字
            }
        },
        {
            "scope": "keyword.operator.word.c",
            "settings": {
                "foreground": "#2b71f1"  // 操作符关键字(如 sizeof、typedef 等)
            }
        },
        {
            "scope": "keyword.operator.logical.c",
            "settings": {
                "foreground": "#ff0000"  // 逻辑操作符关键字(如 &&、|| 等)
            }
        },

        //===================字符串=================
        {
            "scope": "string.quoted.double.cpp",
            "settings": {
                "foreground": "#44e9ff"  // 双引号字符串
            }
        },
        {
            "scope": "string.quoted.single.cpp",
            "settings": {
                "foreground": "#7bf0ff"  // 单引号字符串
            }
        },
        {
            "scope": "string.quoted.other.cpp",
            "settings": {
                "foreground": "#44e9ff"  // 其他类型的字符串
            }
        },
        
        //===================函数=================
        {
            "scope": "entity.name.function.c",
            "settings": {
                "foreground": "#fcff54"  // C 函数名
            }
        },
        {
            "scope": "entity.name.function.cpp",
            "settings": {
                "foreground": "#fcff54"  // C++ 函数名
            }
        },
        {
            "scope": "meta.function-call.c",
            "settings": {
                "foreground": "#d580f7"  // 函数调用名
            }
        },
        {
            "scope": "variable.parameter",
            "settings": {
                "foreground": "#ffd588"  // 函数参数
            }
        },

        //=================== 宏 =================
        {
            "scope": "keyword.other.macro.c",
            "settings": {
                "foreground": "#ff0000"  // 宏定义
            }
        },
        {
            "scope": "keyword.other.macro.cpp",
            "settings": {
                "foreground": "#ec0f0f"  // C++ 宏定义
            }
        },

        //===================注释=================
        {
            "scope": "comment.line.double-slash.c",
            "settings": {
                "foreground": "#5acf5a7e"  // 单行注释
            }
        },
        {
            "scope": "comment.block.c",
            "settings": {
                "foreground": "#5acf5a7e"  // 多行注释
            }
        },

        //===================枚举=================
        {
            "scope": "entity.name.type.enum.c",
            "settings": {
                "foreground": "#2b71f1"  // 枚举类型名
            }
        },
        {
            "scope": "constant.other.enum-member.c",
            "settings": {
                "foreground": "#f0d08c"  // 枚举成员
            }
        },

        //===================指针运算符=================
        {
            "scope": "storage.modifier.pointer.c",
            "settings": {
                "foreground": "#e28df3"  // 指针运算符(* 和 &)
            }
        },
        //===================class=================
        {
            "scope": "entity.name.type.class.cpp",
            "settings": {
                "foreground": "#2b71f1"  // C++ 类名
            }
        },
        {
            "scope": "entity.name.type.struct.c",
            "settings": {
                "foreground": "#2b71f1"  // C 结构体名
            }
        },
        {
            "scope": "entity.name.type.struct.cpp",
            "settings": {
                "foreground": "#2b71f1"  // C++ 结构体名
            }
        },

        //===================变量=================
        {
            "scope": "storage.type.c",
            "settings": {
                "foreground": "#21c937"  // 类型关键字(如 int、float 等)
            }
        },
        {
            "scope": "variable.other.readwrite.c",
            "settings": {
                "foreground": "#bbd1fa"  // 普通变量
            }
        },

        //===================运算符=================
        {
            "scope": "keyword.operator.arithmetic.c",
            "settings": {
                "foreground": "#f7f3f3"  // 算术运算符(如 +、-、*、/ 等)
            }
        },
        {
            "scope": "keyword.operator.comparison.c",
            "settings": {
                "foreground": "#f7f3f3"  // 比较运算符(如 ==、!=、<、> 等)
            }
        },
        {
            "scope": "keyword.operator.assignment.c",
            "settings": {
                "foreground": "#f7f3f3"  // 赋值运算符(如 =、+=、-= 等)
            }
        },

        //===================常量=================
        {
            "scope": "constant.numeric.integer.c",
            "settings": {
                "foreground": "#B5CEA8"  // 整数常量
            }
        },
        {
            "scope": "constant.numeric.float.c",
            "settings": {
                "foreground": "#B5CEA8"  // 浮点数常量
            }
        },
        {
            "scope": "constant.character.escape.c",
            "settings": {
                "foreground": "#CE9178"  // 字符串中的转义字符
            }
        }
        
	],
	"semanticHighlighting": true,
	"semanticTokenColors": {
		"newOperator": "#569CD6",
		"stringLiteral": "#ce9178",
		"customLiteral": "#DCDCAA",
		"numberLiteral": "#b5cea8"//数字颜色
	},
/*
    "editor.semanticTokenColorCustomizations": {
    "rules": {
        "namespace": {
            "foreground": "#569CD6"  // 命名空间
        },
        "class": {
            "foreground": "#4EC9B0"  // 类
        },
        "interface": {
            "foreground": "#4EC9B0"  // 接口
        },
        "enum": {
            "foreground": "#4EC9B0"  // 枚举
        },
        "enumMember": {
            "foreground": "#569CD6"  // 枚举成员
        },
        "struct": {
            "foreground": "#4EC9B0"  // 结构体
        },
        "typeParameter": {
            "foreground": "#9CDCFE"  // 类型参数
        },
        "function": {
            "foreground": "#DCDCAA"  // 函数
        },
        "method": {
            "foreground": "#569CD6"  // 方法
        },
        "variable": {
            "foreground": "#9CDCFE"  // 变量
        },
        "parameter": {
            "foreground": "#9CDCFE"  // 参数
        },
        "property": {
            "foreground": "#9CDCFE"  // 属性
        },
        "macro": {
            "foreground": "#FFD700"  // 宏
        }
            }
    }*/
}