Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/omnilib/vscode-ufmt
VS Code extension for µfmt
https://github.com/omnilib/vscode-ufmt
black formatter hacktoberfest import python ufmt usort vscode vscode-extension
Last synced: about 2 months ago
JSON representation
VS Code extension for µfmt
- Host: GitHub
- URL: https://github.com/omnilib/vscode-ufmt
- Owner: omnilib
- License: mit
- Created: 2022-08-05T20:28:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-19T18:07:23.000Z (3 months ago)
- Last Synced: 2024-10-20T12:26:15.932Z (2 months ago)
- Topics: black, formatter, hacktoberfest, import, python, ufmt, usort, vscode, vscode-extension
- Language: Python
- Homepage: https://ufmt.omnilib.dev
- Size: 708 KB
- Stars: 5
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
- Support: SUPPORT.md
Awesome Lists containing this project
README
# µfmt: safe, atomic formatting and import sorting
[µfmt][] is a code formatter and import sorter for Python and Visual Studio Code,
built on top of [black][] and [µsort][], with experimental support for [ruff-api][]:> Black makes code review faster by producing the smallest diffs possible.
Blackened code looks the same regardless of the project you’re reading.> μsort is a safe, minimal import sorter. Its primary goal is to make no “dangerous”
changes to code, and to make no changes on code style.µfmt formats files in-memory, first with µsort and then with black, before
writing any changes back to disk. This enables a combined, atomic formatting steps in
VS Code, without any chance of conflict or intermediate changes between the import
sorter and the code formatter.Note:
- This extension requires Python version 3.9 or newer.
- The extension comes bundled with the latest version of µfmt `2.x`, as well
as black, µsort, and ruff-api.## Usage
Once installed, "µfmt" will be available as a formatter for Python files
(extension id: `omnilib.ufmt`).
µfmt can be set as the default formatter by adding the following to your settings:```json
"[python]": {
"editor.defaultFormatter": "omnilib.ufmt"
}
```or through the command pallete option "Format Document With...":
Be sure to disable the legacy Python formatter, if enabled:
```json
"python.formatting.provider": "none"
```## Format on Save
VS Code can automatically format your Python files when saving by adding the following
to your settings:```json
"[python]": {
"editor.defaultFormatter": "omnilib.ufmt",
"editor.formatOnSave": true
}
```## Resources
- [µfmt documentation][µfmt]
- [black documentation][black]
- [µsort documentation][µsort][black]: https://black.rtfd.io
[µsort]: https://usort.rtfd.io
[µfmt]: https://ufmt.omnilib.dev
[ruff-api]: https://pypi.org/project/ruff-api/