Skip to content
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

C/C++ Support: Can this be used to help generate the c_cpp_properties.json configuration file? #70

Open
CMCDragonkai opened this issue Jun 7, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@CMCDragonkai
Copy link

Is your feature request related to a problem? Please describe.

The c_cpp_properties.json configuration file is necessary for intellisense to work for C/C++ files.

For example right now I have to manually configure it like:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/nix/store/zl4bvsqfxyx5vn9bbhnrmbmpfvzqj4gd-nodejs-16.14.2/include/**"
            ],
            "defines": [],
            "compilerPath": "/nix/store/58pwclg9yr437h0pfgrnbd0jis8fqasd-gcc-wrapper-11.2.0/bin/gcc",
            "cStandard": "c99",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

In particular both the compilerPath and includePath I had to add in manually.

My shell.nix brings in $NIX_CFLAGS_COMPILE and $NIX_LDFLAGS which shows us all the include paths we need.

Describe the solution you'd like

It would be nice if nix-env-selector could acquire this information, or allow us to configure it to acquire this information from the relevant nix environment, then provide us a way to reference these "variables" from the shell environment for other VScode extensions such as the C/C++ extension. That would be most flexible way.

I could imagine doing something like:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "${nixEnv:...}"
            ],
            "defines": [],
            "compilerPath": "${nixEnv:NIX_CC}",
            "cStandard": "c99",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

I'm not familiar with how vscode extensions work, and how to apply these variables to vscode dynamically, but it would greatly simplify the usage of nix-shell related environment configuration with other extensions and other languages.

@CMCDragonkai CMCDragonkai added the enhancement New feature or request label Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants