feat(jj): configure jj fix with formatters from nvim
Export nvim formatters as `jj fix` tools.
This commit is contained in:
parent
434829c96a
commit
cf335569c2
2 changed files with 61 additions and 2 deletions
|
@ -6,6 +6,64 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.jhome.dev;
|
cfg = config.jhome.dev;
|
||||||
|
nvimFormatters = builtins.mapAttrs (
|
||||||
|
name: value: value.command
|
||||||
|
) config.nixvim.plugins.conform-nvim.settings.formatters;
|
||||||
|
jjFormatters =
|
||||||
|
let
|
||||||
|
ext = extension: "glob:'**/*.${ext}'";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
fish = cmd: {
|
||||||
|
command = [ cmd ];
|
||||||
|
patterns = [ (ext "fish") ];
|
||||||
|
};
|
||||||
|
nixfmt = cmd: {
|
||||||
|
command = [
|
||||||
|
cmd
|
||||||
|
"--filename=$path"
|
||||||
|
];
|
||||||
|
patterns = [ (ext "nix") ];
|
||||||
|
};
|
||||||
|
shfmt = cmd: {
|
||||||
|
command = [
|
||||||
|
cmd
|
||||||
|
"--filename"
|
||||||
|
"$path"
|
||||||
|
"-"
|
||||||
|
];
|
||||||
|
patterns = [
|
||||||
|
(ext "sh")
|
||||||
|
(ext "bash")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
stylua = cmd: {
|
||||||
|
command = [
|
||||||
|
cmd
|
||||||
|
"--stdin-filepath=$path"
|
||||||
|
"-"
|
||||||
|
];
|
||||||
|
patterns = [ (ext "lua") ];
|
||||||
|
};
|
||||||
|
taplo = cmd: {
|
||||||
|
command = [
|
||||||
|
cmd
|
||||||
|
"--stdin-filepath=$path"
|
||||||
|
"-"
|
||||||
|
];
|
||||||
|
patterns = [ (ext "toml") ];
|
||||||
|
};
|
||||||
|
yamlfmt = cmd: {
|
||||||
|
command = [
|
||||||
|
cmd
|
||||||
|
"-in"
|
||||||
|
];
|
||||||
|
patterns = [
|
||||||
|
(ext "yaml")
|
||||||
|
(ext "yml")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config =
|
config =
|
||||||
|
@ -68,6 +126,7 @@ in
|
||||||
package = pkgs.unstable.jujutsu;
|
package = pkgs.unstable.jujutsu;
|
||||||
settings = {
|
settings = {
|
||||||
ui.pager = "bat";
|
ui.pager = "bat";
|
||||||
|
fix.tools = builtins.mapAttrs (tool: cmd: jjFormatters.${tool} cmd) nvimFmt;
|
||||||
# mimic git commit --verbose by adding a diff
|
# mimic git commit --verbose by adding a diff
|
||||||
templates.draft_commit_description = ''
|
templates.draft_commit_description = ''
|
||||||
concat(
|
concat(
|
||||||
|
|
|
@ -95,12 +95,12 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
formatters = {
|
formatters = {
|
||||||
fish.command = lib.getExe pkgs.fish;
|
fish.command = lib.getExe' pkgs.fish "fish_indent";
|
||||||
nixfmt.command = lib.getExe pkgs.nixfmt-rfc-style;
|
nixfmt.command = lib.getExe pkgs.nixfmt-rfc-style;
|
||||||
shfmt.command = lib.getExe pkgs.shfmt;
|
shfmt.command = lib.getExe pkgs.shfmt;
|
||||||
stylua.command = lib.getExe pkgs.stylua;
|
stylua.command = lib.getExe pkgs.stylua;
|
||||||
taplo.command = lib.getExe pkgs.taplo;
|
taplo.command = lib.getExe pkgs.taplo;
|
||||||
yamlfmt.command = lib.getExe' pkgs.yamlfmt "fish_indent";
|
yamlfmt.command = lib.getExe pkgs.yamlfmt;
|
||||||
};
|
};
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
"_" = [ "trim_whitespace" ];
|
"_" = [ "trim_whitespace" ];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue