-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Configuration improvements #1338
Comments
Yeah, changing the ordering makes sense to me. |
The trouble is going to be that the default ordering will be temporary if developers use the light bulb to add include paths to this property (since they are added at the end and not in the middle). We really need to split out the system includes from the project includes. I hate to add yet another 'include path' property but there may be an opportunity to do this if we move c_cpp_properties.json to settings.json in the near future. @csholmq, do you mind if we morph this issue into a design spec for how include paths could be handled in the post-c_cpp_properties.json world? I would like to hear the community's input on the subject as well. |
I don't mind this being merged into something bigger. Will settings.json support project specific includes? I would envision some generic ones and then project specific ones in a separate array that gets included first. To be honest the system default ones mostly messes up my workflow since I have to remove them for every project I open as I work with embedded ones. So to be able to setup a default setting which can be overwritten would probably solve that. |
@bobbrow I assumed we should change the code action include to add the settings to the front of the list instead of the back (I haven't checked if there's a problem doing that). @csholmq Yeah, there would be user settings that apply to all projects, and then workspace settings for the particular project, just like the normal settings.json, but we'd also have a list of configurations in the settings as well, but we haven't ironed out all the details. |
An interim solution would be to add project specific includes to the front of the array. |
We're still discussing how to handle this (we should have more info in Jan). |
Sorry for the delay. This has been a long time coming and I've gone through a couple of iterations internally before getting this into a state that is ready for comments. Most notably, we've decided that removing c_cpp_properties.json would be extremely disruptive to the community and extensions that take a dependency on us and have decided against it. We have an alternative plan that should be able to adequately address the problems that led us to consider removing it in the first place. This plan will allow us to make c_cpp_properties.json an optional configuration tool. related issues: New VS Code settingsFirst, we will be adding new
These settings have all of the benefits of VS Code settings, meaning that they can have default, "User", "Workspace", and "Folder" values. So you can set a global value for Updated c_cpp_properties.json syntaxSecond, we will add a special variable to the accepted syntax of c_cpp_properties.json that will instruct the extension to actually use the default value from the VS Code settings. If you set the value of any setting in c_cpp_properties.json to "${default}" it will instruct us to read the VS Code default setting for that property and insert it. For example:
Take note that for the properties that accept string[], the syntax proposed above allows you to augment the VS Code setting with additional values, thus allowing you to have common paths listed in the VS Code settings and configuration-specific settings in c_cpp_properties.json. If a property is missing from c_cpp_properties.json, the extension will use the value in the VS Code setting. If a developer assigns values to all of the settings that apply for a given folder, then c_cpp_properties.json could be removed from the .vscode folder as it will no longer be needed. System includesThird, a new setting will be added that allows you specify the system include path separate from the folder's include path. If this setting has a value, then the system include path the extension gets from the compiler specified in the
Include Path Resolution StrategiesThe extension determines the includePath to send to the IntelliSense engine in the following manner:
System includes should no longer be added to the Advanced ScenariosFor more complex projects that would like to define base configurations and inherit from them, we can also add support for that too, but it will not come in the first wave of changes. Adding support for this will be conditional on the demand for it, so the following is merely a rough outline of how if might work and may need to be refined a bit. The basic concept would be that c_cpp_properties.json could import configs from another json file and inherit them using the following syntax:
Using this syntax, you can specify either "configurations", or "import", or both. Missing both properties results in an error. The imported configuration files do not need to be named "c_cpp_properties.json". They just need to conform to the schema. The configuration schema would add a new property: For example:
|
Is omitting a configuration option the same as specifying it to ${default}? I don't fully understand if you are enabling the issue with system defaults (e.g system defaults) to not Trump project specific ones. Do I need to set the default includePath to blank to achieve this? |
Yes.
EDITED: |
@bobbrow We currently do "a. Interpret the first argument in the command as the compiler and attempt to query it." only after the compilerPath was deemed invalid. Did you intend to change that? Was there a reason? If so, then we'd need to fix the bug where "other" compile command args aren't being passed to the compiler for querying defines/includes to avoid a regression. The original intent was for the compilerPath to take precedence for when the compiler found in the compile commands was invalid, but the new way could be made to work too. Also, is the compilerPath still queried for system defines when systemIncludePath is set? |
Thanks for pointing that out @sean-mcmanus. That was an unintentional mistake. I will fix it. |
Hi, as I'm reading this, the system include paths detected by VSCode will now be separate from the 'user defined' includes paths? If this is correct then "hooray" \o/ because currently I'm doing all sorts of hacks to detect the system includes since I'm generating c_cpp_properties.json files 'out of thin air' in my cmake wrapper (with things like trying to figure out what Visual Studio versions and what Windows Kits are installed (see here for the OSX/Linux clang version: https://github.com/floooh/fips/blob/9681f85be1e220b7539f5abed0751f959d837f23/mod/tools/vscode.py#L105, and here for the Visual Studio version: https://github.com/floooh/fips/blob/9681f85be1e220b7539f5abed0751f959d837f23/mod/tools/vscode.py#L140). It would be really great if:
|
@floooh, if you are generating c_cpp_properties.json, then you should only need to set the |
A preview of this is available in the insiders build if you would like to try it out and provide feedback. |
This is implemented in 0.17.0. I also added a "env" property to c_cpp_properties.json to enable creating variables shared across configs for cases where the "Advanced Scenario" syntax is overkill.
|
Hi, My goal is to have 1 single workspace configuration file for everything... |
Yes, this request is similar to #2060, but it is actually a combination of 2 requests:
|
If there are two requests, can you clarify in #2060 which one it covers and then open another issue for the second one? |
Done, I just opened #2096. Thank you. |
Thanks, @dsanz006 |
When creating a new
c_cpp_properties.json
the default system includes comes first meaning that any project modules with the same name is not included. (E.g Io.h gets matched inC:/Program Files (x86)/Windows Kits/10/Include/10.0.14393.0/ucrt
before the project specific)Similarly, adding local paths gets appended to the end of the
includePath
array.The text was updated successfully, but these errors were encountered: