refactor. simple UI to install individual scripts
This commit is contained in:
parent
d9bdffe74f
commit
3f13edf6aa
@ -19,6 +19,9 @@ com! -nargs=0 BundleDocs
|
|||||||
com! -nargs=+ -bang BundleSearch
|
com! -nargs=+ -bang BundleSearch
|
||||||
\ silent call vundle#scripts#search('!' == '<bang>', <q-args>)
|
\ silent call vundle#scripts#search('!' == '<bang>', <q-args>)
|
||||||
|
|
||||||
|
com! -nargs=0 Vundle
|
||||||
|
\ call vundle#scripts#browse()
|
||||||
|
|
||||||
com! -nargs=0 VundleLog
|
com! -nargs=0 VundleLog
|
||||||
\ silent pedit `=g:vundle_log`
|
\ silent pedit `=g:vundle_log`
|
||||||
|
|
||||||
|
@ -1,23 +1,32 @@
|
|||||||
func! vundle#scripts#search(bang,search_str)
|
func! vundle#scripts#search(bang,search_str)
|
||||||
let matches = filter(s:load_scripts(a:bang), 'v:val =~? "'.escape(a:search_str,'"').'"')
|
let matches = filter(s:load_scripts(a:bang), 'v:val =~? "'.escape(a:search_str,'"').'"')
|
||||||
let results = map(matches, ' printf("Bundle ' ."'%s'".'", v:val) ')
|
call s:display(['" Search results for: '.a:search_str], matches)
|
||||||
call s:display(reverse(results), a:search_str)
|
let @/=a:search_str
|
||||||
|
redraw
|
||||||
|
endf
|
||||||
|
|
||||||
|
func! vundle#scripts#browse()
|
||||||
|
call s:display(['" Vim scripts: '], s:load_scripts(0))
|
||||||
endf
|
endf
|
||||||
|
|
||||||
func! vundle#scripts#complete(a,c,d)
|
func! vundle#scripts#complete(a,c,d)
|
||||||
return join(s:load_scripts(0),"\n")
|
return join(s:load_scripts(0),"\n")
|
||||||
endf
|
endf
|
||||||
|
|
||||||
func! s:display(results,search_str)
|
func! vundle#scripts#install() abort
|
||||||
if !exists('s:buff') | let s:buff = tempname() | endif
|
let line = substitute(substitute(getline('.'), '\s*Bundle\s*','','g'), "'",'','g')
|
||||||
call writefile(['" Search results for: '.a:search_str] + a:results, s:buff)
|
call vundle#installer#install(0, line)
|
||||||
pedit `=s:buff`
|
|
||||||
wincmd P
|
|
||||||
let @/=a:search_str
|
|
||||||
setlocal hls ignorecase ft=vim
|
|
||||||
redraw!
|
redraw!
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
func! s:display(headers, results)
|
||||||
|
if !exists('s:browse') | let s:browse = tempname() | endif
|
||||||
|
let results = reverse(map(a:results, ' printf("Bundle ' ."'%s'".'", v:val) '))
|
||||||
|
call writefile(a:headers + results, s:browse)
|
||||||
|
pedit `=s:browse`| wincmd P | wincmd H
|
||||||
|
setl ft=vundle
|
||||||
|
endf
|
||||||
|
|
||||||
func! s:fetch_scripts(to)
|
func! s:fetch_scripts(to)
|
||||||
let temp = tempname()
|
let temp = tempname()
|
||||||
exec '!curl http://vim-scripts.org/api/scripts.json > '.temp
|
exec '!curl http://vim-scripts.org/api/scripts.json > '.temp
|
||||||
|
10
ftplugin/vundle.vim
Normal file
10
ftplugin/vundle.vim
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
setl hls ro noma ignorecase
|
||||||
|
|
||||||
|
set syntax=vim
|
||||||
|
|
||||||
|
syn keyword vimCommand Bundle
|
||||||
|
|
||||||
|
nnoremap <buffer> <silent> <CR> :call vundle#scripts#install()<CR>
|
||||||
|
nnoremap <buffer> s :BundleSearch
|
||||||
|
nnoremap <buffer> c :BundleClean<CR>
|
||||||
|
nnoremap <buffer> C :BundleClean!<CR>
|
Loading…
Reference in New Issue
Block a user