百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

treefmt

> 数据库
开源

格式化器多路复用器 [维护者=@zimbatm,@brianmcgee]

1.0K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

格式化器多路复用器 [维护者=@zimbatm,@brianmcgee]

treefmt streamlines the process of applying formatters to your project, making it a breeze with just one command line.

Motivation

Modern code repositories are rarely written in a single language. They often contain a mix of languages, each with its own formatting requirements.

While working for our customers, we noticed that projects each tended to re-implement the same formatter multiplexing logic. A script that invokes all the formatters.

What if that script was a single command?

What if that single command would handle all the formatters in parallel? And only format files that have changed since the previous run?

That's what treefmt is about.

About treefmt

treefmt runs all your formatters with one command. It’s easy to configure and fast to execute.

Its main features are:

  • Providing a unified CLI and output
    • You don’t need to remember which formatters are necessary for each project.
    • Once you specify the formatters in the config file, you can trigger all of them with one command and get a standardized output.
  • Running all the formatters in parallel
    • A standard script loops over your folders and runs each formatter sequentially.
    • In contrast, treefmt runs formatters in parallel. This way, the formatting job takes less time.
  • Tracking file changes
    • When formatters are run in a script, they process all the files they encounter, regardless of whether or not they have changed.
    • treefmt tracks file changes, and only attempts to format files which have changed.

To reformat the whole source tree, just type treefmt in any folder. This is a fast and simple formatting solution.

Installation

You can install treefmt by downloading the binary. Find the binaries for different architectures here. Otherwise, you can install the package from source code — either with Go, or with the help of nix.

We describe the installation process in detail in the docs.

Usage

In order to use treefmt in your project, make sure the config file treefmt.toml is present in the root folder and is edited to suit your needs.

You can generate it with:

$ treefmt --init

You can then run treefmt in your project root folder like this:

$ treefmt

To explore the tool’s flags and options, type:

$ treefmt --help

Additionally, there's a wrapper called treefmt-nix for using treefmt with nix.

Configuration

Formatters are specified in the config file treefmt.toml, which is usually located in the project root folder. The generic way to specify a formatter is like this:

[formatter.]
command = ""
options = [""...]
includes = [""]

For example, if you want to use nixpkgs-fmt on your Nix project and rustfmt on your Rust project, then treefmt.toml will look as follows:

[formatter.nix]
command = "nixpkgs-fmt"
includes = ["*.nix"]

[formatter.rust]
command = "rustfmt"
options = ["--edition", "2018"]
includes = ["*.rs"]

Before specifying the formatter in the config, make sure it’s installed.

To find and share existing formatter recipes, take a look at the docs.

If you are a Nix user, you might also be interested in treefmt-nix to use Nix to configure and bring in formatters.

Compatibility

treefmt works with any formatter that adheres to the following specification.

For instance, you can go for:

  • clang-format for C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C#
  • gofmt for Golang
  • Prettier for JavaScript/HTML/CSS

You can find information on supported formatters here.

IDE Integration

treefmt currently has support for vscode via an extension:

  • treefmt-vscode | GitHub repo

Upcoming features

This project is still pretty new. Down the line we also want to add support for:

  • More IDE integration
  • Pre-commit hooks

Related projects

  • EditorConfig: unifies file indentations configuration on a per-project basis.
  • prettier: an opinionated code formatter for a number of languages.
  • Super-Linter: a project by GitHub to lint all of your code.
  • pre-commit: a framework for managing and maintaining multi-language pre-commit hooks.

Contributing

All contributions are welcome! We try to keep the project simple and focused. Please refer to the Contributing guidelines for more information.

Commercial support

Looking for help or customization?

Get in touch with Numtide to get a quote. We make it easy for companies to work with Open Source projects:

License

Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion will be licensed under the MIT license without any additional terms or conditions.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gobuildbot-numtidecliformattertreefmt

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库