X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/0ee596c5c5e11fc79598407eaf22f83d279f7e9e..5a4872f466ebd76ddd532bdf2798554421c53df4:/.vim/bundle/ale/ale_linters/json/vscodejson.vim?ds=sidebyside diff --git a/.vim/bundle/ale/ale_linters/json/vscodejson.vim b/.vim/bundle/ale/ale_linters/json/vscodejson.vim new file mode 100644 index 00000000..be9eaf53 --- /dev/null +++ b/.vim/bundle/ale/ale_linters/json/vscodejson.vim @@ -0,0 +1,32 @@ +" Author: Dalius Dobravolskas +" Description: VSCode json language server + +call ale#Set('json_vscodejson_executable', '') + +function! ale_linters#json#vscodejson#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'json_vscodejson_executable') + + if l:executable is# '' + 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') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('json', { +\ 'name': 'vscodejson', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#json#vscodejson#GetExecutable'), +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#json#vscodejson#GetProjectRoot'), +\})