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:
Peter Benjamin
2023-09-09 15:28:38 -07:00
committed by GitHub
parent 92267a14ba
commit 61892e8586
2 changed files with 50 additions and 1 deletions

View File

@@ -1,6 +1,22 @@
" Author: Dalius Dobravolskas <dalius.dobravolskas@gmail.com> " Author: Dalius Dobravolskas <dalius.dobravolskas@gmail.com>
" Description: VSCode json language server " 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 function! ale_linters#json#vscodejson#GetProjectRoot(buffer) abort
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
@@ -10,7 +26,7 @@ endfunction
call ale#linter#Define('json', { call ale#linter#Define('json', {
\ 'name': 'vscodejson', \ 'name': 'vscodejson',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable': 'vscode-json-language-server', \ 'executable': function('ale_linters#json#vscodejson#GetExecutable'),
\ 'command': '%e --stdio', \ 'command': '%e --stdio',
\ 'project_root': function('ale_linters#json#vscodejson#GetProjectRoot'), \ 'project_root': function('ale_linters#json#vscodejson#GetProjectRoot'),
\}) \})

View 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']