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

@ -144,3 +144,7 @@
[Machshev](https://github.com/machshev): [Machshev](https://github.com/machshev):
- Added `ruff` and `ty` LSP support for Python under `programs.python`. - Added `ruff` and `ty` LSP support for Python under `programs.python`.
[Snoweuph](https://github.com/snoweuph)
- Added Formatting support to the `just` language through its builtin formatter.

View file

@ -23,6 +23,18 @@
root_markers = [".git" "justfile"]; root_markers = [".git" "justfile"];
}; };
}; };
defaultFormat = ["just"];
formats = {
just = {
command = getExe pkgs.just;
args = [
"--unstable"
"--fmt"
];
};
};
in { in {
options.vim.languages.just = { options.vim.languages.just = {
enable = mkEnableOption "Just support"; enable = mkEnableOption "Just support";
@ -42,6 +54,16 @@ in {
description = "Just LSP server to use"; 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 [ config = mkIf cfg.enable (mkMerge [
@ -60,5 +82,20 @@ in {
}) })
cfg.lsp.servers; 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;
};
};
})
]); ]);
} }