-
Notifications
You must be signed in to change notification settings - Fork 78
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
How to use prettier
's plugins
option?
#112
Comments
You'd need to install the NPM module yourself. Right now accessing/managing NPM modules from Nix/Nixpkgs isn't straightforward |
Does pluginSearchDirs has any effect at all? I couldn't find it in the upstream documentations. I packaged the plugin with npm2nix but it's not found by prettier:
|
I got it working by specifying an absolute plugin path: https://git.clan.lol/clan/clan-core/src/commit/dbc0ae08c09a20b3921c663bee3356ff9d5ad7eb/formatter.nix#L15 |
Yeah it' not pretty (no pun intended lol) but that works... hopefully once NPM <=> Nix improves it will be more straightforward |
@Mic92 Is this still the recommended way? Looks like the absolutely plugin path hack has been removed from HEAD: https://git.clan.lol/clan/clan-core/src/branch/main/formatter.nix |
What is currently the best method to use a plugin that's in prettier = {
enable = true;
settings = {
plugins = [ "${pkgs.prettier-plugin-go-template}" ];
overrides = {
files = [ "*.html" ];
options.parser = "go-template";
};
};
}; Would this work? Do I need to specify the path further? Do I have to add the package separately? |
I don't actually don't know, we currently don't need prettier. |
When I got this working I installed the plugins via the devShell's packages and specified their names in the prettier config |
Prettier removed the |
How do you set plugin options? e.g. |
Finally got it working, had to update the plugin which is in nixpkgs. { pkgs, ... }:
{
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
gofmt.enable = true;
taplo.enable = true;
prettier = {
enable = true;
settings = {
plugins = [
"${pkgs.prettier-plugin-go-template}/lib/node_modules/prettier-plugin-go-template/lib/index.js"
];
overrides = [
{
files = [ "*.html" ];
options.parser = "go-template";
}
];
};
};
};
settings.global.excludes = [
"public/**"
"static/**"
];
} |
Follow-up to #103
When using the
prettier
formatter, how do we actually use theplugins
option?With
(To use https://tailwindcss.com/blog/automatic-class-sorting-with-prettier)
I get:
The text was updated successfully, but these errors were encountered: