diff options
author | Yasuhiro Matsumoto <mattn.jp@gmail.com> | 2020-01-27 13:07:08 +0900 |
---|---|---|
committer | Yasuhiro Matsumoto <mattn.jp@gmail.com> | 2020-01-27 13:07:08 +0900 |
commit | 1a83260ff247e156ec81ee703bc2fba7db50582a (patch) | |
tree | 820f0fd3e61c6971cfe8845b0fc9a4fe2b473b64 /autoload/lsp_settings.vim | |
parent | d83e45e1a1f5b16dab688c9e1e1d4789a46b28bb (diff) | |
download | vim-lsp-settings-1a83260ff247e156ec81ee703bc2fba7db50582a.tar.gz vim-lsp-settings-1a83260ff247e156ec81ee703bc2fba7db50582a.tar.bz2 vim-lsp-settings-1a83260ff247e156ec81ee703bc2fba7db50582a.zip |
Add sql-language-server
Diffstat (limited to 'autoload/lsp_settings.vim')
-rw-r--r-- | autoload/lsp_settings.vim | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/autoload/lsp_settings.vim b/autoload/lsp_settings.vim index fbe3210..51ff952 100644 --- a/autoload/lsp_settings.vim +++ b/autoload/lsp_settings.vim @@ -1,4 +1,5 @@ let s:servers_dir = expand('<sfile>:h:h').'/servers' +let s:installer_dir = expand('<sfile>:h:h').'/installer' function! lsp_settings#get(name, key, default) abort let l:config = get(g:, 'lsp_settings', {}) @@ -97,3 +98,40 @@ function! lsp_settings#autocd(server_info) abort exe 'cd' l:path endif endfunction + +function! lsp_settings#complete_installer(arglead, cmdline, cursorpos) abort + let l:settings = json_decode(join(readfile(expand('<sfile>:h:h').'/settings.json'), "\n")) + call remove(l:settings, '$schema') + + let l:ft = tolower(get(split(&filetype, '\.'), 0, '')) + if !has_key(l:settings, l:ft) + return [] + endif + let l:server = l:settings[l:ft] + if empty(l:server) + return [] + endif + let l:installers = [] + for l:conf in l:server + let l:missing = 0 + for l:require in l:conf.requires + if !executable(l:require) + let l:missing = 1 + break + endif + endfor + if l:missing !=# 0 + continue + endif + let l:command = printf('%s/install-%s', s:installer_dir, l:conf.command) + if has('win32') + let l:command = substitute(l:command, '/', '\', 'g') . '.cmd' + else + let l:command = l:command . '.sh' + endif + if executable(l:command) + call add(l:installers, l:conf.command) + endif + endfor + return filter(l:installers, 'stridx(v:val, a:arglead) == 0') +endfunction |