Skip to content

domluna/JuliaFormatter.jl

Repository files navigation

JuliaFormatter.jl

Documenter: stable Documenter: dev Build Status

If you're having issues with v2 outputs use the latest v1. add JuliaFormatter@v1 should install 1.0.62

I don't have the time to commit large changes regarding v2. JuliaSyntax v1 broke a bunch of things again and it is a large undertaking fix everything needed to upgrade and then also fix previous issues. If you would like to contribute via PRs they would be welcomed.

Width-sensitive formatter for Julia code. Inspired by gofmt, refmt, and black.

Screencast

Installation

pkg> add JuliaFormatter

Quick Start

julia> using JuliaFormatter

# Recursively formats all Julia files in the current directory
julia> format(".")

# Formats an individual file
julia> format_file("foo.jl")

# Formats a string (contents of a Julia file)
julia> format_text(str)

Check out the docs for further description of the formatter and its options.

Command Line Tool

Starting from version 2.2.0, JuliaFormatter provides a command-line executable jlfmt.

To install:

pkg> app add JuliaFormatter

Usage:

# Format a file and write to stdout
jlfmt src/file.jl

# Format a file in place
jlfmt --inplace src/file.jl

# Check if all files in a directory are already formatted with verbose mode
jlfmt --check -v src/

# Format all files in a directory with multiple threads
jlfmt --threads=6 -- --inplace -v src/

# Show diff without modifying files
jlfmt --diff src/file.jl

Run jlfmt --help for more options.

Check out the CLI docs for further description of the formatter and its options.

Github Actions

Use With GitHub Actions

Editor Plugins

For integration with other editors:

About

An opinionated code formatter for Julia. Plot twist - the opinion is your own.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages