You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nph is an opinionated source code formatter for the Nim language, aiming to
take the drudgery of manual formatting out of your coding day.
Following the great tradition of black,
prettier, clang-format
and other AST-based formatters, it discards existing styling to create a
consistent and beautiful codebase.
# Format the given files in-place
nph file0.nim file1.nim
# Format the given files, writing the formatted code to /tmp
nph file0.nim file1.nim --outdir:/tmp
# Format an entire directory
nph src/
# Use --check to verify that a file is formatted as `nph` would - useful in CI
nph --check somefile.nim ||echo"Not formatted!"# Show a diff of what would change without modifying files
nph --diff somefile.nim
# You can format stuff as part of a pipe using `-` as input:echo"echo 1"| nph -
Configuration
You can configure nph using a .nph.toml file in your project root:
# Completely replace default exclusionsexclude = [
"build",
"dist",
]
# Add to default exclusions (more common)extend-exclude = [
"tests/fixtures",
"vendor",
]
# Customize which files to include (default: \.nim(s|ble)?$)include = [
"\.nim$",
"\.nims$",
]
CLI options override config file settings. See the
documentation for more details.
More information about features and style available from the
documentation
Installation
Binaries are available from the releases page on Github.
nph can be also compiled or installed using nimble v0.16.4+: