Skip to content

Commit 4bb461b

Browse files
FLchsstevearc
andauthored
feat: add Oxfmt (#818)
* feat: add Oxfmt * docs: Add reference to Oxfmt in readme * fix: cwd detection without cwd detection configuration files would be ignored in subdirectories * doc: simplify description of Oxfmt --------- Co-authored-by: Steven Arcangeli <[email protected]>
1 parent ffe26e8 commit 4bb461b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ You can view this list in vim with `:help conform-formatters`
327327
- [odinfmt](https://github.com/DanielGavin/ols) - Auto-formatter for the Odin programming language.
328328
- [opa_fmt](https://www.openpolicyagent.org/docs/latest/cli/#opa-fmt) - Format Rego files using `opa fmt` command.
329329
- [ormolu](https://hackage.haskell.org/package/ormolu) - A formatter for Haskell source code.
330+
- [oxfmt](https://github.com/oxc-project/oxc) - Prettier-compatible code formatter.
330331
- [packer_fmt](https://developer.hashicorp.com/packer/docs/commands/fmt) - The packer fmt Packer command is used to format HCL2 configuration files to a canonical format and style.
331332
- [pangu](https://github.com/vinta/pangu.py) - Insert whitespace between CJK and half-width characters.
332333
- [perlimports](https://github.com/perl-ide/App-perlimports) - Make implicit Perl imports explicit.

lua/conform/formatters/oxfmt.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
local util = require("conform.util")
2+
3+
local config_file_names = {
4+
-- https://oxc.rs/docs/guide/usage/formatter.html#configuration-file
5+
".oxfmtrc.json",
6+
".oxfmtrc.jsonc",
7+
}
8+
9+
---@type conform.FileFormatterConfig
10+
return {
11+
meta = {
12+
url = "https://github.com/oxc-project/oxc",
13+
description = "A Prettier-compatible code formatter.",
14+
},
15+
command = util.from_node_modules("oxfmt"),
16+
args = { "$FILENAME" },
17+
stdin = false,
18+
cwd = require("conform.util").root_file(config_file_names),
19+
}

0 commit comments

Comments
 (0)