Skip to content

Commit 917d562

Browse files
Merge #6840
6840: Add a language configuration file for VS Code r=matklad a=dustypomerleau There has been recent discussion in #6451 and #6682 about the need to include angle brackets in auto-close and auto-surround functionality. This PR will accomplish that, but only for users of VS Code, as it uses the VS Code-specific `language-configuration.json` to get the job done. Since there are a large number of VS Code users in the Rust Analyzer cohort, it may be reasonable to fix the issue for them, while waiting on a more comprehensive solution in the language server. In addition to the usual brackets, I've added auto-closing of block comments. I avoided autoclosing single quotes, given that lifetimes are more common than chars. Co-authored-by: Dusty Pomerleau <[email protected]>
2 parents fbad1b8 + 612be09 commit 917d562

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"comments": {
3+
"lineComment": "//",
4+
"blockComment": [ "/*", "*/" ]
5+
},
6+
"brackets": [
7+
["{", "}"],
8+
["[", "]"],
9+
["(", ")"],
10+
["<", ">"]
11+
],
12+
"autoClosingPairs": [
13+
{ "open": "{", "close": "}" },
14+
{ "open": "[", "close": "]" },
15+
{ "open": "(", "close": ")" },
16+
{ "open": "\"", "close": "\"", "notIn": ["string"] },
17+
{ "open": "/*", "close": " */" }
18+
],
19+
"autoCloseBefore": ";:.,=}])> \n\t",
20+
"surroundingPairs": [
21+
["{", "}"],
22+
["[", "]"],
23+
["(", ")"],
24+
["<", ">"],
25+
["\"", "\""],
26+
["'", "'"]
27+
],
28+
"indentationRules": {
29+
"increaseIndentPattern": "^.*\\{[^}\"']*$|^.*\\([^\\)\"']*$",
30+
"decreaseIndentPattern": "^\\s*(\\s*\\/[*].*[*]\\/\\s*)*[})]"
31+
},
32+
"folding": {
33+
"markers": {
34+
"start": "^\\s*//\\s*#?region\\b",
35+
"end": "^\\s*//\\s*#?endregion\\b"
36+
}
37+
}
38+
}

editors/code/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,17 @@
734734
"extensions": [
735735
".rast"
736736
]
737+
},
738+
{
739+
"id": "rust",
740+
"extensions": [
741+
".rs"
742+
],
743+
"aliases": [
744+
"Rust",
745+
"rs"
746+
],
747+
"configuration": "language-configuration.json"
737748
}
738749
],
739750
"grammars": [

0 commit comments

Comments
 (0)