Skip to content

Commit

Permalink
support jsonlint local executable
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsierraintegro committed Mar 15, 2019
1 parent 80ef7ea commit 6e7f04a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
23 changes: 20 additions & 3 deletions ale_linters/json/jsonlint.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
" Author: KabbAmine <amine.kabb@gmail.com>
" Author: KabbAmine <amine.kabb@gmail.com>, David Sierra <https://github.com/davidsierradz>

call ale#Set('json_jsonlint_executable', 'jsonlint')
call ale#Set('json_jsonlint_use_global', get(g:, 'ale_use_global_executables', 0))

function! ale_linters#json#jsonlint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'json_jsonlint', [
\ 'node_modules/.bin/jsonlint',
\ 'node_modules/jsonlint/lib/cli.js',
\])
endfunction

function! ale_linters#json#jsonlint#GetCommand(buffer) abort
let l:executable = ale_linters#json#jsonlint#GetExecutable(a:buffer)

return ale#node#Executable(a:buffer, l:executable)
\ . ' --compact -'
endfunction

function! ale_linters#json#jsonlint#Handle(buffer, lines) abort
" Matches patterns like the following:
Expand All @@ -19,8 +36,8 @@ endfunction

call ale#linter#Define('json', {
\ 'name': 'jsonlint',
\ 'executable': 'jsonlint',
\ 'executable': function('ale_linters#json#jsonlint#GetExecutable'),
\ 'output_stream': 'stderr',
\ 'command': 'jsonlint --compact -',
\ 'command': function('ale_linters#json#jsonlint#GetCommand'),
\ 'callback': 'ale_linters#json#jsonlint#Handle',
\})
16 changes: 15 additions & 1 deletion doc/ale-json.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,21 @@ g:ale_json_fixjson_use_global *g:ale_json_fixjson_use_global*
===============================================================================
jsonlint *ale-json-jsonlint*

There are no options available.
g:ale_json_jsonlint_executable *g:ale_json_jsonlint_executable*
*b:ale_json_jsonlint_executable*

Type: |String|
Default: `'jsonlint'`

The executable that will be run for jsonlint.

g:ale_json_jsonlint_use_global *g:ale_json_jsonlint_use_global*
*b:ale_json_jsonlint_use_global*

Type: |Number|
Default: `get(g:, 'ale_use_global_executables', 0)`

See |ale-integrations-local-executables|


===============================================================================
Expand Down

0 comments on commit 6e7f04a

Please sign in to comment.