Skip to content

qiaojunfeng/pre-commit-julia-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pre-commit-julia-format

pre-commit hooks for running JuliaFormatter.jl

Hook Prerequisites

  • requires JuliaFormatter.jl installed in a julia environment, e.g., can be the global environment, or a dedicated julia environment only for JuliaFormatter.jl, or the environment for your own julia package.

    To check if JuliaFormatter.jl is installed, run

    cd DIR_OF_YOUR_JULIA_ENVIRONMENT/
    julia       # start julia REPL
    ]           # enter Pkg mode
    activate .  # activate the environment of the current dir
    status      # there should be a JuliaFormatter installed

Hook Installation

To use the hook, add the following code block to your .pre-commit-config.yaml:

- repo: https://github.com/qiaojunfeng/pre-commit-julia-format
  rev: v0.2.0                # use the most recent version
  hooks:
  - id: julia-format         # formatter for Julia code

Hook Configuration

Julia project path

By default the hook will use the default julia environment (under ~/.julia/environments/) to run JuliaFormatter, if you want to use a different one, add an args key in the yaml:

  - id: julia-format
    args: [--project=/DIR_OF_YOUR_JULIA_ENVIRONMENT]

where DIR_OF_YOUR_JULIA_ENVIRONMENT is the path to your julia environment containing JuliaFormatter.jl.

Style

You can use the .JuliaFormatter.toml to specify the style.

Example usage

You can check this repo for an example of how to use the hook: https://github.com/qiaojunfeng/WannierIO.jl

References

About

pre-commit hooks for running JuliaFormatter.jl

Resources

License

Stars

Watchers

Forks

Packages

No packages published