A fast, configurable Fortran formatter with Fypp, Doxygen, and OpenACC/OpenMP support
Project description
ffmt
A fast, configurable Fortran formatter with support for Fypp, Doxygen, and OpenACC/OpenMP directives. 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
line-length = 132
keyword-case = "lower" # lower, upper, preserve
normalize-keywords = true # enddo -> end do
named-ends = true # end subroutine -> end subroutine s_foo
align-declarations = true # align :: in consecutive declarations
unicode-to-ascii = true # Greek/math symbols -> LaTeX in comments
rewrap-comments = true # wrap long comments at line-length
rewrap-code = true # wrap long code lines at line-length
space-after-comment = true # !comment -> ! comment
collapse-double-spaces = true # x = y -> x = y
keyword-paren-space = true # if( -> if (
fypp-list-commas = true # normalize commas in Fypp '[...]' args
[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
Other Fortran Formatters
| Formatter | Language | Status | Notes |
|---|---|---|---|
| fprettify | Python | Unmaintained (last release 2020) | Free-form only. Fypp support. Requires multiple passes for convergence. |
| findent | C | Active | Indentation and fixed/free conversion. No whitespace normalization. |
| Codee Formatter | Proprietary | Active | Commercial. Tree-sitter based. Fixed and free-form. |
| LFortran fmt | Rust | In development | AST-based. Part of the LFortran compiler project. |
| Fortitude | Rust | Active | Linter with auto-fix, not a full formatter. Tree-sitter based. |
| f90-mode | Emacs Lisp | Active | Emacs built-in. Indentation only. |
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.2.1.tar.gz.
File metadata
- Download URL: ffmt-0.2.1.tar.gz
- Upload date:
- Size: 52.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b85e688a4eb97c53637b082006fa9fbeffb1ed6d0d8886c70eacaec75e76d70e
|
|
| MD5 |
5e059d0ea1cb7e72e1240ff74663ee3d
|
|
| BLAKE2b-256 |
71f04c860644a47eb0f5c26164a81acef8df0f90cbed085425f4803717d7a5f2
|
Provenance
The following attestation bundles were made for ffmt-0.2.1.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.2.1.tar.gz -
Subject digest:
b85e688a4eb97c53637b082006fa9fbeffb1ed6d0d8886c70eacaec75e76d70e - Sigstore transparency entry: 1153200939
- Sigstore integration time:
-
Permalink:
sbryngelson/ffmt@18e3d9455e6423600d77fe9ba13e82e86285a034 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/sbryngelson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@18e3d9455e6423600d77fe9ba13e82e86285a034 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ffmt-0.2.1-py3-none-win_amd64.whl.
File metadata
- Download URL: ffmt-0.2.1-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 |
bdc9e4adf87f2148af09c545684a5a3d4bfcc8189495f281010246bc426429f1
|
|
| MD5 |
556e0f0b112fcd9d98ab4bd4618aed8c
|
|
| BLAKE2b-256 |
c6db19cad03365e8e172bd32410f322526fec101871dc8fa412e2b6311dd14e9
|
Provenance
The following attestation bundles were made for ffmt-0.2.1-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.2.1-py3-none-win_amd64.whl -
Subject digest:
bdc9e4adf87f2148af09c545684a5a3d4bfcc8189495f281010246bc426429f1 - Sigstore transparency entry: 1153201088
- Sigstore integration time:
-
Permalink:
sbryngelson/ffmt@18e3d9455e6423600d77fe9ba13e82e86285a034 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/sbryngelson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@18e3d9455e6423600d77fe9ba13e82e86285a034 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ffmt-0.2.1-py3-none-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: ffmt-0.2.1-py3-none-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.8 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 |
589bbac44526efdf8933d9ab926538029b716d8781485587aa8a35f8103ecd0c
|
|
| MD5 |
33eb26b268f2bd00db11a550ddb35a6a
|
|
| BLAKE2b-256 |
4bddc3b6b2bd7d610474b49c21477ecbfb864dd6887eadf396dc71674dd6c91a
|
Provenance
The following attestation bundles were made for ffmt-0.2.1-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.2.1-py3-none-manylinux_2_34_x86_64.whl -
Subject digest:
589bbac44526efdf8933d9ab926538029b716d8781485587aa8a35f8103ecd0c - Sigstore transparency entry: 1153201014
- Sigstore integration time:
-
Permalink:
sbryngelson/ffmt@18e3d9455e6423600d77fe9ba13e82e86285a034 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/sbryngelson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@18e3d9455e6423600d77fe9ba13e82e86285a034 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ffmt-0.2.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: ffmt-0.2.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.6 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 |
35da0cc6ebad6ab136a22c25e2d785c79c0f6e3244e1fa1d1d06d26b6d6ad3f6
|
|
| MD5 |
57e93714e23515cd3c38e1317f961fa5
|
|
| BLAKE2b-256 |
a430c79592d7106f0a6b79c05600733d89d4098f11f009c0d53e7e548e4cdd6e
|
Provenance
The following attestation bundles were made for ffmt-0.2.1-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.2.1-py3-none-macosx_11_0_arm64.whl -
Subject digest:
35da0cc6ebad6ab136a22c25e2d785c79c0f6e3244e1fa1d1d06d26b6d6ad3f6 - Sigstore transparency entry: 1153201172
- Sigstore integration time:
-
Permalink:
sbryngelson/ffmt@18e3d9455e6423600d77fe9ba13e82e86285a034 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/sbryngelson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@18e3d9455e6423600d77fe9ba13e82e86285a034 -
Trigger Event:
release
-
Statement type: