Add fixer for json: python's json.tool (#4847)

Resolves #4314.

Add a fixer that's built into python for json formatting. Include a
couple arguments in docs to make these features more discoverable.

Uses stdin-based fixing so you don't need to save the file to fix.
This commit is contained in:
David Briscoe
2025-02-23 18:30:43 -08:00
committed by GitHub
parent 699c0dbe80
commit d38a3f7739
6 changed files with 62 additions and 0 deletions

View File

@@ -83,6 +83,40 @@ g:ale_json_fixjson_use_global *g:ale_json_fixjson_use_global*
See |ale-integrations-local-executables|
===============================================================================
pytool *ale-json-pytool*
Use python's json.tool module to reformat json.
g:ale_json_pytool_executable *g:ale_json_pytool_executable*
*b:ale_json_pytool_executable*
Type: |String|
Default: `'python'`
The python executable that run to use its json.tool module. This fixer
requires python 3, which includes the json module.
g:ale_json_pytool_options *g:ale_json_pytool_options*
*b:ale_json_pytool_options*
Type: |String|
Default: `''`
These options are passed to the json.tool module. Example: >
let g:ale_json_pytool_options = '--sort-keys --indent 2'
< See docs for all options:
https://docs.python.org/3/library/json.html#module-json.tool
g:ale_json_pytool_use_global *g:ale_json_pytool_use_global*
*b:ale_json_pytool_use_global*
Type: |Number|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
jsonlint *ale-json-jsonlint*

View File

@@ -329,6 +329,7 @@ Notes:
* `eslint`
* `fixjson`
* `jq`
* `json.tool`
* `jsonlint`
* `prettier`
* `spectral`

View File

@@ -3159,6 +3159,7 @@ documented in additional help files.
dprint................................|ale-json-dprint|
eslint................................|ale-json-eslint|
fixjson...............................|ale-json-fixjson|
pytool................................|ale-json-pytool|
jsonlint..............................|ale-json-jsonlint|
jq....................................|ale-json-jq|
prettier..............................|ale-json-prettier|