forked from dense-analysis/ale
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fixer for json: python's json.tool
Resolves dense-analysis#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.
- Loading branch information
Showing
5 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
" Author: idbrii | ||
" Description: json formatter as ALE fixer using python's json.tool | ||
|
||
call ale#Set('json_pytool_executable', 'python') | ||
call ale#Set('json_pytool_options', '') | ||
call ale#Set('json_pytool_use_global', get(g:, 'ale_use_global_executables', 0)) | ||
|
||
function! ale#fixers#json_pytool#GetExecutable(buffer) abort | ||
return ale#path#FindExecutable(a:buffer, 'json_pytool', ['python']) | ||
endfunction | ||
|
||
function! ale#fixers#json_pytool#Fix(buffer) abort | ||
let l:executable = ale#Escape(ale#fixers#json_pytool#GetExecutable(a:buffer)) | ||
let l:opts = ale#Var(a:buffer, 'json_pytool_options') | ||
let l:command = printf('%s -m json.tool %s -', l:executable, l:opts) | ||
|
||
return { | ||
\ 'command': l:command | ||
\ } | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,6 +317,7 @@ Notes: | |
* `eslint` | ||
* `fixjson` | ||
* `jq` | ||
* `json.tool` | ||
* `jsonlint` | ||
* `prettier` | ||
* `spectral` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters