pbrubaker
pbrubaker

Reputation: 61

Having trouble getting editor surround working in a vscode language extension

I'm adding ISPC (Intel SPMD Compiler) language support to VS Code and I've run into an issue. I'm unable to get the surround working. I've added the configurationDefaults to the contributes section in package.json and I've added a language configuration file that contains the brackets, autoClosingPairs and surroundingPairs section.

I've also tried setting the editor settings globally however no matter what I do the selection is deleted and replaced with the bracket/quote/comment character. Hopefully I'm just doing something wrong here. Thanks in advance for any help.

vscode version - 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": [
        ["{", "}"],
        ["[", "]"],
        ["(", ")"],
        ["\"", "\""],
        ["'", "'"],
        ["<", ">"]
    ]
}

Upvotes: 1

Views: 195

Answers (1)

pbrubaker
pbrubaker

Reputation: 61

I was able to solve this. I had a typo in the configuration file name.

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

Should have been:

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

Everything is working as expected now.

Upvotes: 0

Related Questions