From dfb9eeec99272fcb2776d39ac634275715bc1549 Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Sat, 30 Dec 2023 06:34:14 -0300 Subject: [PATCH] feat: add juliaformatter - adds juliaformatter(https://github.com/domluna/JuliaFormatter.jl) - most of the settings were ported from https://github.com/qiaojunfeng/pre-commit-julia-format/blob/main/.pre-commit-hooks.yaml --- README.md | 4 ++++ modules/hooks.nix | 20 ++++++++++++++++++++ nix/tools.nix | 2 ++ 3 files changed, 26 insertions(+) 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