Rust-analyzer: VS Code won't surround with angle brackets when rust-analyzer is used

Created on 30 Nov 2020  路  3Comments  路  Source: rust-analyzer/rust-analyzer

When rust-analyzer is disabled I can select a word in a Rust file, type < and the word will be wrapped with < >. When rust-analyzer is turned on this doesn't work anymore. I don't think this is a duplicate of #6451 but they might be related.

A-vscode E-has-instructions good first issue

Most helpful comment

Happy to submit this鈥攋ust waiting on some consensus as to whether it's helpful to solve this only in the VS Code space.

All 3 comments

For VS Code specifically, I think RA could just ship its own language-configuration.json. I'm not certain how this would interact with language configurations provided by other extensions鈥攑resumably they would be overridden. The docs are here. This solution leaves the other editors unaddressed, but maybe it could be used temporarily, until the language server can be extended to handle these cases.

6451 is addressed with the autoClosingPairs key, and #6682 is addressed with the surroundingPairs key, so they are related, but not identical. If we were going to ship a VS Code language config, my first attempt would be:

// language-configuration.json

{
    "comments": {
        "lineComment": "//",
        "blockComment": [ "/*", "*/" ]
    },
    "brackets": [
        ["{", "}"],
        ["[", "]"],
        ["(", ")"],
        ["<", ">"]
    ],
    "autoClosingPairs": [
        { "open": "{", "close": "}" },
        { "open": "[", "close": "]" },
        { "open": "(", "close": ")" },
        { "open": "<", "close": ">" },
        { "open": "\"", "close": "\"", "notIn": ["string"] },
        { "open": "/*", "close": " */" }
    ],
    "autoCloseBefore": ";:.,=}])> \n\t",
    "surroundingPairs": [
        ["{", "}"],
        ["[", "]"],
        ["(", ")"],
        ["\"", "\""],
        ["'", "'"],
        ["<", ">"]
    ],
    "indentationRules": {
        "increaseIndentPattern": "^.*\\{[^}\"']*$|^.*\\([^\\)\"']*$",
    "decreaseIndentPattern": "^\\s*(\\s*\\/[*].*[*]\\/\\s*)*[})]"
    },
    "folding": {
        "markers": {
            "start": "^\\s*//\\s*#?region\\b",
            "end": "^\\s*//\\s*#?endregion\\b"
    }
    }
}

Happy to submit this鈥攋ust waiting on some consensus as to whether it's helpful to solve this only in the VS Code space.

I think this was implemented in #6840, please reopen if still now working.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Matelasse picture Matelasse  路  3Comments

mehmooda picture mehmooda  路  3Comments

GopherJ picture GopherJ  路  3Comments

csmoe picture csmoe  路  4Comments

jhpratt picture jhpratt  路  3Comments