switch to neobundle
This commit is contained in:
parent
6cef5c101f
commit
5a1c95140f
57 changed files with 9901 additions and 1958 deletions
119
.vim/bundle/neobundle.vim/autoload/neobundle/sources/github.vim
Normal file
119
.vim/bundle/neobundle.vim/autoload/neobundle/sources/github.vim
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
"=============================================================================
|
||||
" FILE: github.vim
|
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
||||
" License: MIT license {{{
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
" "Software"), to deal in the Software without restriction, including
|
||||
" without limitation the rights to use, copy, modify, merge, publish,
|
||||
" distribute, sublicense, and/or sell copies of the Software, and to
|
||||
" permit persons to whom the Software is furnished to do so, subject to
|
||||
" the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included
|
||||
" in all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
" }}}
|
||||
"=============================================================================
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! neobundle#sources#github#define() abort "{{{
|
||||
return s:source
|
||||
endfunction"}}}
|
||||
|
||||
let s:source = {
|
||||
\ 'name' : 'github',
|
||||
\ 'short_name' : 'github',
|
||||
\ }
|
||||
|
||||
" sorter
|
||||
let s:filter = {
|
||||
\ "name" : "sorter_stars",
|
||||
\}
|
||||
|
||||
function! s:filter.filter(candidates, context) abort
|
||||
return unite#util#sort_by(a:candidates, 'v:val.source__stars')
|
||||
endfunction
|
||||
|
||||
call unite#define_filter(s:filter)
|
||||
unlet s:filter
|
||||
|
||||
function! s:source.gather_candidates(args, context) abort "{{{
|
||||
let plugins = s:get_github_searches(a:context.source__input)
|
||||
|
||||
|
||||
return map(copy(plugins), "{
|
||||
\ 'word' : v:val.full_name. ' ' . v:val.description,
|
||||
\ 'source__name' : (v:val.fork ? '| ' : '') .
|
||||
\ v:val.full_name,
|
||||
\ 'source__path' : v:val.full_name,
|
||||
\ 'source__description' : v:val.description,
|
||||
\ 'source__stars' : v:val.stargazers_count,
|
||||
\ 'source__options' : [],
|
||||
\ 'action__uri' : v:val.html_url,
|
||||
\ }")
|
||||
endfunction"}}}
|
||||
|
||||
" Misc.
|
||||
" @vimlint(EVL102, 1, l:true)
|
||||
" @vimlint(EVL102, 1, l:false)
|
||||
" @vimlint(EVL102, 1, l:null)
|
||||
function! s:get_github_searches(string) abort "{{{
|
||||
let uri = 'https://api.github.com/search/repositories?q='
|
||||
\ . a:string . '+language:VimL'.'\&sort=stars'.'\&order=desc'
|
||||
let temp = neobundle#util#substitute_path_separator(tempname())
|
||||
|
||||
let cmd = neobundle#util#wget(uri, temp)
|
||||
|
||||
call unite#print_message(
|
||||
\ '[neobundle/search:github] Searching plugins from github...')
|
||||
redraw
|
||||
|
||||
let result = unite#util#system(cmd)
|
||||
|
||||
if cmd =~# '^E:'
|
||||
call unite#print_error(
|
||||
\ '[neobundle/search:github] '.
|
||||
\ 'wget or curl command is not available!')
|
||||
return []
|
||||
elseif unite#util#get_last_status()
|
||||
call unite#print_message('[neobundle/search:github] ' . cmd)
|
||||
call unite#print_error('[neobundle/search:github] Error occurred!')
|
||||
call unite#print_error(result)
|
||||
return []
|
||||
elseif !filereadable(temp)
|
||||
call unite#print_error('[neobundle/search:github] '.
|
||||
\ 'Temporary file was not created!')
|
||||
return []
|
||||
else
|
||||
call unite#print_message('[neobundle/search:github] Done!')
|
||||
endif
|
||||
|
||||
let [true, false, null] = [1,0,"''"]
|
||||
sandbox let data = eval(join(readfile(temp)))
|
||||
call filter(data.items,
|
||||
\ "stridx(v:val.full_name, a:string) >= 0")
|
||||
|
||||
call delete(temp)
|
||||
|
||||
return data.items
|
||||
endfunction"}}}
|
||||
" @vimlint(EVL102, 0, l:true)
|
||||
" @vimlint(EVL102, 0, l:false)
|
||||
" @vimlint(EVL102, 0, l:null)
|
||||
|
||||
call unite#custom_source('neobundle/search', 'sorters', 'sorters_stars')
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: foldmethod=marker
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
"=============================================================================
|
||||
" FILE: metadata.vim
|
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
||||
" License: MIT license {{{
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
" "Software"), to deal in the Software without restriction, including
|
||||
" without limitation the rights to use, copy, modify, merge, publish,
|
||||
" distribute, sublicense, and/or sell copies of the Software, and to
|
||||
" permit persons to whom the Software is furnished to do so, subject to
|
||||
" the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included
|
||||
" in all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
" }}}
|
||||
"=============================================================================
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let s:repository_cache = []
|
||||
|
||||
function! neobundle#sources#metadata#define() abort "{{{
|
||||
return s:source
|
||||
endfunction"}}}
|
||||
|
||||
let s:source = {
|
||||
\ 'name' : 'metadata',
|
||||
\ 'short_name' : 'meta',
|
||||
\ }
|
||||
|
||||
function! s:source.gather_candidates(args, context) abort "{{{
|
||||
let plugins = s:get_repository_plugins(a:context)
|
||||
|
||||
try
|
||||
return map(copy(plugins), "{
|
||||
\ 'word' : v:val.name . ' ' . v:val.description,
|
||||
\ 'source__name' : v:val.name,
|
||||
\ 'source__path' : v:val.repository,
|
||||
\ 'source__script_type' : s:convert2script_type(v:val.raw_type),
|
||||
\ 'source__description' : v:val.description,
|
||||
\ 'source__options' : [],
|
||||
\ 'action__uri' : v:val.uri,
|
||||
\ }")
|
||||
catch
|
||||
call unite#print_error(
|
||||
\ '[neobundle/search:metadata] '
|
||||
\ .'Error occurred in loading cache.')
|
||||
call unite#print_error(
|
||||
\ '[neobundle/search:metadata] '
|
||||
\ .'Please re-make cache by <Plug>(unite_redraw) mapping.')
|
||||
call neobundle#installer#error(v:exception . ' ' . v:throwpoint)
|
||||
|
||||
return []
|
||||
endtry
|
||||
endfunction"}}}
|
||||
|
||||
" Misc.
|
||||
function! s:get_repository_plugins(context) abort "{{{
|
||||
if a:context.is_redraw
|
||||
" Reload cache.
|
||||
call unite#print_message(
|
||||
\ '[neobundle/search:metadata] '
|
||||
\ .'Reloading cache from metadata repository')
|
||||
redraw
|
||||
|
||||
call neobundle#metadata#update()
|
||||
endif
|
||||
|
||||
return s:convert_metadata(neobundle#metadata#get())
|
||||
endfunction"}}}
|
||||
|
||||
function! s:convert_metadata(data) abort "{{{
|
||||
return values(map(copy(a:data), "{
|
||||
\ 'name' : v:key,
|
||||
\ 'raw_type' : get(v:val, 'script-type', ''),
|
||||
\ 'repository' : substitute(v:val.url, '^git://', 'https://', ''),
|
||||
\ 'description' : '',
|
||||
\ 'uri' : get(v:val, 'homepage', ''),
|
||||
\ }"))
|
||||
endfunction"}}}
|
||||
|
||||
function! s:convert2script_type(type) abort "{{{
|
||||
if a:type ==# 'utility'
|
||||
return 'plugin'
|
||||
elseif a:type ==# 'color scheme'
|
||||
return 'colors'
|
||||
else
|
||||
return a:type
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: foldmethod=marker
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
"=============================================================================
|
||||
" FILE: vim_scripts_org.vim
|
||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
||||
" License: MIT license {{{
|
||||
" Permission is hereby granted, free of charge, to any person obtaining
|
||||
" a copy of this software and associated documentation files (the
|
||||
" "Software"), to deal in the Software without restriction, including
|
||||
" without limitation the rights to use, copy, modify, merge, publish,
|
||||
" distribute, sublicense, and/or sell copies of the Software, and to
|
||||
" permit persons to whom the Software is furnished to do so, subject to
|
||||
" the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included
|
||||
" in all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
" }}}
|
||||
"=============================================================================
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let s:Cache = unite#util#get_vital_cache()
|
||||
|
||||
let s:repository_cache = []
|
||||
|
||||
function! neobundle#sources#vim_scripts_org#define() abort "{{{
|
||||
return s:source
|
||||
endfunction"}}}
|
||||
|
||||
let s:source = {
|
||||
\ 'name' : 'vim-scripts.org',
|
||||
\ 'short_name' : 'vim.org',
|
||||
\ }
|
||||
|
||||
function! s:source.gather_candidates(args, context) abort "{{{
|
||||
let repository =
|
||||
\ 'https://raw.githubusercontent.com/vim-scraper/'
|
||||
\ .'vim-scraper.github.com/master/api/scripts_recent.json'
|
||||
|
||||
call unite#print_message(
|
||||
\ '[neobundle/search:vim-scripts.org] repository: ' . repository)
|
||||
|
||||
let plugins = s:get_repository_plugins(a:context, repository)
|
||||
|
||||
try
|
||||
return map(copy(plugins), "{
|
||||
\ 'word' : v:val.name . ' ' . v:val.description,
|
||||
\ 'source__name' : v:val.name,
|
||||
\ 'source__path' : v:val.name,
|
||||
\ 'source__script_type' : s:convert2script_type(v:val.raw_type),
|
||||
\ 'source__description' : v:val.description,
|
||||
\ 'source__options' : [],
|
||||
\ 'action__uri' : v:val.uri,
|
||||
\ }")
|
||||
catch
|
||||
call unite#print_error(
|
||||
\ '[neobundle/search:vim-scripts.org] '
|
||||
\ .'Error occurred in loading cache.')
|
||||
call unite#print_error(
|
||||
\ '[neobundle/search:vim-scripts.org] '
|
||||
\ .'Please re-make cache by <Plug>(unite_redraw) mapping.')
|
||||
call neobundle#installer#error(v:exception . ' ' . v:throwpoint)
|
||||
|
||||
return []
|
||||
endtry
|
||||
endfunction"}}}
|
||||
|
||||
" Misc.
|
||||
function! s:get_repository_plugins(context, path) abort "{{{
|
||||
let cache_dir = neobundle#get_neobundle_dir() . '/.neobundle'
|
||||
|
||||
if a:context.is_redraw || !s:Cache.filereadable(cache_dir, a:path)
|
||||
" Reload cache.
|
||||
let cache_path = s:Cache.getfilename(cache_dir, a:path)
|
||||
|
||||
call unite#print_message(
|
||||
\ '[neobundle/search:vim-scripts.org] '
|
||||
\ .'Reloading cache from ' . a:path)
|
||||
redraw
|
||||
|
||||
if s:Cache.filereadable(cache_dir, a:path)
|
||||
call delete(cache_path)
|
||||
endif
|
||||
|
||||
let temp = unite#util#substitute_path_separator(tempname())
|
||||
|
||||
let cmd = neobundle#util#wget(a:path, temp)
|
||||
if cmd =~# '^E:'
|
||||
call unite#print_error(
|
||||
\ '[neobundle/search:vim-scripts.org] '.
|
||||
\ 'curl or wget command is not available!')
|
||||
return []
|
||||
endif
|
||||
|
||||
let result = unite#util#system(cmd)
|
||||
|
||||
if unite#util#get_last_status()
|
||||
call unite#print_message(
|
||||
\ '[neobundle/search:vim-scripts.org] ' . cmd)
|
||||
call unite#print_message(
|
||||
\ '[neobundle/search:vim-scripts.org] ' . result)
|
||||
call unite#print_error(
|
||||
\ '[neobundle/search:vim-scripts.org] Error occurred!')
|
||||
return []
|
||||
elseif !filereadable(temp)
|
||||
call unite#print_error('[neobundle/search:vim-scripts.org] '.
|
||||
\ 'Temporary file was not created!')
|
||||
return []
|
||||
else
|
||||
call unite#print_message('[neobundle/search:vim-scripts.org] Done!')
|
||||
endif
|
||||
|
||||
sandbox let data = eval(get(readfile(temp), 0, '[]'))
|
||||
|
||||
" Convert cache data.
|
||||
call s:Cache.writefile(cache_dir, a:path,
|
||||
\ [string(s:convert_vim_scripts_data(data))])
|
||||
|
||||
call delete(temp)
|
||||
endif
|
||||
|
||||
if empty(s:repository_cache)
|
||||
sandbox let s:repository_cache =
|
||||
\ eval(get(s:Cache.readfile(cache_dir, a:path), 0, '[]'))
|
||||
endif
|
||||
|
||||
return s:repository_cache
|
||||
endfunction"}}}
|
||||
|
||||
function! s:convert_vim_scripts_data(data) abort "{{{
|
||||
return map(copy(a:data), "{
|
||||
\ 'name' : v:val.n,
|
||||
\ 'raw_type' : v:val.t,
|
||||
\ 'repository' : v:val.rv,
|
||||
\ 'description' : printf('%-5s %s', v:val.rv, v:val.s),
|
||||
\ 'uri' : 'https://github.com/vim-scripts/' . v:val.n,
|
||||
\ }")
|
||||
endfunction"}}}
|
||||
|
||||
function! s:convert2script_type(type) abort "{{{
|
||||
if a:type ==# 'utility'
|
||||
return 'plugin'
|
||||
elseif a:type ==# 'color scheme'
|
||||
return 'colors'
|
||||
else
|
||||
return a:type
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: foldmethod=marker
|
||||
Loading…
Add table
Add a link
Reference in a new issue