mirror of
https://github.com/mattn/vim-lsp-settings.git
synced 2025-12-12 20:35:54 +01:00
Open browser
This commit is contained in:
committed by
mattn
parent
1c0dfc0a26
commit
428e78dbab
@@ -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 <buffer> i :call <SID>install_or_update()<cr>
|
||||
nnoremap <buffer> x :call <SID>uninstall()<cr>
|
||||
nnoremap <buffer> b :call <SID>open()<cr>
|
||||
nnoremap <buffer> ? :call <SID>help()<cr>
|
||||
nnoremap q :bw<cr>
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user