Visual Studio Code: How to Include another language in a user defined language?

时光毁灭记忆、已成空白 提交于 2020-01-03 05:54:08

问题


I have downloaded a plugin for Language A. It is at %USERPROFILE%.vscode\extensions\langA\syntaxes. There is a file langA.tmLanguage. It is XML.

I am creating "language B". I have a JSON tmLanguage file. I have already added some custom coloring and folding rules. I would like to inherit language A's syntax when it is embedded in Language B between START_MARKER and END_MARKER. Is this possible? Can someone help with the JSON syntax to accomplish this?

Bonus Q: Can anyone point me to a real simple hover example not using a language server? I would like to create a hover that takes the word with the cursor and searches the document for "DEF_MARKER word" to display in the hover. I am struggling with the real language examples due to my lack of experience in these languages and the complexity involved in say the GO example or other plugins I have downloaded.


回答1:


I think I got it.

{
    "name": "entity.name.tag",
    "begin": "^START_MARKER",
    "end": "^END_MARKER",
    "patterns": [
        {
            "include": "source.LangA"
        }
    ]           
}


来源:https://stackoverflow.com/questions/47394392/visual-studio-code-how-to-include-another-language-in-a-user-defined-language

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