【问题标题】:Having trouble getting editor surround working in a vscode language extension无法让编辑器环绕在 vscode 语言扩展中工作
【发布时间】:2018-10-11 03:54:15
【问题描述】:

我正在向 VS Code 添加 ISPC(英特尔 SPMD 编译器)语言支持,但遇到了问题。我无法让环绕声工作。我已将 configurationDefaults 添加到 package.json 中的贡献部分,并添加了一个包含括号、autoClosingPairs 和aroundPairs 部分的语言配置文件。

我也尝试过全局设置编辑器设置,但是无论我做什么,选择都会被删除并替换为括号/引号/注释字符。希望我只是在这里做错了什么。提前感谢您的帮助。

vscode 版本 - 1.28.0

package.json

"contributes": {
    "languages": [
      {
        "id": "ispc",
        "aliases": ["Intel® SPMD Program Compiler", "ISPC", "Volta"],
        "extensions": [".ispc", ".isph" ],
        "configuration": "./ispc.configuration.json"
      }
    ],

    "grammars": [
      {
          "language": "ispc",
          "scopeName": "source.ispc",
          "path": "./ispc.tmLanguage"
      }
    ],

      "snippets": [
      {
          "language": "ispc",
          "path": "./ispc-snippets.json"
      }
    ],

    "configuration": {
      "type": "object",
      "title": "ISPC ",
      "properties": {
        "ispc.maxNumberOfProblems": {
          "type": "number",
          "default": 100,
          "description": "Controls the maximum number of problems returned by the server."
        },
        "ispc.trace.server": {
          "type": "string",
          "enum": [
            "off",
            "messages",
            "verbose"
          ],
          "default": "off",
          "description": "Traces the communication between VSCode and the ISPC language server."
        }
      }
    },

    "configurationDefaults": {
         "[ispc]": {
             "editor.autoClosingBrackets": "always",
             "editor.autoClosingQuotes": "always",
             "editor.autoSurround": "brackets"
        }
    }
},

ispc.configuration.json

{
    "comments": {
        "lineComment": "//",
        "blockComment": ["/*", "*/"]
    },

    "brackets": [
        ["{", "}"],
        ["[", "]"],
        ["(", ")"]
    ],

    "autoClosingPairs": [
        { "open": "[", "close": "]" },
        { "open": "{", "close": "}" },
        { "open": "(", "close": ")" },
        { "open": "'", "close": "'", "notIn": ["string", "comment"] },
        { "open": "\"", "close": "\"", "notIn": ["string"] }
    ],

    "surroundingPairs": [
        ["{", "}"],
        ["[", "]"],
        ["(", ")"],
        ["\"", "\""],
        ["'", "'"],
        ["<", ">"]
    ]
}

【问题讨论】:

    标签: visual-studio-code vscode-extensions


    【解决方案1】:

    我能够解决这个问题。我的配置文件名有错别字。

    "configuration": "./ispc.configuration.json"
    

    应该是:

    "configuration": "./ispc-configuration.json"
    

    现在一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-29
      • 2018-02-17
      • 2018-07-30
      • 1970-01-01
      • 1970-01-01
      • 2021-11-25
      相关资源
      最近更新 更多