nix-community / vscode-nix-ide

Nix language support for VSCode editor [maintainer: @jnoortheen]
https://marketplace.visualstudio.com/items?itemName=jnoortheen.nix-ide
MIT License
286 stars 22 forks source link

How do I enable NixOS, Flake-parts, and Home-manager options at the same time when using nixd? #363

Closed sylvesterroos closed 3 weeks ago

sylvesterroos commented 11 months ago

The example in the README is not very clear on this. Copying this example leads to the obvious duplicate key errors, but there's also the <name> part. Is this supposed to be my username? Should it be .<myname>. or .myname.? Thanks

Relevant config:

"nix.serverSettings": {
    // settings for 'nixd' LSP
    "formatting": {
        "command": "nixpkgs-fmt"
    },
    "options": {
        "enable": true,
        "target": {
            // tweak arguments here
            "args": [],
            // NixOS options
            "installable": "<flakeref>#nixosConfigurations.<name>.options",
            // Flake-parts options
            "installable": "<flakeref>#debug.options",
            // Home-manager options
            "installable": "<flakeref>#homeConfigurations.<name>.options"
        }
    }
}
spikespaz commented 11 months ago

Currently not possible, as I understand. I requested of the author of Nixd to implement this for flakes, but as I understand, he doesn't use flakes and only supports such usage through flake-compat. That is until @edolstra finishes source tree abstraction, which would allow the LSP to provide file paths relative to your git directory.

Even still, if you manage to hack something together, you have to choose one installable or one expression, unless you want to create .vscode/settings.nix for each subdirectory of your flake.

I encourage you to pester the author of Nixd to implement a reasonable (even if hacky) solution to this.

jnoortheen commented 3 weeks ago

There is now advanced settings example available in the readme. https://github.com/nix-community/vscode-nix-ide?tab=readme-ov-file#lsp-plugin-support