Can I Extend an Existing Colorizer or Language in VS Code

这一生的挚爱 提交于 2019-12-11 00:15:49

问题


What I'd like to do is create an extension that extends HTML support - that is it does everything that HTML support does and more, which includes the following:

  1. Syntax Highlighting (colorizer)
  2. IntelliSense
  3. Format HTML
  4. Emmet snippets

These details are listed on this page HTML Programming in VS Code

Ultimately I would like to create an extension that supports Liquid Templating syntax highlighting and auto complete.

I've gotten #1 to work on it's own as a colorizer, and #2 can be accomplished through a language server.

Since Liquid expressions are inserted into HTML documents, the plugin should be built top of/extend HTML support rather than override it. Is this possible?


回答1:


It doesn't look like this is possible as an extension. Looking at the source code src\vs\languages\html\common, if I want to extend an existing built in language support, then I can create a class extension.

For example, Handlebars language support is an extension of HTML and is implemented thusly:

// handlebars.ts
import htmlMode = require('vs/languages/html/common/html');
export class HandlebarsState extends htmlMode.State { ... }
export class HandlebarsMode extends htmlMode.HTMLMode<htmlWorker.HTMLWorker> { ... }

So in my particular case, I'll either want to extend HTML or Handlebars (I haven't determined which makes more sense yet) in order to add Liquid language support.



来源:https://stackoverflow.com/questions/38404182/can-i-extend-an-existing-colorizer-or-language-in-vs-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!