A fast, configurable Fortran formatter
Project description
ffmt
A fast, configurable Fortran formatter. Written in Rust. Installable via pip.
Installation
pip install ffmt
Or via Cargo:
cargo install ffmt
Usage
ffmt src/ # format in-place
ffmt --check src/ # CI mode (exit 1 if changes needed)
ffmt --diff src/ # show colored diff
ffmt -j 8 src/ # parallel
cat file.fpp | ffmt - # stdin/stdout
ffmt --range 10:50 file.fpp # format only lines 10-50
What it does
- Indentation -- scope-based indentation for all Fortran constructs
- Whitespace -- consistent spacing around operators, commas, colons, parentheses
- Keywords -- case normalization (
IF->if,ENDDO->end do) - Continuation lines -- normalized with proportional re-indentation
- Preprocessor -- Fypp (
#:if,#:for), OpenACC (!$acc), OpenMP (!$omp) handled correctly
Configuration
Create ffmt.toml or add [tool.ffmt] to pyproject.toml:
indent-width = 4
keyword-case = "lower" # lower, upper, preserve
normalize-keywords = true # enddo -> end do
[whitespace]
relational = true # ==, /=, <, <=, >, >=
logical = true # .and., .or., .not.
plusminus = true # binary +, -
multdiv = false # *, /
power = false # **
assignment = true # =
declaration = true # ::
comma = true # space after comma
All options have sensible defaults -- most projects need no config file at all.
Preserved as-is
- String literals and inline expressions (
${...}$,@{...}@) - Comment contents and Doxygen alignment (
!<,!>,!!) - Continuation line structure
#ifdef/#endifblocks (no indentation change)
Editor integration
ffmt includes a built-in LSP server for real-time format-on-save:
ffmt --lsp
VS Code
{
"fortran.formatting.formatter": "ffmt",
"fortran.formatting.args": ["--stdin-filepath", "${file}", "-"]
}
Vim/Neovim
autocmd BufWritePost *.fpp,*.f90 silent !ffmt %
" Or: set formatprg=ffmt\ -
Neovim (LSP)
vim.lsp.start({
name = "ffmt",
cmd = { "ffmt", "--lsp" },
root_dir = vim.fs.dirname(vim.fs.find({ "ffmt.toml", "pyproject.toml" }, { upward = true })[1]),
})
CI integration
GitHub Actions
- uses: sbryngelson/ffmt@v0.1.0
with:
args: "--check src/"
pre-commit
repos:
- repo: https://github.com/sbryngelson/ffmt
rev: v0.1.0
hooks:
- id: ffmt
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ffmt-0.1.2.tar.gz.
File metadata
- Download URL: ffmt-0.1.2.tar.gz
- Upload date:
- Size: 39.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
808b62c88c4f3742ab94778e58d6b4ee3bad3e1e548457d3c58c3149d7c57852
|
|
| MD5 |
f6fbd8a6a53d2a580933b8aaa9845de3
|
|
| BLAKE2b-256 |
06d459a801251fe7eec264bde566d942221d3ff681733dac0868d54ca1c460e0
|
Provenance
The following attestation bundles were made for ffmt-0.1.2.tar.gz:
Publisher:
release.yml on sbryngelson/ffmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ffmt-0.1.2.tar.gz -
Subject digest:
808b62c88c4f3742ab94778e58d6b4ee3bad3e1e548457d3c58c3149d7c57852 - Sigstore transparency entry: 1147973963
- Sigstore integration time:
-
Permalink:
sbryngelson/ffmt@8ad4629fbb615838e594af928117ad3a2d17281e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/sbryngelson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8ad4629fbb615838e594af928117ad3a2d17281e -
Trigger Event:
release
-
Statement type:
File details
Details for the file ffmt-0.1.2-py3-none-win_amd64.whl.
File metadata
- Download URL: ffmt-0.1.2-py3-none-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
583a00776ff8da81e16207ea23678da7790ee855b10a0b75dd113d512ce49b74
|
|
| MD5 |
f46505709f0c7966287639addb50f5ba
|
|
| BLAKE2b-256 |
82ce0a65dd26dc29655bb8517053d7ed82d65751c65c27cbe594cca290cdb9ce
|
Provenance
The following attestation bundles were made for ffmt-0.1.2-py3-none-win_amd64.whl:
Publisher:
release.yml on sbryngelson/ffmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ffmt-0.1.2-py3-none-win_amd64.whl -
Subject digest:
583a00776ff8da81e16207ea23678da7790ee855b10a0b75dd113d512ce49b74 - Sigstore transparency entry: 1147973981
- Sigstore integration time:
-
Permalink:
sbryngelson/ffmt@8ad4629fbb615838e594af928117ad3a2d17281e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/sbryngelson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8ad4629fbb615838e594af928117ad3a2d17281e -
Trigger Event:
release
-
Statement type:
File details
Details for the file ffmt-0.1.2-py3-none-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: ffmt-0.1.2-py3-none-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f423c84a26aa95bf468ce1be4d49d2565e64b9590bd8498459f22ef0ae94cc6
|
|
| MD5 |
977eabb4b303d834d55453f0ffc36226
|
|
| BLAKE2b-256 |
da5a258ae5f8ef5308c0e86f91c51c80b7e5c952b003265886e403c45717d538
|
Provenance
The following attestation bundles were made for ffmt-0.1.2-py3-none-manylinux_2_34_x86_64.whl:
Publisher:
release.yml on sbryngelson/ffmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ffmt-0.1.2-py3-none-manylinux_2_34_x86_64.whl -
Subject digest:
9f423c84a26aa95bf468ce1be4d49d2565e64b9590bd8498459f22ef0ae94cc6 - Sigstore transparency entry: 1147974002
- Sigstore integration time:
-
Permalink:
sbryngelson/ffmt@8ad4629fbb615838e594af928117ad3a2d17281e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/sbryngelson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8ad4629fbb615838e594af928117ad3a2d17281e -
Trigger Event:
release
-
Statement type:
File details
Details for the file ffmt-0.1.2-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: ffmt-0.1.2-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.5 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1143a3fcab518bd62b32cd8cccbcbfac0dd7c5028dd86584d918864077c53a3
|
|
| MD5 |
ff601d68ad5f3ab1aa1caf5bec3d9ad6
|
|
| BLAKE2b-256 |
f232d8fbf7313194f1a47a764543eba1be4c745cbff5b781da84ffc7540739c0
|
Provenance
The following attestation bundles were made for ffmt-0.1.2-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on sbryngelson/ffmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ffmt-0.1.2-py3-none-macosx_11_0_arm64.whl -
Subject digest:
e1143a3fcab518bd62b32cd8cccbcbfac0dd7c5028dd86584d918864077c53a3 - Sigstore transparency entry: 1147973969
- Sigstore integration time:
-
Permalink:
sbryngelson/ffmt@8ad4629fbb615838e594af928117ad3a2d17281e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/sbryngelson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8ad4629fbb615838e594af928117ad3a2d17281e -
Trigger Event:
release
-
Statement type: