devdocs lookup

This commit is contained in:
ManjaroOne666 2018-02-01 22:55:49 +00:00
parent 38c3127004
commit 298af8af0a
1 changed files with 20 additions and 0 deletions

20
vimrc
View File

@ -517,7 +517,27 @@ if !exists('*RangerExplorer')
endif endif
" devdocs DD
" https://gist.github.com/romainl/8d3b73428b4366f75a19be2dad2f0987#file-devdocs-vim
function! s:Get_env() abort
if has('win64') || has('win32') || has('win16')
return 'WINDOWS'
else
return toupper(substitute(system('uname'), '\n', '', ''))
endif
endfunction
" What command to use on what system
let s:cmds = {"DARWIN": "open", "LINUX": "qutebrowser", "WINDOWS": "start"}
" Build the URL stub
let s:stub = s:cmds[<SID>Get_env()] . " 'http://devdocs.io/?q="
command! -nargs=* DD silent! call system(len(split(<q-args>, ' ')) == 0 ?
\ s:stub . &ft . ' ' . expand('<cword>') . "'" : len(split(<q-args>, ' ')) == 1 ?
\ s:stub . &ft . ' ' . <q-args> . "'" : s:stub . <q-args> . "'")
nnoremap <leader>dd :DD<CR>
" ze end " ze end