nix-community / vscode-nix-ide

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

Can't make it use treefmt #241

Closed wmertens closed 2 years ago

wmertens commented 2 years ago

Working on dream2nix, have direnv installed and working in the shell and in other vscode projects; it uses treefmt for formatting.

I set the workspace nix.formatter to treefmt and it keeps using my previous one until I reload the window. I assume https://github.com/nix-community/vscode-nix-ide/blob/8e899868f6cd3b46ae61a402927fc04ac3c53bd4/src/formatter.ts#L12 needs to be resolved at format time instead of at module load time.

But after reloading the window, it doesn't format at all. Passing treefmt or the full path (+reload) doesn't make a difference, vscode now says there's no formatter for nix files installed.

austinbutler commented 2 years ago

I can't get it to use my preferred formatter, either. I wonder if "Enable Language Server" overwrites the setting.

jnoortheen commented 2 years ago

Please check with the latest release.

wmertens commented 2 years ago

Hmm - I used the configuration from the readme for treefmt in my workspace configuration but when I save it still uses my user setting nixpkgs-fmt. Not sure how to debug this.

austinbutler commented 2 years ago

Seems I was correct, if you enable the language server the formatter is ignored, and nixpkgs-fmt is used since that's hardcoded by rnix-lsp and can't be changed yet.