-
Notifications
You must be signed in to change notification settings - Fork 29.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple languages specific editor settings #51935
Comments
(Experimental duplicate detection) |
really want it! we are using something like |
I would like this as well but should the logic around having a duplicate setting for the same language? Should there be a hierarchy, ie having the settings pull from the single language specification over the multiple language specifications? E.g. get settings for javascriptreact from "[javascript, javascriptreact]": {
"editor.insertSpaces": true
},
"[javascriptreact]": {
"editor.insertSpaces": true
} |
Yup, also want this. Currently it's just a bit of a pain.
|
Would love this feature, tons of duplicated settings in my settings file and this feature would clean it up quite nicely and reduce copy/pasta accidents. |
Also adding my +1 for this 👍 |
Looks like it's "On Deck" for consideration for an upcoming release so that's good news! |
Please just emoji 👍 the original post at the top, that way your demand is expressed without notifying everyone who is subscribed for updates |
Would be nice for a simple rule to not be this long
|
Gotta add my +1 for this! 🎉 |
Should the second entry in this example be treated as a duplicate object key? |
@igetgames Rather than duplicate object key, perhaps if there are duplicate settings for the same language then a warning message could appear. In the code example above:
A warning message could appear along the lines of: The setting |
But only if it has an identical value.
in this example I'd expect it to have a different behaviour ONLY for "javascriptreact". |
That could overwhelm a user and add un-needed complexity. A warning should appear on the key, irrespective of the value. I think that would be a nicer user experience overall. |
@RMacfarlane Any updates? |
@Szymono you do realize VSCode's the open-source one right?... You can view the source code, it's under MIT license and anyone can fork/make a PR for it. |
@Szymono well you could fork it and implement this feature instead of calling developers stupid just because they couldn't attend to it yet. That's because, you know, it is open source |
Hey let's keep this thread peaceful and productive please. I would love to see this implemented at some point. |
I had a Glance at the repo and while I do not have the time to work on this at the moment I think this is a good place to start when looking to implement such a feature: |
I tried to search a bit deeper into where this could be implemented so I'll leave what I found here. A test for language specific settings in configurationModels.test.ts shows us that the configurationModelParser is the object that parses settings. If I understand correctly this creates an object Settings are being tested for satisfying Right below this Regex pattern there's the function I've also thought lightly on how best to store these settings. I think storing them for each language individually is okay. This is what we're doing without this feature anyway, and other methods would likely require more complicated requests for settings than how it works now. Those would likely not only slow down when multiple languages are defined, but always make loading the settings slower. Here I copy some of the behaviour we want from above so it's easier to find:Doubly configured with same value:
Could be accepted or give a warning message along the lines of:
Doubly configured with different value:
Should be accepted and use Doubly configured in disjoint sets (different value):
Should be accepted and use Doubly configured in disjoint sets (same value):
Should be accepted and use |
Did it |
Implemented this feature and you can configure editor settings for multiple languages with single key as follows: "[cpp][c]":{
"editor.formatOnSave": true
} We already use this syntax in the setting "workbench.colorCustomizations": {
"[GitHub Sharp][GitHub Sharp Dark]": {
"editorPane.background": "#d6d0d01a",
"sideBarSectionHeader.border": "#D3D3D3",
}
} Hence, went with this syntax also here to define multiple languages. |
@sandy081 How come you decided to separate the languages into separate brackets?
The original issue called for it to be a comma-separated list inside the brackets and it's a lot more semantic with less verbosity. If you want to overload 20 languages that you have to match up 20 brackets for and if one of them is malformed it's likely an invalid key. A single bracket is plenty sufficient and reduces the clutter from the additional characters: "[javascript][typescript][json][html][jsx-tags][yaml][editorconfig][dotenv][astro][javascriptreact]":
{
"editor.formatOnSave": true
} "[javascript, typescript, json, html, jsx-tags, yaml, editorconfig, dotenv, astro, javascriptreact]":
{
"editor.formatOnSave": true
} |
While we're at it, why not be as forgiving as possible and allow no brackets at all "javascript, typescript, json, html, jsx-tags, yaml, editorconfig, dotenv, astro, javascriptreact": as well as no spaces "javascript,typescript,json,html,jsx-tags,yaml,editorconfig,dotenv,astro,javascriptreact": |
@CEbbinghaus It was decided by the team - we already use the same syntax in |
Hey When can we use it? It's not supported in:
cc @sandy081 |
With next release - 1.63.0. You can also try insiders channel to use it now - http://code.visualstudio.com/insiders/ |
We definitely need the ability to set those for multiple languages at once.
Something like:
Instead of:
The text was updated successfully, but these errors were encountered: