Skip to content

Commit f64b728

Browse files
committed
# This is a combination of 2 commits.
# The first commit's message is: WIP! # The 2nd commit message will be skipped: # WIP!
1 parent f095d2b commit f64b728

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

autoload/vundle.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ com! -nargs=* -bang -complete=custom,vundle#scripts#complete PluginInstall
1212
\ call vundle#installer#new('!' == '<bang>', <f-args>)
1313

1414
com! -nargs=? -bang -complete=custom,vundle#scripts#complete PluginSearch
15-
\ call vundle#scripts#all('!' == '<bang>', <q-args>)
15+
\ call vundle#search#new(<q-args>)
1616

1717
com! -nargs=0 -bang PluginList
1818
\ call vundle#installer#list('!' == '<bang>')

autoload/vundle/search.vim

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
" ---------------------------------------------------------------------------
2+
" Search the database from vim-script.org for a matching plugin. If no
3+
" argument is given, list all plugins. This function is used by the :Plugins
4+
" and :PluginSearch commands.
5+
"
6+
" ... -- a plugin name to search for
7+
" ---------------------------------------------------------------------------
8+
func! vundle#search#new(string)
9+
let info = ['"Keymap: i - Install plugin; c - Cleanup; s - Search; R - Reload list']
10+
let url = s:search_url.'+'.a:string
11+
let query_result = s:search(url)
12+
" check error first
13+
if 0 == query_result[0]
14+
let false = 0
15+
let true = 0
16+
let null = 0
17+
let res = substitute(query_result[1], "\n", "", 'g')
18+
let items = eval(res).items
19+
" echo items
20+
call vundle#scripts#view('search', info, vundle#search#bundle_names(items))
21+
echo len(items).' plugins found'
22+
else
23+
call vundle#scripts#view('search', info, ['"An error running query'])
24+
endif
25+
redraw
26+
endf
27+
28+
" ---------------------------------------------------------------------------
29+
" Create a list of 'Plugin ...' lines from a list of bundle names.
30+
"
31+
" names -- a list of names (strings) of plugins
32+
" return -- a list of 'Plugin ...' lines suitable to be written to a buffer
33+
" ---------------------------------------------------------------------------
34+
func! vundle#search#bundle_names(items)
35+
let r = []
36+
for item in a:items
37+
call add(r, printf("Plugin '%s' \" %s", item.full_name, item.description))
38+
endfo
39+
return r
40+
endf
41+
42+
" ---------------------------------------------------------------------------
43+
"
44+
" to -- the filename (string) to save the database to
45+
" url -- the request url
46+
" return -- 0 on success, 1 if an error occurred
47+
" ---------------------------------------------------------------------------
48+
49+
func! s:search(url)
50+
let url = vundle#installer#shellesc(a:url)
51+
52+
if executable("curl")
53+
let cmd = 'curl --fail -s '.l:url
54+
elseif executable("wget")
55+
let cmd = 'wget -q -O - '.l:url
56+
else
57+
echoerr 'Error curl or wget is not available!'
58+
return [1]
59+
endif
60+
61+
let response = system(cmd)
62+
63+
if (0 != v:shell_error)
64+
echoerr 'Error fetching scripts!'
65+
endif
66+
return [v:shell_error, response]
67+
endf
68+
69+
let s:search_url = 'https://api.github.com/search/repositories?q=language:VimL+user:vim-scripts'
70+
71+
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:

0 commit comments

Comments
 (0)