Skip to content

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

Open
@CMCDragonkai

Description

@CMCDragonkai

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions