Appearance
VSCode Emmet 自定义语言支持 emmet.syntaxProfiles 配置
Note:代码已提交至 GitHub - vscode-emmet-helper 的
feat-enhance-syntaxProfiles分支。
1. 修改 VSCode Emmet 插件源码
找到 VSCode Emmet 插件的脚本文件,例如
C:\Program Files\Microsoft VS Code\resources\app\extensions\emmet\dist\node\emmetNodeMain.js;将该文件复制一份出来作为备份;
打开该文件:
格式化文档;
搜索并定位至
l10n:JavaScript... let m; try { m = n(1398).l10n; } catch (e) { m = { t: (e) => e }; } ...1
2
3
4
5
6
7
8将其修改为:
JavaScript... let m; let getProfileOfCurrentLanguageId = (profilesConfig) => null; try { let vsc = n(1398); m = vsc.l10n; getProfileOfCurrentLanguageId = (profilesConfig) => profilesConfig[vsc.window.activeTextEditor.document.languageId]; } catch (e) { m = { t: (e) => e }; } ...1
2
3
4
5
6
7
8
9
10
11
12Note:这里
n(1398)对应的源码实际上是require('vscode');搜索并定位至
tag_case:JavaScript... g = (function (e, t) { t || (t = {}); const n = Object.assign({}, N, t)[e]; if (!n || "string" == typeof n) return "xhtml" === n ? { selfClosingStyle: "xhtml" } : {}; const r = {}; for (const e in n) switch (e) { case "tag_case": r.tagCase = "lower" === n[e] || "upper" === n[e] ? n[e] : ""; break; ...1
2
3
4
5
6
7
8
9
10
11
12
13
14重点其实在第 3 行
const n = Object.assign({}, N, t)[e];,将其修改为:JavaScript... g = (function (e, t) { t || (t = {}); const profiles = Object.assign({}, N, t); const n = getProfileOfCurrentLanguageId(profiles) || profiles[e]; if (!n || "string" == typeof n) return "xhtml" === n ? { selfClosingStyle: "xhtml" } : {}; const r = {}; for (const e in n) switch (e) { case "tag_case": r.tagCase = "lower" === n[e] || "upper" === n[e] ? n[e] : ""; break; ...1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2. 编辑 VSCode 配置
现在自定义语言也支持 emmet.syntaxProfiles 配置,例如 Markdown:
JSON
...
"emmet.syntaxProfiles": {
"markdown": {
"tag_nl": false,
"tag_nl_leaf": false
}
},
...1
2
3
4
5
6
7
8
2
3
4
5
6
7
8