Skip to main content

A fast, configurable Fortran formatter

Project description

ffmt

PyPI CI License: MIT GitHub Marketplace

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/#endif blocks (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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ffmt-0.1.3.tar.gz (39.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ffmt-0.1.3-py3-none-win_amd64.whl (1.4 MB view details)

Uploaded Python 3Windows x86-64

ffmt-0.1.3-py3-none-manylinux_2_34_x86_64.whl (1.7 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

ffmt-0.1.3-py3-none-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file ffmt-0.1.3.tar.gz.

File metadata

  • Download URL: ffmt-0.1.3.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ffmt-0.1.3.tar.gz
Algorithm Hash digest
SHA256 24ae2e360ace82e7ded52b5777ad0cc510022e23961851c10670a90ea36617d4
MD5 a77816d19463ee27261139fe0558d481
BLAKE2b-256 f13bdee6c41d94d6c753d1993bea2df256609d104bb47a4142e4024e3dbe2274

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffmt-0.1.3.tar.gz:

Publisher: release.yml on sbryngelson/ffmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ffmt-0.1.3-py3-none-win_amd64.whl.

File metadata

  • Download URL: ffmt-0.1.3-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

Hashes for ffmt-0.1.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 d8412ede1648388fa88e492cfc6a094d43a15d985f892ef009fbd20675f76057
MD5 4b05d2d5c7e4f7e307095ac87c4b370c
BLAKE2b-256 40890d3024188fc22206b89fc9c3eda94fa1874471a88f218acda20718f6ac3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffmt-0.1.3-py3-none-win_amd64.whl:

Publisher: release.yml on sbryngelson/ffmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ffmt-0.1.3-py3-none-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: ffmt-0.1.3-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

Hashes for ffmt-0.1.3-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8c5c0dea990cc9621c32cecb23cf424a91bf54550fa3c560189849a28821f4e5
MD5 cdfe718fbb4d0919d82d5a14a172c050
BLAKE2b-256 02d75cae199b00056e50c49e2745f3323d21af4421c764d46ad51ed26ec7b459

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffmt-0.1.3-py3-none-manylinux_2_34_x86_64.whl:

Publisher: release.yml on sbryngelson/ffmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ffmt-0.1.3-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: ffmt-0.1.3-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

Hashes for ffmt-0.1.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 be59b5ce35732aee2d041766c6bc155c40b4228e3832310d364442b22f3b4cbb
MD5 d403be50471fb8ad5397876ba711cc8c
BLAKE2b-256 0a68daa4ad6177958387b773ffacc1b5eebc40799f7e2cc37aa7a076b4bb71d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffmt-0.1.3-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on sbryngelson/ffmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page