neovim-flake/config/plugins/formatters.nix

66 lines
1.4 KiB
Nix
Raw Normal View History

# Code formatters
2024-09-02 18:28:53 -07:00
{ pkgs, ... }:
{
extraPackages = with pkgs; [
2024-09-02 18:25:15 -07:00
# TS/JS, Markdown, TOML, JSON, etc
nodePackages.prettier
# Rust
rustfmt
# Nix
2024-09-02 18:25:15 -07:00
nixfmt-rfc-style
# Python
black
# Lua
stylua
# Haskell
haskellPackages.fourmolu
2024-09-11 00:54:12 -07:00
taplo
# Misc
2024-09-02 18:25:15 -07:00
# codespell
];
plugins.conform-nvim = {
enable = true;
# because combinePlugins.enable = true, the collision of `doc` is
# unavoidable. this renames them.
package = pkgs.vimPlugins.conform-nvim.overrideAttrs (oldAttrs: {
postInstall =
(oldAttrs.postInstall or "")
+ ''
mv $out/doc/recipes.md $out/doc/conform-nvim_recipes.md
'';
});
# package = pkgs.vimPlugins.conform-nvim;
settings = {
format_on_save = {
timeoutMs = 500;
lspFallback = true;
};
formatters_by_ft = {
2024-09-02 18:28:53 -07:00
lua = [ "stylua" ];
python = [ "black" ];
nix = [ "nixfmt" ];
svelte = [ "prettier" ];
rust = [ "rustfmt" ];
haskell = [ "fourmolu" ];
2024-09-11 00:54:12 -07:00
toml = [ "taplo" ];
2024-09-02 18:28:53 -07:00
json = [ "prettier" ];
markdown = [ "prettier" ];
yaml = [ "prettier" ];
html = [ "prettier" ];
javascript = [ "prettier" ];
typescript = [ "prettier" ];
2024-09-02 18:25:15 -07:00
# "*" = ["codespell"];
2024-09-02 18:28:53 -07:00
"_" = [ "trim_whitespace" ];
};
};
};
}