Skip to content

Commit f8208e4

Browse files
authored
builtins/formatting: add atlas_fmt (#232)
1 parent caf8556 commit f8208e4

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

doc/BUILTINS.md

+17
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,23 @@ local sources = { null_ls.builtins.formatting.astyle }
19401940
- Command: `astyle`
19411941
- Args: `{ "--quiet" }`
19421942

1943+
### [atlas_fmt](https://atlasgo.io/cli-reference#atlas-schema-fmt)
1944+
1945+
atlas fmt command rewrites `atlas` config and schema files to a canonical format and style.
1946+
1947+
#### Usage
1948+
1949+
```lua
1950+
local sources = { null_ls.builtins.formatting.atlas_fmt }
1951+
```
1952+
1953+
#### Defaults
1954+
1955+
- Filetypes: `{ "hcl", "atlas-config", "atlas-schema-mysql", "atlas-schema-sqlite", "atlas-schema-mariadb", "atlas-schema-redshift", "atlas-schema-clickhouse", "atlas-schema-postgresql", "atlas-schema-mssql", "atlas-plan", "atlas-test"}`
1956+
- Method: `formatting`
1957+
- Command: `atlas`
1958+
- Args: `{ "schema", "fmt", "$FILENAME" }`
1959+
19431960
### [bean_format](https://beancount.github.io/docs/running_beancount_and_generating_reports.html#bean-format)
19441961

19451962
This pure text processing tool will reformat `beancount` input to right-align all the numbers at the same, minimal column.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
local h = require("null-ls.helpers")
2+
local methods = require("null-ls.methods")
3+
4+
local FORMATTING = methods.internal.FORMATTING
5+
6+
return h.make_builtin({
7+
name = "atlas_fmt",
8+
meta = {
9+
url = "https://atlasgo.io/cli-reference#atlas-schema-fmt",
10+
description = "atlas fmt command rewrites `atlas` config and schema files to a canonical format and style.",
11+
},
12+
method = FORMATTING,
13+
filetypes = {
14+
"hcl",
15+
"atlas-config",
16+
"atlas-schema-mysql",
17+
"atlas-schema-sqlite",
18+
"atlas-schema-mariadb",
19+
"atlas-schema-redshift",
20+
"atlas-schema-clickhouse",
21+
"atlas-schema-postgresql",
22+
"atlas-schema-mssql",
23+
"atlas-plan",
24+
"atlas-test",
25+
},
26+
generator_opts = {
27+
command = "atlas",
28+
to_temp_file = true,
29+
from_temp_file = true,
30+
args = {
31+
"schema",
32+
"fmt",
33+
"$FILENAME",
34+
},
35+
},
36+
factory = h.formatter_factory,
37+
})

0 commit comments

Comments
 (0)