language/just: formatter

This commit is contained in:
Snoweuph 2026-01-24 00:18:32 +01:00
commit 1af12636cd
No known key found for this signature in database
GPG key ID: BEFC41DA223CEC55
2 changed files with 41 additions and 0 deletions

View file

@ -23,6 +23,18 @@
root_markers = [".git" "justfile"];
};
};
defaultFormat = ["just"];
formats = {
just = {
command = getExe pkgs.just;
args = [
"--unstable"
"--fmt"
];
};
};
in {
options.vim.languages.just = {
enable = mkEnableOption "Just support";
@ -42,6 +54,16 @@ in {
description = "Just LSP server to use";
};
};
format = {
enable = mkEnableOption "Justfile formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Justfile formatter to use";
type = listOf (enum (attrNames formats));
default = defaultFormat;
};
};
};
config = mkIf cfg.enable (mkMerge [
@ -60,5 +82,20 @@ in {
})
cfg.lsp.servers;
})
(mkIf cfg.format.enable {
vim.formatter.conform-nvim = {
enable = true;
setupOpts = {
formatters_by_ft.just = cfg.format.type;
formatters =
mapListToAttrs (name: {
inherit name;
value = formats.${name};
})
cfg.format.type;
};
};
})
]);
}