diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 5bda9d56..6a3c3ce1 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- emacs_version: [27, 28, "master"]
+ emacs_version: [27, 28, 29]
steps:
- name: Checkout
uses: actions/checkout@v4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 36eade64..ad15520b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,12 +15,11 @@ The format is based on [Keep a Changelog].
* Disable formatting of go module files with gofmt. This was never supported
([#214]).
* Remove support for Emacs 26 ([#215]).
-
-### Features
-* New user option `apheleia-formatters-respect-indent-level`,
- defaulting to `t`. You can set this to `nil` to disable Apheleia
- configuring formatters to use the same indent settings as the Emacs
- major mode is using ([#208]).
+* Emacs will infer indentation configuration from your major mode and,
+ by default, supply this configuration to formatters, to ensure
+ consistency between how you have Emacs configured and how your
+ formatter is configured. You can disable this by setting
+ `apheleia-formatters-respect-indent-level` to nil ([#167], [#208]).
### Enhancements
* Use the `prettier-json` formatter for `js-json-mode` ([#209]).
@@ -64,13 +63,6 @@ The format is based on [Keep a Changelog].
### Formatters
-* [`xmllint`](https://gitlab.gnome.org/GNOME/libxml2) for XML ([#251]).
-* [purs-tidy](https://github.com/natefaubion/purescript-tidy) for PureScript ([#182]).
-* [`jq`](https://stedolan.github.io/jq/) for
- [JSON](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON)
- ([#174]).
-* [`gawk`](https://www.gnu.org/software/gawk/) for
- [awk](https://en.wikipedia.org/wiki/AWK) ([#187]).
* [`asmfmt`](https://github.com/klauspost/asmfmt) for assembly ([#168]).
* [`astyle`](https://github.com/steinwurf/astyle) for C ([#169]).
* [`beautysh`](https://github.com/lovesegfault/beautysh) for shell
@@ -80,10 +72,17 @@ The format is based on [Keep a Changelog].
* [`cmake-format`](https://github.com/cheshirekow/cmake_format)
for [CMake](https://cmake.org/) ([#172]).
* [`fourmolu`](https://github.com/fourmolu/fourmolu) for haskell
+* [`gawk`](https://www.gnu.org/software/gawk/) for
+ [awk](https://en.wikipedia.org/wiki/AWK) ([#187]).
+* [`hclfmt`](https://github.com/hashicorp/hcl/tree/main/cmd/hclfmt) for [HCL](https://github.com/hashicorp/hcl) ([#231])
* [`html-tidy`](https://www.html-tidy.org/) for HTML/XML ([#173]).
+* [`jq`](https://stedolan.github.io/jq/) for
+ [JSON](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON)
+ ([#174]).
* [`ormolu`](https://github.com/tweag/ormolu) for haskell.
* [`perltidy`](https://perltidy.sourceforge.net/) for
[perl](https://www.perl.org/) ([#175]).
+* [purs-tidy](https://github.com/natefaubion/purescript-tidy) for PureScript ([#182]).
* [`rubocop`](https://github.com/rubocop/rubocop) for [ruby](https://www.ruby-lang.org/en/) ([#176]).
* [`ruby-standard`](https://github.com/standardrb/standard) for
[ruby](https://www.ruby-lang.org/en/) ([#201])
@@ -91,9 +90,11 @@ The format is based on [Keep a Changelog].
[python](https://python.org) ([#236])
* [`rufo`](https://github.com/ruby-formatter/rufo) for
[Ruby](https://www.ruby-lang.org/en/) ([#177]).
+* [`xmllint`](https://gitlab.gnome.org/GNOME/libxml2) for XML ([#251]).
* [`yapf`](https://github.com/google/yapf) for [Python](https://www.python.org/) ([#196])
-* [`hclfmt`](https://github.com/hashicorp/hcl/tree/main/cmd/hclfmt) for [HCL](https://github.com/hashicorp/hcl) ([#231])
+* [`yq`](https://mikefarah.gitbook.io/yq/) for YAML, JSON, CSV, TSV, XML and [.properties](https://en.wikipedia.org/wiki/.properties) ([#250]).
+[#167]: https://github.com/radian-software/apheleia/pull/167
[#168]: https://github.com/radian-software/apheleia/pull/168
[#169]: https://github.com/radian-software/apheleia/pull/169
[#170]: https://github.com/radian-software/apheleia/pull/170
diff --git a/apheleia-formatters.el b/apheleia-formatters.el
index d222d7ae..d75eb15c 100644
--- a/apheleia-formatters.el
+++ b/apheleia-formatters.el
@@ -150,7 +150,19 @@
(rustfmt . ("rustfmt" "--quiet" "--emit" "stdout"))
(terraform . ("terraform" "fmt" "-"))
(xmllint . ("xmllint" "--format" "-"))
- (yapf . ("yapf")))
+ (yapf . ("yapf"))
+ (yq-csv . ("yq" "--prettyPrint" "--no-colors"
+ "--input-format" "csv" "--output-format" "csv"))
+ (yq-json . ("yq" "--prettyPrint" "--no-colors"
+ "--input-format" "json" "--output-format" "json"))
+ (yq-properties . ("yq" "--prettyPrint" "--no-colors"
+ "--input-format" "props" "--output-format" "props"))
+ (yq-tsv . ("yq" "--prettyPrint" "--no-colors"
+ "--input-format" "tsv" "--output-format" "tsv"))
+ (yq-xml . ("yq" "--prettyPrint" "--no-colors"
+ "--input-format" "xml" "--output-format" "xml"))
+ (yq-yaml . ("yq" "--prettyPrint" "--no-colors" "--no-doc"
+ "--input-format" "yaml" "--output-format" "yaml")))
"Alist of code formatting commands.
The keys may be any symbols you want, and the values are shell
commands, lists of strings and symbols, or a function symbol.
diff --git a/apheleia-utils.el b/apheleia-utils.el
index 9407cd2f..7ca30bb1 100644
--- a/apheleia-utils.el
+++ b/apheleia-utils.el
@@ -45,9 +45,13 @@ INDENT-FLAG."
(json-ts-mode 'json-ts-mode-indent-offset)
(js-mode 'js-indent-level)
(js-jsx-mode 'js-indent-level)
+ (js-ts-mode 'js-indent-level)
(js2-mode 'js2-basic-offset)
(js2-jsx-mode 'js2-basic-offset)
- (js3-mode 'js3-indent-level))))
+ (js3-mode 'js3-indent-level)
+ (tsx-ts-mode 'typescript-ts-mode-indent-offset)
+ (typescript-mode 'typescript-indent-level)
+ (typescript-ts-mode 'typescript-ts-mode-indent-offset))))
(defcustom apheleia-formatters-respect-fill-column nil
"Whether formatters should set `fill-column' related flags."
diff --git a/test/formatters/installers/yq-csv.bash b/test/formatters/installers/yq-csv.bash
new file mode 120000
index 00000000..9316c89d
--- /dev/null
+++ b/test/formatters/installers/yq-csv.bash
@@ -0,0 +1 @@
+yq-yaml.bash
\ No newline at end of file
diff --git a/test/formatters/installers/yq-json.bash b/test/formatters/installers/yq-json.bash
new file mode 120000
index 00000000..9316c89d
--- /dev/null
+++ b/test/formatters/installers/yq-json.bash
@@ -0,0 +1 @@
+yq-yaml.bash
\ No newline at end of file
diff --git a/test/formatters/installers/yq-properties.bash b/test/formatters/installers/yq-properties.bash
new file mode 120000
index 00000000..9316c89d
--- /dev/null
+++ b/test/formatters/installers/yq-properties.bash
@@ -0,0 +1 @@
+yq-yaml.bash
\ No newline at end of file
diff --git a/test/formatters/installers/yq-tsv.bash b/test/formatters/installers/yq-tsv.bash
new file mode 120000
index 00000000..9316c89d
--- /dev/null
+++ b/test/formatters/installers/yq-tsv.bash
@@ -0,0 +1 @@
+yq-yaml.bash
\ No newline at end of file
diff --git a/test/formatters/installers/yq-xml.bash b/test/formatters/installers/yq-xml.bash
new file mode 120000
index 00000000..9316c89d
--- /dev/null
+++ b/test/formatters/installers/yq-xml.bash
@@ -0,0 +1 @@
+yq-yaml.bash
\ No newline at end of file
diff --git a/test/formatters/installers/yq-yaml.bash b/test/formatters/installers/yq-yaml.bash
new file mode 100644
index 00000000..0f368497
--- /dev/null
+++ b/test/formatters/installers/yq-yaml.bash
@@ -0,0 +1 @@
+curl -fsSLo /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 && chmod +x /usr/local/bin/yq
diff --git a/test/formatters/samplecode/yq-csv/in.csv b/test/formatters/samplecode/yq-csv/in.csv
new file mode 100644
index 00000000..81a3661f
--- /dev/null
+++ b/test/formatters/samplecode/yq-csv/in.csv
@@ -0,0 +1,2 @@
+hello,"world"
+a,"1,2"
diff --git a/test/formatters/samplecode/yq-csv/out.csv b/test/formatters/samplecode/yq-csv/out.csv
new file mode 100644
index 00000000..99162393
--- /dev/null
+++ b/test/formatters/samplecode/yq-csv/out.csv
@@ -0,0 +1,2 @@
+hello,world
+a,"1,2"
diff --git a/test/formatters/samplecode/yq-json/in.json b/test/formatters/samplecode/yq-json/in.json
new file mode 120000
index 00000000..599a1e23
--- /dev/null
+++ b/test/formatters/samplecode/yq-json/in.json
@@ -0,0 +1 @@
+../prettier-json/in.json
\ No newline at end of file
diff --git a/test/formatters/samplecode/yq-json/out.json b/test/formatters/samplecode/yq-json/out.json
new file mode 100644
index 00000000..59bb3b44
--- /dev/null
+++ b/test/formatters/samplecode/yq-json/out.json
@@ -0,0 +1,19 @@
+{
+ "arrowParens": "always",
+ "bracketSpacing": true,
+ "embeddedLanguageFormatting": "auto",
+ "htmlWhitespaceSensitivity": "css",
+ "insertPragma": false,
+ "jsxBracketSameLine": false,
+ "jsxSingleQuote": false,
+ "printWidth": 80,
+ "proseWrap": "preserve",
+ "quoteProps": "as-needed",
+ "requirePragma": false,
+ "semi": true,
+ "singleQuote": false,
+ "tabWidth": 2,
+ "trailingComma": "es5",
+ "useTabs": false,
+ "vueIndentScriptAndStyle": false
+}
diff --git a/test/formatters/samplecode/yq-properties/in.properties b/test/formatters/samplecode/yq-properties/in.properties
new file mode 100644
index 00000000..74d0a43f
--- /dev/null
+++ b/test/formatters/samplecode/yq-properties/in.properties
@@ -0,0 +1 @@
+foo=bar
diff --git a/test/formatters/samplecode/yq-properties/out.properties b/test/formatters/samplecode/yq-properties/out.properties
new file mode 100644
index 00000000..d5dd18c1
--- /dev/null
+++ b/test/formatters/samplecode/yq-properties/out.properties
@@ -0,0 +1 @@
+foo = bar
diff --git a/test/formatters/samplecode/yq-tsv/in.tsv b/test/formatters/samplecode/yq-tsv/in.tsv
new file mode 100644
index 00000000..c659c726
--- /dev/null
+++ b/test/formatters/samplecode/yq-tsv/in.tsv
@@ -0,0 +1,2 @@
+hello "world"
+a "1 2"
diff --git a/test/formatters/samplecode/yq-tsv/out.tsv b/test/formatters/samplecode/yq-tsv/out.tsv
new file mode 100644
index 00000000..6acb9d1b
--- /dev/null
+++ b/test/formatters/samplecode/yq-tsv/out.tsv
@@ -0,0 +1,2 @@
+hello world
+a "1 2"
diff --git a/test/formatters/samplecode/yq-xml/in.xml b/test/formatters/samplecode/yq-xml/in.xml
new file mode 100644
index 00000000..3338af29
--- /dev/null
+++ b/test/formatters/samplecode/yq-xml/in.xml
@@ -0,0 +1 @@
+
diff --git a/test/formatters/samplecode/yq-xml/out.xml b/test/formatters/samplecode/yq-xml/out.xml
new file mode 100644
index 00000000..b4e8ae3e
--- /dev/null
+++ b/test/formatters/samplecode/yq-xml/out.xml
@@ -0,0 +1 @@
+
diff --git a/test/formatters/samplecode/yq-yaml/in.yml b/test/formatters/samplecode/yq-yaml/in.yml
new file mode 120000
index 00000000..bdbc9aaf
--- /dev/null
+++ b/test/formatters/samplecode/yq-yaml/in.yml
@@ -0,0 +1 @@
+../prettier-yaml/in.yml
\ No newline at end of file
diff --git a/test/formatters/samplecode/yq-yaml/out.yml b/test/formatters/samplecode/yq-yaml/out.yml
new file mode 100644
index 00000000..8b4f56dc
--- /dev/null
+++ b/test/formatters/samplecode/yq-yaml/out.yml
@@ -0,0 +1,7 @@
+- hosts: all
+ tasks:
+ - name: Get software for apt repository management.
+ apt:
+ state: present
+ name:
+ - python3-pycurl