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

feature proposal: make config optional #3

Open
steveej opened this issue Nov 14, 2024 · 3 comments
Open

feature proposal: make config optional #3

steveej opened this issue Nov 14, 2024 · 3 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@steveej
Copy link

steveej commented Nov 14, 2024

issue

this would introduce compatibility with a wrapped treefmt binary that already encodes a --config /nix/store/path.

e.g. using this as a formatter seems convenient to me:

    inputs.treefmt-nix.lib.mkWrapper pkgs {
      # Used to find the project root
      projectRootFile = ".git/config";
      programs.nixfmt.enable = true;
    };

the wrapper binary treefmt ends with

exec /nix/store/m9q4afy31dshqb47047pghb1f4jr6fxf-treefmt-0.6.1/bin/treefmt --config-file /nix/store/ccr7krsq3grwsli2a5z206ypwdxz5ax5-treefmt.toml "$@" --tree-root "$tree_root"

for treefmt v1,
when this is called by the extension it ends up with an error due to duplicate --config argument:

Error running treefmt-nix: error: the argument '--config-file <CONFIG_FILE>' cannot be used multiple times Usage: treefmt [OPTIONS] [PATHS]... For more information, try '--help'.

for treevmt v2 it's not an error, and on first try treevmt v2 uses the last occurrence of --config-file, thus whatever happens to be in the repository.

proposal

add an extension setting that indicates skipping of config creation and omitting the --config <..> argument.

@isbecker
Copy link
Owner

isbecker commented Nov 16, 2024

Hi @steveej, can you please let me know what version of the extension you have installed?

Thanks!

I hope that the issue you're facing may have been addressed in the latest 2.1.0 release. The change below, you can see that it only adds the --config when the option is set in the vscode settings for the extension.

if (configPath) {
if (!path.isAbsolute(configPath)) {
configPath = path.join(workspaceRoot, configPath);
}
args = ` --config-file=${configPath}`;
}

@steveej
Copy link
Author

steveej commented Nov 16, 2024

thanks for the response @isbecker.

i just updated to v2.1.0. after removing the treefmt.toml and setting "treefmt.config": null explicitly i'm still seeing this notification when running treefmt in vscodium:

treefmt.toml not found. Would you like to create treefmt.toml?

IIUC this code always returns early if the config hasn't existed when the call happened.

@isbecker
Copy link
Owner

@steveej thanks for the additional information and context, I will look into a fix for this behavior.

@isbecker isbecker added bug Something isn't working enhancement New feature or request labels Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants