vscode-json-languageserver support (#4164)

* vscode-json-languageserver-bin support

VSCode JSON languageserver has schema support for linting and
completions.

I have enabled snippets support (`snippetSupport`) even if it is not
fully supported. `label` that comes with completions response can be
used as well.

* Test fix.

* vscode-json-languageserver instead of vscode-json-languageserver-bin

vscode-json-languageserver is more up-to-date (about 1 year old),
vscode-json-languageserver-bin is 4 years old.

* Use git root.

* Documentation update.

* Trying to sort ordering issue.

* One more attempt

* One more attempt

* Uppercase seems to win.

* Clean-up

* Clean-up 2

* Test removed.
This commit is contained in:
Dalius Dobravolskas 2022-04-30 06:33:48 +03:00 committed by GitHub
parent d484347fb5
commit 34892186e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 2 deletions

View File

@ -0,0 +1,16 @@
" Author: Dalius Dobravolskas <dalius.dobravolskas@gmail.com>
" Description: VSCode json languageserver
function! ale_linters#json#vscodejson#GetProjectRoot(buffer) abort
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
endfunction
call ale#linter#Define('json', {
\ 'name': 'vscodejson',
\ 'lsp': 'stdio',
\ 'executable': 'vscode-json-languageserver',
\ 'command': '%e --stdio',
\ 'project_root': function('ale_linters#json#vscodejson#GetProjectRoot'),
\})

View File

@ -45,7 +45,7 @@ let s:default_ale_linters = {
\ 'hack': ['hack'], \ 'hack': ['hack'],
\ 'help': [], \ 'help': [],
\ 'inko': ['inko'], \ 'inko': ['inko'],
\ 'json': ['jsonlint', 'spectral'], \ 'json': ['jsonlint', 'spectral', 'vscodejson'],
\ 'json5': [], \ 'json5': [],
\ 'jsonc': [], \ 'jsonc': [],
\ 'perl': ['perlcritic'], \ 'perl': ['perlcritic'],

View File

@ -153,6 +153,18 @@ g:ale_json_spectral_use_global *g:ale_json_spectral_use_global*
See |ale-integrations-local-executables| See |ale-integrations-local-executables|
===============================================================================
vscodejson *ale-json-vscode*
Website: https://www.npmjs.com/package/vscode-json-languageserver
Installation
-------------------------------------------------------------------------------
Install VSCode json language server either globally or locally: >
npm install -g vscode-json-languageserver
<
=============================================================================== ===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -283,6 +283,7 @@ Notes:
* `tsserver` * `tsserver`
* `xo` * `xo`
* JSON * JSON
* `VSCode JSON language server`
* `cspell` * `cspell`
* `dprint` * `dprint`
* `eslint` * `eslint`

View File

@ -1613,6 +1613,7 @@ g:ale_linters *g:ale_linters*
\ 'help': [], \ 'help': [],
\ 'inko': ['inko'], \ 'inko': ['inko'],
\ 'json': ['jsonlint', 'spectral'], \ 'json': ['jsonlint', 'spectral'],
\ 'json': ['jsonlint', 'spectral', 'vscodejson'],
\ 'json5': [], \ 'json5': [],
\ 'jsonc': [], \ 'jsonc': [],
\ 'perl': ['perlcritic'], \ 'perl': ['perlcritic'],
@ -2961,6 +2962,7 @@ documented in additional help files.
jq....................................|ale-json-jq| jq....................................|ale-json-jq|
prettier..............................|ale-json-prettier| prettier..............................|ale-json-prettier|
spectral..............................|ale-json-spectral| spectral..............................|ale-json-spectral|
vscodejson............................|ale-json-vscode|
jsonc...................................|ale-jsonc-options| jsonc...................................|ale-jsonc-options|
eslint................................|ale-jsonc-eslint| eslint................................|ale-jsonc-eslint|
jsonnet.................................|ale-jsonnet-options| jsonnet.................................|ale-jsonnet-options|

View File

@ -292,6 +292,7 @@ formatting.
* [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29) * [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29)
* [xo](https://github.com/sindresorhus/xo) * [xo](https://github.com/sindresorhus/xo)
* JSON * JSON
* [VSCode JSON language server](https://www.npmjs.com/package/vscode-json-languageserver)
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) :warning: * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) :warning:
* [dprint](https://dprint.dev) * [dprint](https://dprint.dev)
* [eslint](http://eslint.org/) :warning: * [eslint](http://eslint.org/) :warning:

View File

@ -60,7 +60,7 @@ Execute(The defaults for the inko filetype should be correct):
AssertEqual [], GetLinterNames('inko') AssertEqual [], GetLinterNames('inko')
Execute(The defaults for the json filetype should be correct): Execute(The defaults for the json filetype should be correct):
AssertEqual ['jsonlint', 'spectral'], GetLinterNames('json') AssertEqual ['jsonlint', 'spectral', 'vscodejson'], GetLinterNames('json')
let g:ale_linters_explicit = 1 let g:ale_linters_explicit = 1