nix-community / vscode-nix-ide

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

feat: support use vscode variables in settings #399

Open njzydark opened 1 month ago

njzydark commented 1 month ago

https://github.com/nix-community/nixd/blob/main/nixd/docs/configuration.md#where-to-place-the-configuration

According to the above document, when defining the expr of options, only absolute paths can be used. This is very inconvenient for configuring across machines. Therefore, this PR introduces the vscode-variables package to support using ${workspaceFolder} in configuration files to define paths.

before

{
    "nixd": {
      "options": {
        "nixpkgs": {
          "expr": "import <nixpkgs> { }"
        },
        "nix-darwin": {
          "expr": "(builtins.getFlake \"/absolute/path/to/flake\").darwinConfigurations.default.options"
        }
      }
    }
}

after

{
    "nixd": {
      "options": {
        "nixpkgs": {
          "expr": "import <nixpkgs> { }"
        },
        "nix-darwin": {
          "expr": "(builtins.getFlake \"${workspaceFolder}/flake\").darwinConfigurations.default.options"
        }
      }
    }
}