diff --git a/autoload/lsp_settings/ui.vim b/autoload/lsp_settings/ui.vim index 5e91f6c..9fe6181 100644 --- a/autoload/lsp_settings/ui.vim +++ b/autoload/lsp_settings/ui.vim @@ -13,6 +13,52 @@ function! s:install_or_update() abort call lsp_settings#install_server(l:languages[0], l:command) endfunction +function! s:open() abort + let l:command = substitute(getline('.'), '\[.\] \(\S\+\).*', '\1', '') + if empty(l:command) + return + endif + + let l:settings = lsp_settings#settings() + for l:ft in sort(keys(l:settings)) + for l:conf in l:settings[l:ft] + if l:conf.command ==# l:command + let l:cmd = '' + if has('win32') || has('win64') + silent! exec printf('!start rundll32 url.dll,FileProtocolHandler %s', l:conf.url) + elseif has('mac') || has('macunix') || has('gui_macvim') || system('uname') =~? '^darwin' + call system(printf('open "%s"', l:conf.url)) + elseif executable('xdg-open') + call system(printf('xdg-open "%s"', l:conf.url)) + elseif executable('firefox') + call system(printf('firefox "%s"', l:conf.url)) + else + return + endif + break + endif + endfor + endfor +endfunction + +function! s:help() abort + let l:command = substitute(getline('.'), '\[.\] \(\S\+\).*', '\1', '') + if empty(l:command) + return + endif + + let l:settings = lsp_settings#settings() + for l:ft in sort(keys(l:settings)) + for l:conf in l:settings[l:ft] + if l:conf.command ==# l:command + echomsg l:conf.url + echomsg l:conf.description + break + endif + endfor + endfor +endfunction + function! s:uninstall() abort let l:command = substitute(getline('.'), '\[.\] \(\S\+\).*', '\1', '') if empty(l:command) @@ -68,7 +114,9 @@ function! lsp_settings#ui#open() abort call s:update() nnoremap i :call install_or_update() nnoremap x :call uninstall() + nnoremap b :call open() + nnoremap ? :call help() nnoremap q :bw redraw - echomsg 'Type i to install, or x to uninstall' + echomsg 'Type i to install, or x to uninstall, b to open browser, ? to show description' endfunction