visual-studio-code - 如何在 V.S. 中获得语法高亮支持? JSONL 代码 — "JSON-Lines"— 当文件类型不受支持时?

标签 visual-studio-code jsonlines

我有一些 JSONL ("JSON Lines")使用 .jsonl 的文件因此,文件扩展名;我想知道是否有办法在 中获得支持VS代码 对于 JSONL — "JSON-Lines"— 当编辑器尚不支持该文件类型时?
我在想也许有一种方法可以将支持添加到 VS代码 ?
建议我搜索一个扩展,以增加对 编辑器的支持。 JSON 行 ( .jsonl ) 文件(每 recommendation ),令人沮丧的是,VSCode 没有推荐 JSONL 扩展。
我还在 Marketplace 中搜索了“JSON Lines”和“.jsonl”,再次搜索没有返回任何有用的结果。

最佳答案

2021 年 7 月 21 日 @ 04:08 UTC — 编辑:“添加了另一个可能的解决方案”

支持不受支持的文件类型的可能解决方案

在回答另一个关于“VS Code 中的语言支持”的问题时,我想起了来自 的问题。 '问答' ,我意识到有一个可能有效的解决方案。如果作者还没有找到解决方案,那么我建议他们尝试这个,如果其他人偶然发现这个问题,希望添加对不受支持的语言的支持。
首先,如果您添加的语言和/或文件类型是完全唯一的,那么此解决方案将不起作用;如果能得到支持,可能不是全力支持,也可能有其他问题。让我给你举个例子,以帮助你充分理解我想告诉你的是什么。
例子:

To start, let me show you the syntax for the solution. This is a setting used in V.S. Code's settings.json file — it can be placed in either the user's, or the workspace's implementation of the settings.json file.
   // "./.vscode/settings.json"

   "files.associations": {
       "json": "jsonc"
   },

"Hypothetically, lets say V.S. Code does not support the JSONC file type — 'JSON with Comments'. If the previous statement were true, which it isn't, but if it were, then this solution would work, however, if you have JSONC files already filled with data, then you will likely get errors, as the JSONC file type is used to implement comments in a JSON file, however, V.S. Code's JSON language does not support comments, and the editor will display errors for every comment that there is in a JSONC document, because when you configure your editor this way, V.S. code treats JSONC files as JSON files."



"There are other instances where using this configuration works better. Since we already used JSONC as an example, I'll give you a real world example, where the File-Associations Setting is used to support comments in .json (JSON) files — remember, the above was a hypothetical example, this one is an actual example practiced by developers."
"Adding comments to JSON file is simple, and quick, using the File Association Setting, simple invert the configuration from the code block above, so that the settings configuration looks like the example below. If you type the configuration into your .vscode/settings.json file, you will find that V.S. Code won't complain when you add a comment to a JSON file anymore.
    // "./.vscode/settings.json"  

    "files.associations": {
        "jsonc": "json"
    }, 
基本上,简而言之,使用文件关联 (file.associations) 设置,您可能会也可能不会获得一些支持,可能是有限支持,也可能是完全支持。这很容易尝试,而且比添加对 V.S.整个编程语言或数据文件类型的代码。

2021 年 6 月 23 日 @ 22:45 UTC — 原始帖子

配套解决方案JSONL在 V.S.代码

没有人为 创建支持JSONL VSCode 中的文件。像您一样,我找不到为 添加语言支持的扩展程序JSON 行或 JSONL 文件。在 VSCode 中获得支持的唯一方法是将支持添加到 VSCode。 VSCode 为其用户提供了定义语言所需的工具。他们提供的工具与 MS VSCode 开发团队用来定义语言的工具相同,换句话说,都是很好的工具,你可以用它们做很酷的事情。如果它是一门完整的语言,这可能不值得考虑,但它不是,它只是对预先存在的数据类型的几个小添加。最难的部分是阅读 VSCode 文档以了解如何使用扩展 list 中的 Contributes 属性,这只是一个美化的 package.json文件。
我知道没有人喜欢做额外的工作,特别是如果它的工作量也比他们多,但我向你保证,一旦你了解了 VSCode 扩展 list 及其贡献属性的基础知识,再加上一点关于 TextMate 的工作原理,您可以在不到几个小时内完成您想做的事情。返回也是巨大的,学习如何制作 VSCode 扩展是我非常乐意做出的决定,我几乎每天都在使用这些知识。此外,这是您获得支持的唯一途径。

这里有几个不错的起点:

LANGUAGE DEFINITIONS (Official VSCode Website)
SYNTAX HIGHLIGHTING (Official VSCode Website)
CONTRIBUTES OBJECT (Official VSCode Website)
EXTENSION MANIFEST (Official VSCode Website)
TEXTMATE GRAMMARS DOCS (TextMate Official Website)
TEXTMATE TOKENS/SCOPES IN VSCODE (Official VSCode Website)

最后说明:
您唯一的其他选择是给负责 JSON Lines 的人发电子邮件,询问他们建议使用什么编辑器,或者询问他们是否计划在 future 添加对 VSCode 的支持。

关于visual-studio-code - 如何在 V.S. 中获得语法高亮支持? JSONL 代码 — "JSON-Lines"— 当文件类型不受支持时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66874505/

相关文章:

python - 将 JSONL 文件加载为 JSON 对象

visual-studio-code - 我怎样才能让 vscode 知道 SCM 何时可见?

visual-studio-code - VS 代码更改菜单中悬停元素的背景颜色

json - 将 JSONL 转换为 JSON

python - 如何从元素不断变化的 JSONL 文件中提取元素?

npm - 为什么 jsonlines 包会解析为registry.npm.taobao.org?

javascript - 使用 Typescript+VSCode 调试 Node.js 异步/等待

javascript - VS Code 自动格式化更漂亮

visual-studio-code - 如何使用终端 API 监听 vscode 中的所有终端输出?

python - 将文本文档转换为 jsonl(json 行)格式