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

feat: support use vscode variables in settings #399

Merged

Conversation

njzydark
Copy link
Contributor

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"
        }
      }
    }
}

@njzydark njzydark force-pushed the feat-support-vscode-variables branch from 0920035 to 9e7320c Compare June 13, 2024 14:14
export default function variables(
string: string,
recursive?: boolean,
): string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to export these types? is this needed by vscode ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type definition is mainly for solving type checking issues.

use vscode-variables package to support using ${workspaceFolder} in configuration files to define paths
@njzydark njzydark force-pushed the feat-support-vscode-variables branch from 9e7320c to 92dcfca Compare June 13, 2024 15:48
@@ -73,6 +73,10 @@ Pass settings to the language server via the `serverSettings` option.
},
"home-manager": {
"expr": "(builtins.getFlake \"/absolute/path/to/flake\").homeConfigurations.<name>.options"
},
// Tip: use ${workspaceFolder} variable to define path
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe this feature here

@jnoortheen jnoortheen merged commit a602050 into nix-community:main Aug 2, 2024
@jnoortheen
Copy link
Collaborator

Thanks for the contribution @njzydark !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants