Skip to content

Commit

Permalink
Merge branch 'main' into feat/xmllint
Browse files Browse the repository at this point in the history
  • Loading branch information
raxod502 committed Nov 23, 2023
2 parents 9bb0537 + 317fe75 commit 5904809
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 15 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]).
Expand Down Expand Up @@ -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
Expand All @@ -80,20 +72,29 @@ 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])
* [`ruff`](https://github.com/astral-sh/ruff) for
[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
Expand Down
14 changes: 13 additions & 1 deletion apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion apheleia-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
1 change: 1 addition & 0 deletions test/formatters/installers/yq-csv.bash
1 change: 1 addition & 0 deletions test/formatters/installers/yq-json.bash
1 change: 1 addition & 0 deletions test/formatters/installers/yq-properties.bash
1 change: 1 addition & 0 deletions test/formatters/installers/yq-tsv.bash
1 change: 1 addition & 0 deletions test/formatters/installers/yq-xml.bash
1 change: 1 addition & 0 deletions test/formatters/installers/yq-yaml.bash
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions test/formatters/samplecode/yq-csv/in.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello,"world"
a,"1,2"
2 changes: 2 additions & 0 deletions test/formatters/samplecode/yq-csv/out.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello,world
a,"1,2"
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-json/in.json
19 changes: 19 additions & 0 deletions test/formatters/samplecode/yq-json/out.json
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-properties/in.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo=bar
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-properties/out.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo = bar
2 changes: 2 additions & 0 deletions test/formatters/samplecode/yq-tsv/in.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello "world"
a "1 2"
2 changes: 2 additions & 0 deletions test/formatters/samplecode/yq-tsv/out.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello world
a "1 2"
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-xml/in.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<hello who='world' />
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-xml/out.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<hello who="world"></hello>
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-yaml/in.yml
7 changes: 7 additions & 0 deletions test/formatters/samplecode/yq-yaml/out.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- hosts: all
tasks:
- name: Get software for apt repository management.
apt:
state: present
name:
- python3-pycurl

0 comments on commit 5904809

Please sign in to comment.