mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
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 <dustypomerleau@users.noreply.github.com>
This commit is contained in:
commit
917d56273d
2 changed files with 49 additions and 0 deletions
38
editors/code/language-configuration.json
Normal file
38
editors/code/language-configuration.json
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"comments": {
|
||||
"lineComment": "//",
|
||||
"blockComment": [ "/*", "*/" ]
|
||||
},
|
||||
"brackets": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["<", ">"]
|
||||
],
|
||||
"autoClosingPairs": [
|
||||
{ "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"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -734,6 +734,17 @@
|
|||
"extensions": [
|
||||
".rast"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "rust",
|
||||
"extensions": [
|
||||
".rs"
|
||||
],
|
||||
"aliases": [
|
||||
"Rust",
|
||||
"rs"
|
||||
],
|
||||
"configuration": "language-configuration.json"
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
|
|
Loading…
Reference in a new issue