mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 04:34:25 +08:00
fix(json): update vscode json lsp name (#4601)
* fix(json): update vscode json lsp name * fix(vscodejson): fallback to previous name Co-authored-by: w0rp <devw0rp@gmail.com>
This commit is contained in:
@@ -1,6 +1,22 @@
|
||||
" Author: Dalius Dobravolskas <dalius.dobravolskas@gmail.com>
|
||||
" Description: VSCode json language server
|
||||
|
||||
call ale#Set('json_vscodejson_executable', '<auto>')
|
||||
|
||||
function! ale_linters#json#vscodejson#GetExecutable(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'json_vscodejson_executable')
|
||||
|
||||
if l:executable is# '<auto>'
|
||||
if ale#engine#IsExecutable(a:buffer, 'vscode-json-languageserver')
|
||||
let l:executable = 'vscode-json-languageserver'
|
||||
else
|
||||
let l:executable = 'vscode-json-language-server'
|
||||
endif
|
||||
endif
|
||||
|
||||
return l:executable
|
||||
endfunction
|
||||
|
||||
function! ale_linters#json#vscodejson#GetProjectRoot(buffer) abort
|
||||
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
|
||||
|
||||
@@ -10,7 +26,7 @@ endfunction
|
||||
call ale#linter#Define('json', {
|
||||
\ 'name': 'vscodejson',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': 'vscode-json-language-server',
|
||||
\ 'executable': function('ale_linters#json#vscodejson#GetExecutable'),
|
||||
\ 'command': '%e --stdio',
|
||||
\ 'project_root': function('ale_linters#json#vscodejson#GetProjectRoot'),
|
||||
\})
|
||||
|
||||
33
test/linter/test_json_vscodejson.vader
Normal file
33
test/linter/test_json_vscodejson.vader
Normal file
@@ -0,0 +1,33 @@
|
||||
Before:
|
||||
let g:executable_map = {}
|
||||
|
||||
call ale#assert#SetUpLinterTest('json', 'vscodejson')
|
||||
|
||||
runtime autoload/ale/engine.vim
|
||||
|
||||
" Stub out IsExecutable so we can emulate it.
|
||||
function! ale#engine#IsExecutable(buffer, executable) abort
|
||||
return get(g:executable_map, a:executable)
|
||||
endfunction
|
||||
|
||||
After:
|
||||
unlet! g:executable_map
|
||||
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
runtime autoload/ale/engine.vim
|
||||
|
||||
Execute(The default executable name should be correct):
|
||||
let g:executable_map = {'vscode-json-languageserver': 1}
|
||||
|
||||
AssertLinter 'vscode-json-languageserver', [ale#Escape('vscode-json-languageserver') . ' --stdio']
|
||||
|
||||
Execute(We should fall back on the old executable name):
|
||||
let g:executable_map = {'vscode-json-languageserver': 0}
|
||||
|
||||
AssertLinter 'vscode-json-language-server', [ale#Escape('vscode-json-language-server') . ' --stdio']
|
||||
|
||||
Execute(Executable name should be configurable):
|
||||
let b:ale_json_vscodejson_executable = 'foo'
|
||||
|
||||
AssertLinter 'foo', [ale#Escape('foo') . ' --stdio']
|
||||
Reference in New Issue
Block a user