summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalius Dobravolskas <dalius.dobravolskas@gmail.com>2022-04-30 06:33:48 +0300
committerGitHub <noreply@github.com>2022-04-30 12:33:48 +0900
commit34892186e44b21356c84e1c2e019f96a304c3edc (patch)
treefe6b13f579b58b7a56f0b0e7ae204c1ce101588f
parentd484347fb5f63cd5d4d4da7bf1ba4fc197f668eb (diff)
downloadale-34892186e44b21356c84e1c2e019f96a304c3edc.zip
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.
-rw-r--r--ale_linters/json/vscodejson.vim16
-rw-r--r--autoload/ale/linter.vim2
-rw-r--r--doc/ale-json.txt12
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale.txt2
-rw-r--r--supported-tools.md1
-rw-r--r--test/test_filetype_linter_defaults.vader2
7 files changed, 34 insertions, 2 deletions
diff --git a/ale_linters/json/vscodejson.vim b/ale_linters/json/vscodejson.vim
new file mode 100644
index 00000000..91988923
--- /dev/null
+++ b/ale_linters/json/vscodejson.vim
@@ -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'),
+\})
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 9079dfa0..98839488 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -45,7 +45,7 @@ let s:default_ale_linters = {
\ 'hack': ['hack'],
\ 'help': [],
\ 'inko': ['inko'],
-\ 'json': ['jsonlint', 'spectral'],
+\ 'json': ['jsonlint', 'spectral', 'vscodejson'],
\ 'json5': [],
\ 'jsonc': [],
\ 'perl': ['perlcritic'],
diff --git a/doc/ale-json.txt b/doc/ale-json.txt
index 67db0b74..879cedb8 100644
--- a/doc/ale-json.txt
+++ b/doc/ale-json.txt
@@ -153,6 +153,18 @@ g:ale_json_spectral_use_global *g:ale_json_spectral_use_global*
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:
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index a311cda9..0bd1b3d1 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -283,6 +283,7 @@ Notes:
* `tsserver`
* `xo`
* JSON
+ * `VSCode JSON language server`
* `cspell`
* `dprint`
* `eslint`
diff --git a/doc/ale.txt b/doc/ale.txt
index 3e6ea02b..383b7ae1 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -1613,6 +1613,7 @@ g:ale_linters *g:ale_linters*
\ 'help': [],
\ 'inko': ['inko'],
\ 'json': ['jsonlint', 'spectral'],
+ \ 'json': ['jsonlint', 'spectral', 'vscodejson'],
\ 'json5': [],
\ 'jsonc': [],
\ 'perl': ['perlcritic'],
@@ -2961,6 +2962,7 @@ documented in additional help files.
jq....................................|ale-json-jq|
prettier..............................|ale-json-prettier|
spectral..............................|ale-json-spectral|
+ vscodejson............................|ale-json-vscode|
jsonc...................................|ale-jsonc-options|
eslint................................|ale-jsonc-eslint|
jsonnet.................................|ale-jsonnet-options|
diff --git a/supported-tools.md b/supported-tools.md
index 45562851..313b3b88 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -292,6 +292,7 @@ formatting.
* [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29)
* [xo](https://github.com/sindresorhus/xo)
* JSON
+ * [VSCode JSON language server](https://www.npmjs.com/package/vscode-json-languageserver)
* [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) :warning:
* [dprint](https://dprint.dev)
* [eslint](http://eslint.org/) :warning:
diff --git a/test/test_filetype_linter_defaults.vader b/test/test_filetype_linter_defaults.vader
index dad8e5ee..1217e237 100644
--- a/test/test_filetype_linter_defaults.vader
+++ b/test/test_filetype_linter_defaults.vader
@@ -60,7 +60,7 @@ Execute(The defaults for the inko filetype should be correct):
AssertEqual [], GetLinterNames('inko')
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