JuliaFormatter.jl

Build Status

Width-sensitive formatter for Julia code. Inspired by gofmt, refmt, black, and prettier. Built with CSTParser.

  • Sane defaults out of the box with options to customize.
  • Supports YAS and Blue style guides.
  • JuliaFormatter.toml configuration file to store options.

Installation

]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)

Usage

JuliaFormatter exports format, format_file, format_text, and format_md:

JuliaFormatter should work on any valid Julia and Markdown files. If JuliaFormatter cannot parse the code for any reason, it will throw an error pointing to the line that could not be parsed. If running format on multiple files, you may want to set verbose = true to print information about which file is being formatted.