diff --git a/README.md b/README.md index be033692..e7286226 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,10 @@ use nix - [revive](https://github.com/mgechev/revive) - [staticcheck](https://github.com/dominikh/go-tools) +## Julia + +- [JuiaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) + ## Shell - [shellcheck](https://github.com/koalaman/shellcheck) diff --git a/modules/hooks.nix b/modules/hooks.nix index 241597ce..f03e1aeb 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -2241,5 +2241,25 @@ in entry = "${tools.typst-fmt}/bin/typst-fmt"; files = "\\.typ$"; }; + + juliaformatter = { + description = "Run JuliaFormatter.jl against Julia source files"; + files = "\\.jl$"; + entry = '' + ${tools.julia-bin}/bin/julia -e ' + using Pkg + Pkg.activate(".") + using JuliaFormatter + format(ARGS) + out = Cmd(`git diff --name-only`) |> read |> String + if out == "" + exit(0) + else + @error "Some files have been formatted !!!" + write(stdout, out) + exit(1) + end' + ''; + }; }; } diff --git a/nix/tools.nix b/nix/tools.nix index fb889a45..6bae4fc0 100644 --- a/nix/tools.nix +++ b/nix/tools.nix @@ -36,6 +36,7 @@ , hunspell , luaPackages , lua-language-server +, julia-bin , mdl , mdsh , nil @@ -109,6 +110,7 @@ in hlint hpack html-tidy + julia-bin mdl mdsh nil