我可以在 VS Code 中扩展现有的着色器或语言吗 [英] Can I Extend an Existing Colorizer or Language in VS Code

查看:28
本文介绍了我可以在 VS Code 中扩展现有的着色器或语言吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的是创建一个扩展 HTML 支持的扩展 - 也就是说,它可以完成 HTML 支持所做的一切以及更多,其中包括以下内容:

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. 语法高亮(着色器)
  2. 智能感知
  3. 格式化 HTML
  4. Emmet 片段

这些细节列在这个页面上HTML Programming in VS代码

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

最终我想创建一个支持 Liquid Templating 语法高亮和自动完成的扩展.

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

我已经让 #1 自己作为着色器工作,而 #2 可以通过语言服务器完成.

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

由于 Liquid 表达式被插入到 HTML 文档中,因此该插件应该建立在/扩展 HTML 支持之上,而不是覆盖它.这可能吗?

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?

推荐答案

这看起来不可能作为扩展.查看源代码src\vs\languages\html\common,如果我想扩展现有的内置语言支持,那么我可以创建一个类扩展.

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.

例如,Handlebars 语言支持是 HTML 的扩展,并且是这样实现的:

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> { ... }

所以在我的特殊情况下,我要么想要扩展 HTML 或 Handlebars(我还没有确定哪个更有意义)以添加 Liquid 语言支持.

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.

这篇关于我可以在 VS Code 中扩展现有的着色器或语言吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆