mirror of
https://github.com/mattn/vim-lsp-settings.git
synced 2025-12-12 20:35:54 +01:00
Enable server when installation finished successfully
This commit is contained in:
@@ -29,11 +29,11 @@ endfunction
|
|||||||
|
|
||||||
function! s:vimlsp_installer() abort
|
function! s:vimlsp_installer() abort
|
||||||
if !has_key(s:settings, &filetype)
|
if !has_key(s:settings, &filetype)
|
||||||
return ''
|
return []
|
||||||
endif
|
endif
|
||||||
let l:server = s:settings[&filetype]
|
let l:server = s:settings[&filetype]
|
||||||
if empty(l:server)
|
if empty(l:server)
|
||||||
return ''
|
return []
|
||||||
endif
|
endif
|
||||||
let l:found = {}
|
let l:found = {}
|
||||||
for l:conf in l:server
|
for l:conf in l:server
|
||||||
@@ -50,7 +50,7 @@ function! s:vimlsp_installer() abort
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
if empty(l:found)
|
if empty(l:found)
|
||||||
return ''
|
return []
|
||||||
endif
|
endif
|
||||||
for l:conf in l:server
|
for l:conf in l:server
|
||||||
let l:command = s:vimlsp_settings_get(l:conf.command, 'cmd', l:conf.command)
|
let l:command = s:vimlsp_settings_get(l:conf.command, 'cmd', l:conf.command)
|
||||||
@@ -64,15 +64,33 @@ function! s:vimlsp_installer() abort
|
|||||||
let l:command = l:command . '.sh'
|
let l:command = l:command . '.sh'
|
||||||
endif
|
endif
|
||||||
if s:executable(l:command)
|
if s:executable(l:command)
|
||||||
return l:command
|
return [l:conf.command, l:command]
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
return ''
|
return []
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:vimlsp_install_server_post(command, job, code) abort
|
||||||
|
if a:code != 0
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
if s:executable(a:command)
|
||||||
|
let l:script = printf('%s/%s.vim', s:settings_dir, a:command)
|
||||||
|
echomsg l:script
|
||||||
|
if filereadable(l:script)
|
||||||
|
exe 'source' l:script
|
||||||
|
doautocmd User lsp_setup
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:vimlsp_install_server() abort
|
function! s:vimlsp_install_server() abort
|
||||||
let l:command = s:vimlsp_installer()
|
let l:entry = s:vimlsp_installer()
|
||||||
exe 'terminal' l:command
|
exe 'terminal' l:entry[1]
|
||||||
|
let l:job = term_getjob(bufnr('%'))
|
||||||
|
if l:job != v:null
|
||||||
|
call job_setoptions(l:job, {'exit_cb': function('s:vimlsp_install_server_post', [l:entry[0]])})
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:vimlsp_settings_suggest() abort
|
function! s:vimlsp_settings_suggest() abort
|
||||||
@@ -125,7 +143,7 @@ function! s:vimlsp_setting() abort
|
|||||||
if l:found ==# 0
|
if l:found ==# 0
|
||||||
exe printf('augroup vimlsp_suggest_%s', l:ft)
|
exe printf('augroup vimlsp_suggest_%s', l:ft)
|
||||||
au!
|
au!
|
||||||
exe printf('autocmd FileType %s call s:vimlsp_settings_suggest()', l:ft)
|
exe printf('autocmd FileType %s ++once call s:vimlsp_settings_suggest()', l:ft)
|
||||||
augroup END
|
augroup END
|
||||||
elseif !empty(s:vimlsp_installer())
|
elseif !empty(s:vimlsp_installer())
|
||||||
command! -buffer LspInstallServer call s:vimlsp_install_server()
|
command! -buffer LspInstallServer call s:vimlsp_install_server()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
augroup vimlsp_settings_dockerfile_language_server_nodejs
|
augroup vimlsp_settings_dockerfile_language_server_nodejs
|
||||||
au!
|
au!
|
||||||
autocmd User lsp_setup ++once call lsp#register_server({
|
autocmd User lsp_setup ++once call lsp#register_server({
|
||||||
\ 'name': 'dockerfile-language-server-nodejs',
|
\ 'name': 'docker-langserver',
|
||||||
\ 'cmd': {server_info->lsp_settings#get('docker-langserver', 'cmd', [lsp_settings#exec_path('docker-langserver'), '--stdio'])},
|
\ 'cmd': {server_info->lsp_settings#get('docker-langserver', 'cmd', [lsp_settings#exec_path('docker-langserver'), '--stdio'])},
|
||||||
\ 'whitelist': lsp_settings#get('docker-langserver', 'whitelist', ['dockerfile']),
|
\ 'whitelist': lsp_settings#get('docker-langserver', 'whitelist', ['dockerfile']),
|
||||||
\ 'blacklist': lsp_settings#get('docker-langserver', 'blacklist', []),
|
\ 'blacklist': lsp_settings#get('docker-langserver', 'blacklist', []),
|
||||||
|
|||||||
Reference in New Issue
Block a user