JuliaFormatter for imports / using

I like writing my imports / using statements in the following style:

import CairoMakie
import CSV
import HDF5
import KernelDensity
import Makie
import StatsBase
using DataFrames: DataFrame
using Distributions: Gamma
using Distributions: logpdf
using Distributions: pdf
using Distributions: Poisson
using LinearAlgebra: Diagonal
using LinearAlgebra: eigen
using Makie: @L_str
using NaNStatistics: nanmean
using NaNStatistics: nansum
using ProgressMeter: @showprogress
using Random: bitrand
using Statistics: cor
using Statistics: mean
using Statistics: middle
using StatsBase: countmap

Thus, each using (for each symbol) and each import goes in its own line, and lines are sorted alphabetically.

Can I write a JuliaFormatter spec to help me enforce this style?

1 Like

I like that style as well.

This contradicts one Julia styleguide (there are at least three I know of this one I think most restrictive):

I don’t like it too much that there are many styleguides, at least when contradicting…

It’s fine to have different styleguides, that’s why it’s a style. What’s important is to stick to it in your own projects.

I still prefer my verbose way of writing imports over SciML guideline.

1 Like