今天解决了困扰我许久但没有什么实质性大用的一个问题:VScode里函数名和关键字都是正常的,但变量名全都是白色的。就算去设置的json的"editor.tokenColorCustomizations"里更改variable也没用,自己增加"textMateRules"也没用。
困扰了我很久,一直凑合用着,然后今天终于找到了原因。
原来是后来默认的VScode的python被拆解成了多个扩展,变量名有颜色的必要条件是装上pylance,装上pylance,装上pylance!
(天啊查了我这么久怎么就是这个东西啊 TTATT)
然后几种办法:
1. 设置Dark + 主题,就有默认颜色了
2. 或者 自己打开 设置--打开设置json--增加variable设置。
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "variable.parameter",
"settings": {
"foreground": "#ffa41c"
}
},
{
"scope": "variable.other.readwrite",
"settings": {
"foreground": "#fffec8"
}
},
{
"scope": "variable.other",
"settings": {
// "foreground": "#ff0000"
}
}
],
// "comments": "#7ceead", // 注释
// "keywords": "#416ed8", // 关键字
"variables": "#e0fff0", // 变量名
// "strings": "#fff5cbfa", // 字符串
// "functions": "#9eff20c9", // 函数名
// "numbers": "#9d1fbd" // 数字
},
// 选中高亮的颜色
"workbench.colorCustomizations": {
"editor.selectionBackground": "#08b0e4"
},
设置自己喜欢的颜色就好。
变量名就可以有颜色了。