ITensorFormatter.jl is a code formatter for Julia source files used by packages in the ITensor ecosystem. It makes use of Runic.jl, and JuliaFormatter.jl, and also organizes using/import statements by merging adjacent blocks, sorting modules and symbols, and line-wrapping (similar to, and based off of, the using/import statement organization functionality in LanguageServer.jl).
ITensorFormatter.jl is supported by the Flatiron Institute, a division of the Simons Foundation.
This package resides in the ITensor/ITensorRegistry local registry.
In order to install, simply add that registry through your package manager.
This step is only required once.
julia> using Pkg: Pkg
julia> Pkg.Registry.add(url = "https://github.com/ITensor/ITensorRegistry")or:
julia> Pkg.Registry.add(url = "git@github.com:ITensor/ITensorRegistry.git")if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.
In Julia v1.12 and later, ITensorFormatter should be installed as a Pkg app:
julia -e 'using Pkg; Pkg.Apps.add("ITensorFormatter")'Assuming ~/.julia/bin is in your PATH you can now invoke itfmt, e.g.:
# Format all files in-place in the current directory (recursively)
# !! DON'T DO THIS FROM YOUR HOME DIRECTORY !!
itfmt .In Julia v1.11 and earlier (or if you don't want to use a Pkg app), ITensorFormatter can also be installed manually with Julia's package manager:
# Install ITensorFormatter
julia --project=@itfmt --startup-file=no -e 'using Pkg; Pkg.add("ITensorFormatter")'
# Install the itfmt shell script
curl -fsSL -o ~/.local/bin/itfmt https://raw.githubusercontent.com/ITensor/ITensorFormatter.jl/refs/heads/main/bin/itfmt
chmod +x ~/.local/bin/itfmtThis page was generated using Literate.jl.