File: json_pytool.vim

package info (click to toggle)
vim-ale 4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,764 kB
  • sloc: sh: 499; python: 311; perl: 31; makefile: 4; xml: 4; javascript: 1
file content (20 lines) | stat: -rw-r--r-- 730 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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