switch to neobundle

This commit is contained in:
Barak Michener 2016-10-27 13:40:04 -07:00
parent 6cef5c101f
commit 5a1c95140f
57 changed files with 9901 additions and 1958 deletions

View file

@ -0,0 +1,448 @@
"=============================================================================
" FILE: neobundle.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu at 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
" Check 'term' option value.
if exists('g:loaded_neobundle') && &term ==# 'builtin_gui'
echoerr 'neobundle is initialized in .gvimrc!'
\' neobundle must be initialized in .vimrc.'
endif
if v:version < 702
echoerr 'neobundle does not work this version of Vim (' . v:version . ').'
finish
endif
" Global options definition." "{{{
call neobundle#util#set_default(
\ 'g:neobundle#log_filename', '', 'g:neobundle_log_filename')
call neobundle#util#set_default(
\ 'g:neobundle#default_site', 'github', 'g:neobundle_default_site')
call neobundle#util#set_default(
\ 'g:neobundle#enable_name_conversion', 0)
call neobundle#util#set_default(
\ 'g:neobundle#default_options', {})
call neobundle#util#set_default(
\ 'g:neobundle#install_max_processes', 8,
\ 'g:unite_source_neobundle_install_max_processes')
call neobundle#util#set_default(
\ 'g:neobundle#install_process_timeout', 120)
"}}}
let g:neobundle#tapped = {}
let g:neobundle#hooks = {}
let s:neobundle_dir = ''
let s:neobundle_runtime_dir = neobundle#util#substitute_path_separator(
\ fnamemodify(expand('<sfile>'), ':p:h:h'))
command! -nargs=+
\ NeoBundle
\ call neobundle#parser#bundle(
\ substitute(<q-args>, '\s"[^"]\+$', '', ''))
command! -bar
\ NeoBundleCheck
\ call neobundle#commands#check()
command! -nargs=? -bar
\ -complete=customlist,neobundle#commands#complete_bundles
\ NeoBundleCheckUpdate
\ call neobundle#commands#check_update(<q-args>)
command! -nargs=+
\ NeoBundleLazy
\ call neobundle#parser#lazy(
\ substitute(<q-args>, '\s"[^"]\+$', '', ''))
command! -nargs=+
\ NeoBundleFetch
\ call neobundle#parser#fetch(
\ substitute(<q-args>, '\s"[^"]\+$', '', ''))
command! -nargs=1 -complete=dir -bar
\ NeoBundleLocal
\ call neobundle#local(<q-args>, {})
command! -nargs=+ -bar
\ NeoBundleDirectInstall
\ call neobundle#parser#direct(
\ substitute(<q-args>, '\s"[^"]\+$', '', ''))
command! -nargs=* -bar
\ -complete=customlist,neobundle#commands#complete_lazy_bundles
\ NeoBundleSource
\ call neobundle#commands#source([<f-args>])
command! -nargs=+ -bar
\ -complete=customlist,neobundle#commands#complete_bundles
\ NeoBundleDisable
\ call neobundle#config#disable(<f-args>)
command! -nargs=? -bang -bar
\ -complete=customlist,neobundle#commands#complete_bundles
\ NeoBundleInstall
\ call neobundle#commands#install(
\ '!' == '<bang>', <q-args>)
command! -nargs=? -bang -bar
\ -complete=customlist,neobundle#commands#complete_bundles
\ NeoBundleUpdate
\ call neobundle#commands#install(
\ ('!' == '<bang>' ? 2 : 1), <q-args>)
command! -nargs=+ -bang -bar
\ -complete=customlist,neobundle#commands#complete_bundles
\ NeoBundleReinstall
\ call neobundle#commands#reinstall(<q-args>)
command! -nargs=? -bar
\ -complete=customlist,neobundle#commands#complete_bundles
\ NeoBundleGC
\ call neobundle#commands#gc(<q-args>)
command! -nargs=? -bang -bar
\ NeoBundleList
\ call neobundle#commands#list()
command! -bar
\ NeoBundleDocs
\ call neobundle#commands#helptags(
\ neobundle#config#get_enabled_bundles())
command! -bar
\ NeoBundleLog
\ echo join(neobundle#installer#get_log(), "\n")
command! -bar
\ NeoBundleUpdatesLog
\ echo join(neobundle#installer#get_updates_log(), "\n")
command! -bar
\ NeoBundleExtraEdit
\ execute 'edit' fnameescape(
\ neobundle#get_neobundle_dir()).'/extra_bundles.vim'
command! -bar
\ NeoBundleCount
\ echo len(neobundle#config#get_neobundles())
command! -bar
\ NeoBundleSaveCache
\ call neobundle#commands#save_cache()
command! -bar
\ NeoBundleLoadCache
\ call neobundle#util#print_error(
\ 'NeoBundleLoadCache is deprecated command.') |
\ call neobundle#util#print_error(
\ 'It will be removed in the next version.') |
\ call neobundle#util#print_error(
\ 'Please use neobundle#load_cache() instead.') |
\ call neobundle#commands#load_cache([$MYVIMRC])
command! -bar
\ NeoBundleClearCache
\ call neobundle#commands#clear_cache()
command! -nargs=1 -bar
\ -complete=customlist,neobundle#commands#complete_bundles
\ NeoBundleRollback
\ call neobundle#commands#rollback(<f-args>)
command! -nargs=+ -bar
\ NeoBundleLock
\ call neobundle#commands#lock(<f-args>)
command! -bar
\ NeoBundleRemotePlugins
\ call neobundle#commands#remote_plugins()
function! neobundle#rc(...) abort "{{{
call neobundle#util#print_error(
\ 'neobundle#rc() is removed function.')
call neobundle#util#print_error(
\ 'Please use neobundle#begin()/neobundle#end() instead.')
return 1
endfunction"}}}
function! neobundle#begin(...) abort "{{{
if a:0 > 0
let path = a:1
else
" Use default path
let paths = filter(split(globpath(&runtimepath,
\ 'bundle', 1), '\n'), 'isdirectory(v:val)')
if empty(paths)
let rtps = neobundle#util#split_rtp(&runtimepath)
if empty(rtps)
call neobundle#util#print_error(
\ 'Invalid runtimepath is detected.')
call neobundle#util#print_error(
\ 'Please check your .vimrc.')
return 1
endif
let paths = [rtps[0].'/bundle']
endif
let path = paths[0]
endif
return neobundle#init#_rc(path)
endfunction"}}}
function! neobundle#append() abort "{{{
call neobundle#config#append()
endfunction"}}}
function! neobundle#end() abort "{{{
call neobundle#config#final()
endfunction"}}}
function! neobundle#add(repository, ...) abort "{{{
let options = get(a:000, 0, {})
let bundle = neobundle#parser#_init_bundle(
\ a:repository, [options])
if empty(bundle)
return {}
endif
let bundle.orig_arg = [a:repository, options]
call neobundle#config#add(bundle)
return bundle
endfunction"}}}
function! neobundle#add_meta(name, ...) abort "{{{
let metadata = neobundle#metadata#get(a:name)
if empty(metadata)
call neobundle#util#print_error(
\ 'Plugin name "' . a:name . '" is not found.')
return {}
endif
let repository = substitute(metadata.url, '^git://', 'https://', '')
let options = { 'name' : a:name }
if has_key(metadata, 'addon-info')
\ && has_key(metadata['addon-info'], 'dependencies')
let options.depends = map(keys(metadata['addon-info'].dependencies),
\ "substitute(neobundle#metadata#get(v:val).url,
\ '^git://', 'https://', '')")
endif
call extend(options, get(a:000, 0, {}))
return neobundle#add(repository, options)
endfunction"}}}
function! neobundle#set_neobundle_dir(path) abort "{{{
let s:neobundle_dir = a:path
endfunction"}}}
function! neobundle#get_neobundle_dir() abort "{{{
if s:neobundle_dir == ''
call neobundle#util#print_error(
\ 'neobundle directory is empty.')
return ''
endif
let dir = s:neobundle_dir
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
return dir
endfunction"}}}
function! neobundle#get_runtime_dir() abort "{{{
return s:neobundle_runtime_dir
endfunction"}}}
function! neobundle#get_tags_dir() abort "{{{
if s:neobundle_dir == ''
return ''
endif
let dir = s:neobundle_dir . '/.neobundle/doc'
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
return dir
endfunction"}}}
function! neobundle#get_rtp_dir() abort "{{{
if s:neobundle_dir == ''
return ''
endif
let dir = s:neobundle_dir . '/.neobundle'
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
return dir
endfunction"}}}
function! neobundle#source(bundle_names) abort "{{{
return neobundle#config#source(a:bundle_names)
endfunction"}}}
function! neobundle#local(localdir, ...) abort "{{{
return neobundle#parser#local(
\ a:localdir, get(a:000, 0, {}), get(a:000, 1, ['*']))
endfunction"}}}
function! neobundle#exists_not_installed_bundles() abort "{{{
return !empty(neobundle#get_not_installed_bundles([]))
endfunction"}}}
function! neobundle#is_installed(...) abort "{{{
return type(get(a:000, 0, [])) == type([]) ?
\ !empty(neobundle#_get_installed_bundles(get(a:000, 0, []))) :
\ neobundle#config#is_installed(a:1)
endfunction"}}}
function! neobundle#is_sourced(name) abort "{{{
return neobundle#config#is_sourced(a:name)
endfunction"}}}
function! neobundle#has_cache() abort "{{{
call neobundle#util#print_error(
\ 'neobundle#has_cache() is deprecated function.')
call neobundle#util#print_error(
\ 'It will be removed in the next version.')
call neobundle#util#print_error(
\ 'Please use neobundle#load_cache() instead.')
return filereadable(neobundle#commands#get_cache_file())
endfunction"}}}
function! neobundle#load_cache(...) abort "{{{
let vimrcs = len(a:000) == 0 ? [$MYVIMRC] : a:000
return neobundle#commands#load_cache(vimrcs)
endfunction"}}}
function! neobundle#get_not_installed_bundle_names() abort "{{{
return map(neobundle#get_not_installed_bundles([]), 'v:val.name')
endfunction"}}}
function! neobundle#get_not_installed_bundles(bundle_names) abort "{{{
let bundles = empty(a:bundle_names) ?
\ neobundle#config#get_neobundles() :
\ neobundle#config#fuzzy_search(a:bundle_names)
call neobundle#installer#_load_install_info(bundles)
return filter(copy(bundles), "
\ !v:val.disabled && v:val.path != '' && !v:val.local
\ && !isdirectory(neobundle#util#expand(v:val.path))
\")
endfunction"}}}
function! neobundle#get_force_not_installed_bundles(bundle_names) abort "{{{
let bundles = empty(a:bundle_names) ?
\ neobundle#config#get_neobundles() :
\ neobundle#config#fuzzy_search(a:bundle_names)
call neobundle#installer#_load_install_info(bundles)
return filter(copy(bundles), "
\ !v:val.disabled && v:val.path != '' && !v:val.local
\ && (!isdirectory(neobundle#util#expand(v:val.path))
\ || v:val.install_rev !=#
\ neobundle#installer#get_revision_number(v:val))
\")
endfunction"}}}
function! neobundle#get(name) abort "{{{
return neobundle#config#get(a:name)
endfunction"}}}
function! neobundle#get_hooks(name) abort "{{{
return get(neobundle#config#get(a:name), 'hooks', {})
endfunction"}}}
function! neobundle#tap(name) abort "{{{
let g:neobundle#tapped = neobundle#get(a:name)
let g:neobundle#hooks = get(neobundle#get(a:name), 'hooks', {})
return !empty(g:neobundle#tapped) && !g:neobundle#tapped.disabled
endfunction"}}}
function! neobundle#untap() abort "{{{
let g:neobundle#tapped = {}
let g:neobundle#hooks = {}
endfunction"}}}
function! neobundle#bundle(arg, ...) abort "{{{
let opts = get(a:000, 0, {})
call map(neobundle#util#convert2list(a:arg),
\ "neobundle#config#add(neobundle#parser#_init_bundle(
\ v:val, [deepcopy(opts)]))")
endfunction"}}}
function! neobundle#config(arg, ...) abort "{{{
" Use neobundle#tapped or name.
return type(a:arg) == type({}) ?
\ neobundle#config#set(g:neobundle#tapped.name, a:arg) :
\ type(a:arg) == type('') ?
\ neobundle#config#set(a:arg, a:1) :
\ map(copy(a:arg), "neobundle#config#set(v:val, deepcopy(a:1))")
endfunction"}}}
function! neobundle#call_hook(hook_name, ...) abort "{{{
let bundles = neobundle#util#convert2list(
\ (empty(a:000) ? neobundle#config#get_neobundles() : a:1))
let bundles = filter(copy(bundles),
\ 'has_key(v:val.hooks, a:hook_name)')
if a:hook_name ==# 'on_source' || a:hook_name ==# 'on_post_source'
let bundles = filter(neobundle#config#tsort(filter(bundles,
\ 'neobundle#config#is_sourced(v:val.name) &&
\ neobundle#config#is_installed(v:val.name)')),
\ 'has_key(v:val.hooks, a:hook_name)')
endif
for bundle in bundles
if type(bundle.hooks[a:hook_name]) == type('')
execute 'source' fnameescape(bundle.hooks[a:hook_name])
else
call call(bundle.hooks[a:hook_name], [bundle], bundle)
endif
endfor
endfunction"}}}
function! neobundle#_get_installed_bundles(bundle_names) abort "{{{
let bundles = empty(a:bundle_names) ?
\ neobundle#config#get_neobundles() :
\ neobundle#config#search(a:bundle_names)
return filter(copy(bundles),
\ 'neobundle#config#is_installed(v:val.name)')
endfunction"}}}
function! neobundle#load_toml(filename, ...) abort "{{{
let opts = get(a:000, 0, {})
return neobundle#parser#load_toml(a:filename, opts)
endfunction"}}}
let s:init_vim_path = fnamemodify(expand('<sfile>'), ':h')
\ . '/neobundle/init.vim'
function! neobundle#get_cache_version() abort "{{{
return getftime(s:init_vim_path)
endfunction "}}}
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -0,0 +1,332 @@
let s:save_cpo = &cpo
set cpo&vim
"
" public api
"
function! neobundle#TOML#parse(text) abort
let input = {
\ 'text': a:text,
\ 'p': 0,
\ 'length': strlen(a:text),
\}
return s:_parse(input)
endfunction
function! neobundle#TOML#parse_file(filename) abort
if !filereadable(a:filename)
throw printf("vital: Text.TOML: No such file `%s'.", a:filename)
endif
let text = join(readfile(a:filename), "\n")
" fileencoding is always utf8
return neobundle#TOML#parse(iconv(text, 'utf8', &encoding))
endfunction
"
" private api
"
" work around: '[^\r\n]*' doesn't work well in old-vim, but "[^\r\n]*" works well
let s:skip_pattern = '\C^\%(\_s\+\|' . "#[^\r\n]*" . '\)'
let s:table_name_pattern = '\%([^ [:tab:]#.[\]=]\+\)'
let s:table_key_pattern = s:table_name_pattern
function! s:_skip(input) abort
while s:_match(a:input, '\%(\_s\|#\)')
let a:input.p = matchend(a:input.text, s:skip_pattern, a:input.p)
endwhile
endfunction
function! s:_consume(input, pattern) abort
call s:_skip(a:input)
let end = matchend(a:input.text, '\C^' . a:pattern, a:input.p)
if end == -1
call s:_error(a:input)
elseif end == a:input.p
return ''
endif
let matched = strpart(a:input.text, a:input.p, end - a:input.p)
let a:input.p = end
return matched
endfunction
function! s:_match(input, pattern) abort
return match(a:input.text, '\C^' . a:pattern, a:input.p) != -1
endfunction
function! s:_eof(input) abort
return a:input.p >= a:input.length
endfunction
function! s:_error(input) abort
let buf = []
let offset = 0
while (a:input.p + offset) < a:input.length && a:input.text[a:input.p + offset] !~# "[\r\n]"
let buf += [a:input.text[a:input.p + offset]]
let offset += 1
endwhile
throw printf("vital: Text.TOML: Illegal toml format at `%s'.", join(buf, ''))
endfunction
function! s:_parse(input) abort
let data = {}
call s:_skip(a:input)
while !s:_eof(a:input)
if s:_match(a:input, '[^ [:tab:]#.[\]]')
let key = s:_key(a:input)
call s:_equals(a:input)
let value = s:_value(a:input)
call s:_put_dict(data, key, value)
unlet value
elseif s:_match(a:input, '\[\[')
let [key, value] = s:_array_of_tables(a:input)
call s:_put_array(data, key, value)
unlet value
elseif s:_match(a:input, '\[')
let [key, value] = s:_table(a:input)
call s:_put_dict(data, key, value)
unlet value
else
call s:_error(a:input)
endif
call s:_skip(a:input)
endwhile
return data
endfunction
function! s:_key(input) abort
let s = s:_consume(a:input, s:table_key_pattern)
return s
endfunction
function! s:_equals(input) abort
call s:_consume(a:input, '=')
return '='
endfunction
function! s:_value(input) abort
call s:_skip(a:input)
if s:_match(a:input, '"\{3}')
return s:_multiline_basic_string(a:input)
elseif s:_match(a:input, '"\{1}')
return s:_basic_string(a:input)
elseif s:_match(a:input, "'\\{3}")
return s:_multiline_literal(a:input)
elseif s:_match(a:input, "'\\{1}")
return s:_literal(a:input)
elseif s:_match(a:input, '\[')
return s:_array(a:input)
elseif s:_match(a:input, '\%(true\|false\)')
return s:_boolean(a:input)
elseif s:_match(a:input, '\d\{4}-')
return s:_datetime(a:input)
elseif s:_match(a:input, '[+-]\?\%(\d\+\.\d\|\d\+\%(\.\d\+\)\?[eE]\)')
return s:_float(a:input)
else
return s:_integer(a:input)
endif
endfunction
"
" String
"
function! s:_basic_string(input) abort
let s = s:_consume(a:input, '"\%(\\"\|[^"]\)*"')
let s = s[1 : -2]
return s:_unescape(s)
endfunction
function! s:_multiline_basic_string(input) abort
let s = s:_consume(a:input, '"\{3}\_.\{-}"\{3}')
let s = s[3 : -4]
let s = substitute(s, "^\n", '', '')
let s = substitute(s, '\\' . "\n" . '\_s*', '', 'g')
return s:_unescape(s)
endfunction
function! s:_literal(input) abort
let s = s:_consume(a:input, "'[^']*'")
return s[1 : -2]
endfunction
function! s:_multiline_literal(input) abort
let s = s:_consume(a:input, "'\\{3}.\\{-}'\\{3}")
let s = s[3 : -4]
let s = substitute(s, "^\n", '', '')
return s
endfunction
"
" Integer
"
function! s:_integer(input) abort
let s = s:_consume(a:input, '[+-]\?\d\+')
return str2nr(s)
endfunction
"
" Float
"
function! s:_float(input) abort
if s:_match(a:input, '[+-]\?[0-9.]\+[eE][+-]\?\d\+')
return s:_exponent(a:input)
else
return s:_fractional(a:input)
endif
endfunction
function! s:_fractional(input) abort
let s = s:_consume(a:input, '[+-]\?[0-9.]\+')
return str2float(s)
endfunction
function! s:_exponent(input) abort
let s = s:_consume(a:input, '[+-]\?[0-9.]\+[eE][+-]\?\d\+')
return str2float(s)
endfunction
"
" Boolean
"
function! s:_boolean(input) abort
let s = s:_consume(a:input, '\%(true\|false\)')
return (s ==# 'true') ? 1 : 0
endfunction
"
" Datetime
"
function! s:_datetime(input) abort
let s = s:_consume(a:input, '\d\{4}-\d\{2}-\d\{2}T\d\{2}:\d\{2}:\d\{2}\%(Z\|-\?\d\{2}:\d\{2}\|\.\d\+-\d\{2}:\d\{2}\)')
return s
endfunction
"
" Array
"
function! s:_array(input) abort
let ary = []
let _ = s:_consume(a:input, '\[')
call s:_skip(a:input)
while !s:_eof(a:input) && !s:_match(a:input, '\]')
let ary += [s:_value(a:input)]
call s:_consume(a:input, ',\?')
call s:_skip(a:input)
endwhile
let _ = s:_consume(a:input, '\]')
return ary
endfunction
"
" Table
"
function! s:_table(input) abort
let tbl = {}
let name = s:_consume(a:input, '\[\s*' . s:table_name_pattern . '\%(\s*\.\s*' . s:table_name_pattern . '\)*\s*\]')
let name = name[1 : -2]
call s:_skip(a:input)
" while !s:_eof(a:input) && !s:_match(a:input, '\[\{1,2}[a-zA-Z0-9.]\+\]\{1,2}')
while !s:_eof(a:input) && !s:_match(a:input, '\[')
let key = s:_key(a:input)
call s:_equals(a:input)
let value = s:_value(a:input)
let tbl[key] = value
unlet value
call s:_skip(a:input)
endwhile
return [name, tbl]
endfunction
"
" Array of tables
"
function! s:_array_of_tables(input) abort
let tbl = {}
let name = s:_consume(a:input, '\[\[\s*' . s:table_name_pattern . '\%(\s*\.\s*' . s:table_name_pattern . '\)*\s*\]\]')
let name = name[2 : -3]
call s:_skip(a:input)
" while !s:_eof(a:input) && !s:_match(a:input, '\[\{1,2}[a-zA-Z0-9.]\+\]\{1,2}')
while !s:_eof(a:input) && !s:_match(a:input, '\[')
let key = s:_key(a:input)
call s:_equals(a:input)
let value = s:_value(a:input)
let tbl[key] = value
unlet value
call s:_skip(a:input)
endwhile
return [name, [tbl]]
endfunction
function! s:_unescape(text) abort
let text = a:text
let text = substitute(text, '\\"', '"', 'g')
let text = substitute(text, '\\b', "\b", 'g')
let text = substitute(text, '\\t', "\t", 'g')
let text = substitute(text, '\\n', "\n", 'g')
let text = substitute(text, '\\f', "\f", 'g')
let text = substitute(text, '\\r', "\r", 'g')
let text = substitute(text, '\\/', "/", 'g')
let text = substitute(text, '\\\\', '\', 'g')
let text = substitute(text, '\C\\u\(\x\{4}\)', '\=s:_nr2char("0x" . submatch(1))', 'g')
let text = substitute(text, '\C\\U\(\x\{8}\)', '\=s:_nr2char("0x" . submatch(1))', 'g')
return text
endfunction
function! s:_nr2char(nr) abort
return iconv(nr2char(a:nr), &encoding, 'utf8')
endfunction
function! s:_put_dict(dict, key, value) abort
let keys = split(a:key, '\.')
let ref = a:dict
for key in keys[ : -2]
if has_key(ref, key) && type(ref[key]) == type({})
let ref = ref[key]
elseif has_key(ref, key) && type(ref[key]) == type([])
let ref = ref[key][-1]
else
let ref[key] = {}
let ref = ref[key]
endif
endfor
let ref[keys[-1]] = a:value
endfunction
function! s:_put_array(dict, key, value) abort
let keys = split(a:key, '\.')
let ref = a:dict
for key in keys[ : -2]
let ref[key] = get(ref, key, {})
if type(ref[key]) == type([])
let ref = ref[key][-1]
else
let ref = ref[key]
endif
endfor
let ref[keys[-1]] = get(ref, keys[-1], []) + a:value
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et ts=2 sts=2 sw=2 tw=0:

View file

@ -0,0 +1,275 @@
"=============================================================================
" FILE: autoload.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu at 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#autoload#init() abort "{{{
let s:active_auto_source = 0
let s:loaded_path = 0
augroup neobundle
autocmd FileType *
\ call s:on_filetype()
autocmd FuncUndefined *
\ call s:on_function()
autocmd InsertEnter *
\ call s:on_insert()
augroup END
if has('patch-7.4.414')
autocmd neobundle CmdUndefined *
\ call s:on_command_prefix()
endif
augroup neobundle-path
autocmd!
augroup END
for event in [
\ 'BufRead', 'BufCreate', 'BufEnter',
\ 'BufWinEnter', 'BufNew', 'VimEnter', 'BufNewFile'
\ ]
execute 'autocmd neobundle-path' event
\ "* call s:on_path(expand('<afile>'), ".string(event) . ")"
endfor
augroup neobundle-focus
autocmd!
autocmd CursorHold * if s:active_auto_source
\ | call s:source_focus()
\ | endif
autocmd FocusLost * let s:active_auto_source = 1 | call s:source_focus()
autocmd FocusGained * let s:active_auto_source = 0
augroup END
endfunction"}}}
function! neobundle#autoload#_command(command, name, args, bang, line1, line2) abort "{{{
call neobundle#config#source(a:name)
if !exists(':' . a:command)
call neobundle#util#print_error(
\ printf('command %s is not found.', a:command))
return
endif
let range = (a:line1 == a:line2) ? '' :
\ (a:line1==line("'<") && a:line2==line("'>")) ?
\ "'<,'>" : a:line1.",".a:line2
try
execute range.a:command.a:bang a:args
catch /^Vim\%((\a\+)\)\=:E481/
" E481: No range allowed
execute a:command.a:bang a:args
endtry
endfunction"}}}
function! neobundle#autoload#_command_dummy_complete(arglead, cmdline, cursorpos) abort "{{{
" Load plugins
let command = tolower(matchstr(a:cmdline, '\a\S*'))
let bundles = filter(neobundle#config#get_autoload_bundles(),
\ "!empty(filter(map(copy(v:val.pre_cmd), 'tolower(v:val)'),
\ 'stridx(command, v:val) == 0'))")
call neobundle#config#source_bundles(bundles)
" Print the candidates
call feedkeys("\<C-d>", 'n')
return ['']
endfunction"}}}
function! neobundle#autoload#_mapping(mapping, name, mode) abort "{{{
let cnt = v:count > 0 ? v:count : ''
let input = s:get_input()
call neobundle#config#source(a:name)
if a:mode ==# 'v' || a:mode ==# 'x'
call feedkeys('gv', 'n')
elseif a:mode ==# 'o'
" TODO: omap
" v:prevcount?
" Cancel waiting operator mode.
call feedkeys(v:operator, 'm')
endif
call feedkeys(cnt, 'n')
let mapping = a:mapping
while mapping =~ '<[[:alnum:]-]\+>'
let mapping = substitute(mapping, '\c<Leader>',
\ get(g:, 'mapleader', '\'), 'g')
let mapping = substitute(mapping, '\c<LocalLeader>',
\ get(g:, 'maplocalleader', '\'), 'g')
let ctrl = matchstr(mapping, '<\zs[[:alnum:]-]\+\ze>')
execute 'let mapping = substitute(
\ mapping, "<' . ctrl . '>", "\<' . ctrl . '>", "")'
endwhile
call feedkeys(mapping . input, 'm')
return ''
endfunction"}}}
function! neobundle#autoload#_source(bundle_name) abort "{{{
let bundles = filter(neobundle#config#get_autoload_bundles(),
\ "index(v:val.on_source, a:bundle_name) >= 0")
if !empty(bundles)
call neobundle#config#source_bundles(bundles)
endif
endfunction"}}}
function! neobundle#autoload#_set_function_prefixes(bundles) abort "{{{
for bundle in filter(copy(a:bundles), "empty(v:val.pre_func)")
let bundle.pre_func =
\ neobundle#util#uniq(map(split(globpath(
\ bundle.path, 'autoload/**/*.vim', 1), "\n"),
\ "substitute(matchstr(
\ neobundle#util#substitute_path_separator(
\ fnamemodify(v:val, ':r')),
\ '/autoload/\\zs.*$'), '/', '#', 'g').'#'"))
endfor
endfunction"}}}
function! s:on_filetype() abort "{{{
let bundles = filter(neobundle#config#get_autoload_bundles(),
\ "!empty(v:val.on_ft)")
for filetype in add(neobundle#util#get_filetypes(), 'all')
call neobundle#config#source_bundles(filter(copy(bundles),"
\ index(v:val.on_ft, filetype) >= 0"))
endfor
endfunction"}}}
function! s:on_insert() abort "{{{
let bundles = filter(neobundle#config#get_autoload_bundles(),
\ "v:val.on_i")
if !empty(bundles)
call neobundle#config#source_bundles(bundles)
doautocmd InsertEnter
endif
endfunction"}}}
function! s:on_function() abort "{{{
let function = expand('<amatch>')
let function_prefix = substitute(function, '[^#]*$', '', '')
if function_prefix =~# '^neobundle#'
\ || function_prefix ==# 'vital#'
\ || has('vim_starting')
return
endif
let bundles = neobundle#config#get_autoload_bundles()
call neobundle#autoload#_set_function_prefixes(bundles)
let bundles = filter(bundles,
\ "index(v:val.pre_func, function_prefix) >= 0
\ || (index(v:val.on_func, function) >= 0)")
call neobundle#config#source_bundles(bundles)
endfunction"}}}
function! s:on_command_prefix() abort "{{{
let command = tolower(expand('<afile>'))
let bundles = filter(neobundle#config#get_autoload_bundles(),
\ "!empty(filter(map(copy(v:val.pre_cmd), 'tolower(v:val)'),
\ 'stridx(command, v:val) == 0'))")
call neobundle#config#source_bundles(bundles)
endfunction"}}}
function! s:on_path(path, event) abort "{{{
if a:path == ''
return
endif
let path = a:path
" For ":edit ~".
if fnamemodify(path, ':t') ==# '~'
let path = '~'
endif
let path = neobundle#util#expand(path)
let bundles = filter(neobundle#config#get_autoload_bundles(),
\ "len(filter(copy(v:val.on_path),
\ 'path =~? v:val')) > 0")")
if !empty(bundles)
call neobundle#config#source_bundles(bundles)
execute 'doautocmd' a:event
if !s:loaded_path && has('vim_starting')
\ && neobundle#util#redir('filetype') =~# 'detection:ON'
" Force enable auto detection if path bundles are loaded
autocmd neobundle VimEnter * filetype detect
endif
let s:loaded_path = 1
endif
endfunction"}}}
function! s:source_focus() abort "{{{
let bundles = neobundle#util#sort_by(filter(
\ neobundle#config#get_autoload_bundles(),
\ "v:val.focus > 0"), 'v:val.focus')
if empty(bundles)
augroup neobundle-focus
autocmd!
augroup END
return
endif
call neobundle#config#source_bundles([bundles[0]])
call feedkeys("g\<ESC>", 'n')
endfunction"}}}
function! s:get_input() abort "{{{
let input = ''
let termstr = "<M-_>"
call feedkeys(termstr, 'n')
let type_num = type(0)
while 1
let char = getchar()
let input .= (type(char) == type_num) ? nr2char(char) : char
let idx = stridx(input, termstr)
if idx >= 1
let input = input[: idx - 1]
break
elseif idx == 0
let input = ''
break
endif
endwhile
return input
endfunction"}}}
function! s:get_lazy_bundles() abort "{{{
return filter(neobundle#config#get_neobundles(),
\ "!v:val.sourced && v:val.rtp != '' && v:val.lazy")
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -0,0 +1,79 @@
" Utilities for output cache.
let s:save_cpo = &cpo
set cpo&vim
function! neobundle#cache#getfilename(cache_dir, filename) abort
return s:_encode_name(a:cache_dir, a:filename)
endfunction
function! neobundle#cache#filereadable(cache_dir, filename) abort
let cache_name = s:_encode_name(a:cache_dir, a:filename)
return filereadable(cache_name)
endfunction
function! neobundle#cache#readfile(cache_dir, filename) abort
let cache_name = s:_encode_name(a:cache_dir, a:filename)
return filereadable(cache_name) ? readfile(cache_name) : []
endfunction
function! neobundle#cache#writefile(cache_dir, filename, list) abort
let cache_name = s:_encode_name(a:cache_dir, a:filename)
call writefile(a:list, cache_name)
endfunction
function! neobundle#cache#deletefile(cache_dir, filename) abort
let cache_name = s:_encode_name(a:cache_dir, a:filename)
return delete(cache_name)
endfunction
function! s:_encode_name(cache_dir, filename) abort
" Check cache directory.
if !isdirectory(a:cache_dir)
call mkdir(a:cache_dir, 'p')
endif
let cache_dir = a:cache_dir
if cache_dir !~ '/$'
let cache_dir .= '/'
endif
return cache_dir . s:_create_hash(cache_dir, a:filename)
endfunction
function! neobundle#cache#check_old_cache(cache_dir, filename) abort
" Check old cache file.
let cache_name = s:_encode_name(a:cache_dir, a:filename)
let ret = getftime(cache_name) == -1
\ || getftime(cache_name) <= getftime(a:filename)
if ret && filereadable(cache_name)
" Delete old cache.
call delete(cache_name)
endif
return ret
endfunction
function! s:_create_hash(dir, str) abort
if len(a:dir) + len(a:str) < 150
let hash = substitute(substitute(
\ a:str, ':', '=-', 'g'), '[/\\]', '=+', 'g')
elseif exists('*sha256')
let hash = sha256(a:str)
else
" Use simple hash.
let sum = 0
for i in range(len(a:str))
let sum += char2nr(a:str[i]) * (i + 1)
endfor
let hash = printf('%x', sum)
endif
return hash
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et ts=2 sts=2 sw=2 tw=0:

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,300 @@
"=============================================================================
" FILE: init.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" Copyright (C) 2010 http://github.com/gmarik
" 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#init#_rc(path) abort "{{{
let path =
\ neobundle#util#substitute_path_separator(
\ neobundle#util#expand(a:path))
if path =~ '/$'
let path = path[: -2]
endif
if path == ''
call neobundle#util#print_error(
\ 'neobundle#rc() argument is empty.')
return
endif
call neobundle#set_neobundle_dir(path)
" Join to the tail in runtimepath.
let rtp = neobundle#get_rtp_dir()
execute 'set rtp-='.fnameescape(rtp)
let rtps = neobundle#util#split_rtp(&runtimepath)
let n = index(rtps, $VIMRUNTIME)
if n < 0
call neobundle#util#print_error(
\ 'Invalid runtimepath is detected.')
call neobundle#util#print_error(
\ 'Please check your .vimrc.')
return
endif
let &runtimepath = neobundle#util#join_rtp(
\ insert(rtps, rtp, n-1), &runtimepath, rtp)
augroup neobundle
autocmd!
augroup END
call neobundle#config#init()
call neobundle#autoload#init()
endfunction"}}}
function! neobundle#init#_bundle(bundle) abort "{{{
if (!has_key(a:bundle, 'type') && get(a:bundle, 'local', 0))
\ || get(a:bundle, 'type', '') ==# 'nosync'
" Default type.
let a:bundle.type = 'none'
endif
if !has_key(a:bundle, 'type')
call neobundle#installer#error(
\ printf('Failed parse name "%s" and args %s',
\ a:bundle.orig_name, string(a:bundle.orig_opts)))
return {}
endif
let bundle = {
\ 'uri' : '',
\ 'script_type' : '',
\ 'rev' : '',
\ 'rtp' : '',
\ 'depends' : [],
\ 'fetch' : 0,
\ 'force' : 0,
\ 'gui' : 0,
\ 'terminal' : 0,
\ 'autoload' : {},
\ 'hooks' : {},
\ 'external_commands' : {},
\ 'build_commands': {},
\ 'description' : '',
\ 'dummy_commands' : [],
\ 'dummy_mappings' : [],
\ 'sourced' : 0,
\ 'disabled' : 0,
\ 'local' : 0,
\ 'focus' : 0,
\ 'verbose' : 0,
\ 'orig_name' : '',
\ 'vim_version' : '',
\ 'orig_opts' : {},
\ 'base' : neobundle#get_neobundle_dir(),
\ 'install_rev' : '',
\ 'install_process_timeout'
\ : g:neobundle#install_process_timeout,
\ 'refcnt' : 1,
\ 'frozen' : 0,
\ 'on_i' : 0,
\ 'on_ft' : [],
\ 'on_cmd' : [],
\ 'on_func' : [],
\ 'on_map' : [],
\ 'on_path' : [],
\ 'on_source' : [],
\ 'pre_cmd' : [],
\ 'pre_func' : [],
\ }
call extend(bundle, a:bundle)
if !has_key(bundle, 'name')
let bundle.name = neobundle#util#name_conversion(bundle.orig_name)
endif
if !has_key(bundle, 'normalized_name')
let bundle.normalized_name = substitute(
\ fnamemodify(bundle.name, ':r'),
\ '\c^vim[_-]\|[_-]vim$', '', 'g')
endif
if !has_key(bundle.orig_opts, 'name') &&
\ g:neobundle#enable_name_conversion
" Use normalized name.
let bundle.name = bundle.normalized_name
endif
if !has_key(bundle, 'directory')
let bundle.directory = bundle.name
if bundle.rev != ''
let bundle.directory .= '_' . substitute(bundle.rev,
\ '[^[:alnum:]_-]', '_', 'g')
endif
endif
if bundle.base[0] == '~'
let bundle.base = neobundle#util#expand(bundle.base)
endif
if bundle.base[-1] == '/' || bundle.base[-1] == '\'
" Chomp.
let bundle.base = bundle.base[: -2]
endif
let bundle.path = isdirectory(bundle.uri) ?
\ bundle.uri : bundle.base.'/'.bundle.directory
" Check relative path.
if bundle.rtp !~ '^\%([~/]\|\a\+:\)'
let bundle.rtp = bundle.path.'/'.bundle.rtp
endif
if bundle.rtp[0] == '~'
let bundle.rtp = neobundle#util#expand(bundle.rtp)
endif
if bundle.rtp[-1] == '/' || bundle.rtp[-1] == '\'
" Chomp.
let bundle.rtp = bundle.rtp[: -2]
endif
if bundle.normalized_name ==# 'neobundle' || bundle.fetch
" Do not add runtimepath.
let bundle.rtp = ''
endif
if bundle.script_type != ''
" Add script_type.
" Note: To check by neobundle#config#is_installed().
let bundle.path .= '/' . bundle.script_type
endif
if !has_key(bundle, 'augroup')
let bundle.augroup = bundle.normalized_name
endif
" Convert old name
if has_key(bundle, 'stay_same')
let bundle.frozen = bundle.stay_same
endif
call s:init_lazy(bundle)
" Parse depends.
if !empty(bundle.depends)
call s:init_depends(bundle)
endif
if type(bundle.disabled) == type('')
let bundle.disabled = eval(bundle.disabled)
endif
let bundle.disabled = bundle.disabled
\ || (bundle.gui && !has('gui_running'))
\ || (bundle.terminal && has('gui_running'))
\ || (bundle.vim_version != ''
\ && s:check_version(bundle.vim_version))
\ || (!empty(bundle.external_commands)
\ && neobundle#config#check_commands(bundle.external_commands))
return bundle
endfunction"}}}
function! s:init_lazy(bundle) abort "{{{
let bundle = a:bundle
" Auto set autoload keys.
for key in filter([
\ 'filetypes', 'filename_patterns',
\ 'commands', 'functions', 'mappings',
\ 'insert', 'explorer',
\ 'command_prefix', 'function_prefixes',
\ ], 'has_key(bundle, v:val)')
let bundle.autoload[key] = bundle[key]
call remove(bundle, key)
endfor
" Auto set on keys.
for [key, value] in items(filter({
\ 'filetypes' : 'on_ft',
\ 'filename_patterns' : 'on_path',
\ 'commands' : 'on_cmd',
\ 'functions' : 'on_func',
\ 'mappings' : 'on_map',
\ 'insert' : 'on_i',
\ 'explorer' : 'on_path',
\ 'on_source' : 'on_source',
\ 'command_prefix' : 'pre_cmd',
\ 'function_prefixes' : 'pre_func',
\ }, 'has_key(bundle.autoload, v:key)'))
let bundle[value] = (key ==# 'explorer'
\ && type(bundle.autoload[key]) == type(0)
\ && bundle.autoload[key] == 1) ? '.*' : bundle.autoload[key]
endfor
if empty(bundle.pre_cmd)
let bundle.pre_cmd = substitute(bundle.normalized_name, '[_-]', '', 'g')
endif
" Auto convert2list.
for key in filter([
\ 'on_ft', 'on_path', 'on_cmd',
\ 'on_func', 'on_map',
\ 'on_source', 'pre_cmd', 'pre_func',
\ ], "type(bundle[v:val]) != type([])
\")
let bundle[key] = [bundle[key]]
endfor
if !has_key(bundle, 'lazy')
" Set lazy flag automatically
let bundle.lazy = bundle.on_i
\ || !empty(filter(['on_ft', 'on_path', 'on_cmd',
\ 'on_func', 'on_map', 'on_source'],
\ '!empty(bundle[v:val])'))
endif
endfunction"}}}
function! s:init_depends(bundle) abort "{{{
let bundle = a:bundle
let _ = []
for depend in neobundle#util#convert2list(bundle.depends)
if type(depend) == type('')
let depend = string(depend)
endif
let depend_bundle = type(depend) == type({}) ?
\ depend : neobundle#parser#bundle(depend, 1)
let depend_bundle.lazy = bundle.lazy
call add(_, depend_bundle)
unlet depend
endfor
let bundle.depends = _
endfunction"}}}
function! s:check_version(min_version) abort "{{{
let versions = split(a:min_version, '\.')
let major = get(versions, 0, 0)
let minor = get(versions, 1, 0)
let patch = get(versions, 2, 0)
let min_version = major * 100 + minor
return v:version < min_version ||
\ (patch != 0 && v:version == min_version && !has('patch'.patch))
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,84 @@
"=============================================================================
" FILE: metadata.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu at 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:metadata = {}
let s:repository =
\ 'https://gist.githubusercontent.com/Shougo/'
\ . '028d6ae320cc8f354f88/raw/'
\ . '3b62ad42d39a4d3d4f236a45e00eb6b03ca23352/vim-pi.json'
function! neobundle#metadata#get(...) abort "{{{
if empty(s:metadata)
call s:load()
endif
return (a:0 == 0) ? copy(s:metadata) : get(s:metadata, a:1, {})
endfunction"}}}
function! neobundle#metadata#update() abort "{{{
" Reload cache.
let cache_path = neobundle#get_neobundle_dir() . '/.neobundle/metadata.json'
if filereadable(cache_path)
call delete(cache_path)
endif
let cmd = neobundle#util#wget(s:repository, cache_path)
if cmd =~# '^E:'
call neobundle#util#print_error(
\ 'curl or wget command is not available!')
return
endif
let result = neobundle#util#system(cmd)
if neobundle#util#get_last_status()
call neobundle#util#print_error('Error occurred!')
call neobundle#util#print_error(cmd)
call neobundle#util#print_error(result)
elseif !filereadable(cache_path)
call neobundle#util#print_error('Temporary file was not created!')
endif
endfunction"}}}
function! s:load() abort "{{{
" Reload cache.
let cache_path = neobundle#get_neobundle_dir() . '/.neobundle/metadata.json'
if !filereadable(cache_path)
call neobundle#metadata#update()
endif
sandbox let s:metadata = eval(get(readfile(cache_path), 0, '{}'))
return s:metadata
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -0,0 +1,314 @@
"=============================================================================
" FILE: parser.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
" Copyright (C) 2010 http://github.com/gmarik
" 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#parser#bundle(arg, ...) abort "{{{
let bundle = s:parse_arg(a:arg)
let is_parse_only = get(a:000, 0, 0)
if !is_parse_only
call neobundle#config#add(bundle)
if !neobundle#config#within_block()
\ && !bundle.lazy && has('vim_starting')
call neobundle#util#print_error(
\ '`NeoBundle` commands must be executed within' .
\ ' a neobundle#begin/end block. Please check your usage.')
endif
endif
return bundle
endfunction"}}}
function! neobundle#parser#lazy(arg) abort "{{{
let bundle = s:parse_arg(a:arg)
if empty(bundle)
return {}
endif
" Update lazy flag.
let bundle.lazy = 1
let bundle.orig_opts.lazy = 1
for depend in bundle.depends
let depend.lazy = bundle.lazy
endfor
call neobundle#config#add(bundle)
return bundle
endfunction"}}}
function! neobundle#parser#fetch(arg) abort "{{{
let bundle = s:parse_arg(a:arg)
if empty(bundle)
return {}
endif
" Clear runtimepath.
let bundle.fetch = 1
let bundle.rtp = ''
call neobundle#config#add(bundle)
return bundle
endfunction"}}}
function! neobundle#parser#direct(arg) abort "{{{
let bundle = neobundle#parser#bundle(a:arg, 1)
if empty(bundle)
return {}
endif
if !empty(neobundle#get(bundle.name))
call neobundle#util#print_error(
\ bundle.name . ' is already installed.')
return {}
endif
call neobundle#config#add(bundle)
call neobundle#config#save_direct(a:arg)
" Direct install.
call neobundle#commands#install(0, bundle.name)
return bundle
endfunction"}}}
function! s:parse_arg(arg) abort "{{{
let arg = type(a:arg) == type([]) ?
\ string(a:arg) : '[' . a:arg . ']'
let args = eval(arg)
if empty(args)
return {}
endif
let bundle = neobundle#parser#_init_bundle(
\ args[0], args[1:])
if empty(bundle)
return {}
endif
let bundle.orig_arg = copy(a:arg)
return bundle
endfunction"}}}
function! neobundle#parser#_init_bundle(name, opts) abort "{{{
let path = substitute(a:name, "['".'"]\+', '', 'g')
if path[0] == '~'
let path = neobundle#util#expand(path)
endif
let opts = s:parse_options(a:opts)
let bundle = extend(neobundle#parser#path(
\ path, opts), opts)
let bundle.orig_name = a:name
let bundle.orig_path = path
let bundle.orig_opts = opts
let bundle.orig_arg = string(a:name).', '.string(opts)
let bundle = neobundle#init#_bundle(bundle)
return bundle
endfunction"}}}
function! neobundle#parser#local(localdir, options, includes) abort "{{{
let base = fnamemodify(neobundle#util#expand(a:localdir), ':p')
let directories = []
for glob in a:includes
let directories += map(filter(split(glob(base . glob), '\n'),
\ "isdirectory(v:val)"), "
\ substitute(neobundle#util#substitute_path_separator(
\ fnamemodify(v:val, ':p')), '/$', '', '')")
endfor
for dir in neobundle#util#uniq(directories)
let options = extend({ 'local' : 1, 'base' : base }, a:options)
let name = fnamemodify(dir, ':t')
let bundle = neobundle#get(name)
if !empty(bundle) && !bundle.sourced
call extend(options, copy(bundle.orig_opts))
if bundle.lazy
let options.lazy = 1
endif
call neobundle#config#rm(bundle)
endif
call neobundle#parser#bundle([dir, options])
endfor
endfunction"}}}
function! neobundle#parser#load_toml(filename, default) abort "{{{
try
let toml = neobundle#TOML#parse_file(neobundle#util#expand(a:filename))
catch /vital: Text.TOML:/
call neobundle#util#print_error(
\ 'Invalid toml format: ' . a:filename)
call neobundle#util#print_error(v:exception)
return 1
endtry
if type(toml) != type({}) || !has_key(toml, 'plugins')
call neobundle#util#print_error(
\ 'Invalid toml file: ' . a:filename)
return 1
endif
" Parse.
for plugin in toml.plugins
if has_key(plugin, 'repository')
let plugin.repo = plugin.repository
endif
if !has_key(plugin, 'repo')
call neobundle#util#print_error(
\ 'No repository plugin data: ' . a:filename)
return 1
endif
if has_key(plugin, 'depends')
let _ = []
for depend in neobundle#util#convert2list(plugin.depends)
if type(depend) == type('') || type(depend) == type([])
call add(_, depend)
elseif type(depend) == type({})
if has_key(depend, 'repository')
let plugin.repo = plugin.repository
endif
if !has_key(depend, 'repo')
call neobundle#util#print_error(
\ 'No repository plugin data: ' . a:filename)
return 1
endif
call add(_, [depend.repo, depend])
endif
unlet depend
endfor
let plugin.depends = _
endif
let options = extend(plugin, a:default, 'keep')
" echomsg string(options)
call neobundle#parser#bundle([plugin.repo, options])
endfor
endfunction"}}}
function! neobundle#parser#path(path, ...) abort "{{{
let opts = get(a:000, 0, {})
let site = get(opts, 'site', g:neobundle#default_site)
let path = substitute(a:path, '/$', '', '')
if path !~ '^/\|^\a:' && path !~ ':'
" Add default site.
let path = site . ':' . path
endif
if has_key(opts, 'type')
let type = neobundle#config#get_types(opts.type)
let types = empty(type) ? [] : [type]
else
let detect = neobundle#config#get_types('git').detect(path, opts)
if !empty(detect)
let detect.name = neobundle#util#name_conversion(path)
return detect
endif
let types = neobundle#config#get_types()
endif
let detect = {}
for type in types
let detect = type.detect(path, opts)
if !empty(detect)
break
endif
endfor
if empty(detect) && isdirectory(path)
" Detect none type.
return { 'uri' : path, 'type' : 'none' }
endif
if !empty(detect) && !has_key(detect, 'name')
let detect.name = neobundle#util#name_conversion(path)
endif
return detect
endfunction"}}}
function! s:parse_options(opts) abort "{{{
if empty(a:opts)
return has_key(g:neobundle#default_options, '_') ?
\ copy(g:neobundle#default_options['_']) : {}
endif
if len(a:opts) == 3
" rev, default, options
let [rev, default, options] = a:opts
elseif len(a:opts) == 2 && type(a:opts[-1]) == type('')
" rev, default
let [rev, default, options] = a:opts + [{}]
elseif len(a:opts) == 2 && type(a:opts[-1]) == type({})
" rev, options
let [rev, default, options] = [a:opts[0], '', a:opts[1]]
elseif len(a:opts) == 1 && type(a:opts[-1]) == type('')
" rev
let [rev, default, options] = [a:opts[0], '', {}]
elseif len(a:opts) == 1 && type(a:opts[-1]) == type({})
" options
let [rev, default, options] = ['', '', a:opts[0]]
else
call neobundle#installer#error(
\ printf('Invalid option : "%s".', string(a:opts)))
return {}
endif
if rev != ''
let options.rev = rev
endif
if !has_key(options, 'default')
let options.default = (default == '') ? '_' : default
endif
" Set default options.
if has_key(g:neobundle#default_options, options.default)
call extend(options,
\ g:neobundle#default_options[options.default], 'keep')
endif
return options
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View 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

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,312 @@
"=============================================================================
" FILE: git.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Robert Nelson <robert@rnelson.ca>
" Copyright (C) 2010 http://github.com/gmarik
" 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
" Global options definition. "{{{
call neobundle#util#set_default(
\ 'g:neobundle#types#git#command_path', 'git')
call neobundle#util#set_default(
\ 'g:neobundle#types#git#default_protocol', 'https',
\ 'g:neobundle_default_git_protocol')
call neobundle#util#set_default(
\ 'g:neobundle#types#git#enable_submodule', 1)
call neobundle#util#set_default(
\ 'g:neobundle#types#git#clone_depth', 0,
\ 'g:neobundle_git_clone_depth')
call neobundle#util#set_default(
\ 'g:neobundle#types#git#pull_command', 'pull --ff --ff-only')
"}}}
function! neobundle#types#git#define() abort "{{{
return s:type
endfunction"}}}
let s:type = {
\ 'name' : 'git',
\ }
function! s:type.detect(path, opts) abort "{{{
if a:path =~ '^/\|^\a:/' && s:is_git_dir(a:path.'/.git')
" Local repository.
return { 'uri' : a:path, 'type' : 'git' }
elseif isdirectory(a:path)
return {}
endif
let protocol = matchstr(a:path, '^.\{-}\ze://')
if protocol == '' || a:path =~#
\'\<\%(gh\|github\|bb\|bitbucket\):\S\+'
\ || has_key(a:opts, 'type__protocol')
let protocol = get(a:opts, 'type__protocol',
\ g:neobundle#types#git#default_protocol)
endif
if protocol !=# 'https' && protocol !=# 'ssh'
call neobundle#util#print_error(
\ 'Path: ' . a:path . ' The protocol "' . protocol .
\ '" is unsecure and invalid.')
return {}
endif
if a:path !~ '/'
" www.vim.org Vim scripts.
let name = split(a:path, ':')[-1]
let uri = (protocol ==# 'ssh') ?
\ 'git@github.com:vim-scripts/' :
\ protocol . '://github.com/vim-scripts/'
let uri .= name
else
let name = substitute(split(a:path, ':')[-1],
\ '^//github.com/', '', '')
let uri = (protocol ==# 'ssh') ?
\ 'git@github.com:' . name :
\ protocol . '://github.com/'. name
endif
if a:path !~# '\<\%(gh\|github\):\S\+\|://github.com/'
let uri = s:parse_other_pattern(protocol, a:path, a:opts)
if uri == ''
" Parse failure.
return {}
endif
endif
if uri !~ '\.git\s*$'
" Add .git suffix.
let uri .= '.git'
endif
return { 'uri': uri, 'type' : 'git' }
endfunction"}}}
function! s:type.get_sync_command(bundle) abort "{{{
if !executable(g:neobundle#types#git#command_path)
return 'E: "git" command is not installed.'
endif
if !isdirectory(a:bundle.path)
let cmd = 'clone'
if g:neobundle#types#git#enable_submodule
let cmd .= ' --recursive'
endif
let depth = get(a:bundle, 'type__depth',
\ g:neobundle#types#git#clone_depth)
if depth > 0 && a:bundle.rev == '' && a:bundle.uri !~ '^git@'
let cmd .= ' --depth=' . depth
endif
let cmd .= printf(' %s "%s"', a:bundle.uri, a:bundle.path)
else
let cmd = g:neobundle#types#git#pull_command
if g:neobundle#types#git#enable_submodule
let shell = fnamemodify(split(&shell)[0], ':t')
let and = (!neobundle#util#has_vimproc() && shell ==# 'fish') ?
\ '; and ' : ' && '
let cmd .= and . g:neobundle#types#git#command_path
\ . ' submodule update --init --recursive'
endif
endif
return g:neobundle#types#git#command_path . ' ' . cmd
endfunction"}}}
function! s:type.get_revision_number_command(bundle) abort "{{{
if !executable(g:neobundle#types#git#command_path)
return ''
endif
return g:neobundle#types#git#command_path .' rev-parse HEAD'
endfunction"}}}
function! s:type.get_revision_pretty_command(bundle) abort "{{{
if !executable(g:neobundle#types#git#command_path)
return ''
endif
return g:neobundle#types#git#command_path .
\ ' log -1 --pretty=format:"%h [%cr] %s"'
endfunction"}}}
function! s:type.get_commit_date_command(bundle) abort "{{{
if !executable(g:neobundle#types#git#command_path)
return ''
endif
return g:neobundle#types#git#command_path .
\ ' log -1 --pretty=format:"%ct"'
endfunction"}}}
function! s:type.get_log_command(bundle, new_rev, old_rev) abort "{{{
if !executable(g:neobundle#types#git#command_path)
\ || a:new_rev == '' || a:old_rev == ''
return ''
endif
" Note: If the a:old_rev is not the ancestor of two branchs. Then do not use
" %s^. use %s^ will show one commit message which already shown last time.
let is_not_ancestor = neobundle#util#system(
\ g:neobundle#types#git#command_path . ' merge-base '
\ . a:old_rev . ' ' . a:new_rev) ==# a:old_rev
return printf(g:neobundle#types#git#command_path .
\ ' log %s%s..%s --graph --pretty=format:"%%h [%%cr] %%s"',
\ a:old_rev, (is_not_ancestor ? '' : '^'), a:new_rev)
" Test.
" return g:neobundle#types#git#command_path .
" \ ' log HEAD^^^^..HEAD --graph --pretty=format:"%h [%cr] %s"'
endfunction"}}}
function! s:type.get_revision_lock_command(bundle) abort "{{{
if !executable(g:neobundle#types#git#command_path)
return ''
endif
let rev = a:bundle.rev
if rev ==# 'release'
" Use latest released tag
let rev = neobundle#installer#get_release_revision(a:bundle,
\ g:neobundle#types#git#command_path . ' tag')
endif
if rev == ''
" Fix detach HEAD.
let rev = 'master'
endif
return g:neobundle#types#git#command_path . ' checkout ' . rev
endfunction"}}}
function! s:type.get_gc_command(bundle) abort "{{{
if !executable(g:neobundle#types#git#command_path)
return ''
endif
return g:neobundle#types#git#command_path .' gc'
endfunction"}}}
function! s:type.get_revision_remote_command(bundle) abort "{{{
if !executable(g:neobundle#types#git#command_path)
return ''
endif
let rev = a:bundle.rev
if rev == ''
let rev = 'HEAD'
endif
return g:neobundle#types#git#command_path
\ .' ls-remote origin ' . rev
endfunction"}}}
function! s:type.get_fetch_remote_command(bundle) abort "{{{
if !executable(g:neobundle#types#git#command_path)
return ''
endif
return g:neobundle#types#git#command_path
\ .' fetch origin '
endfunction"}}}
function! s:parse_other_pattern(protocol, path, opts) abort "{{{
let uri = ''
if a:path =~# '\<gist:\S\+\|://gist.github.com/'
let name = split(a:path, ':')[-1]
let uri = (a:protocol ==# 'ssh') ?
\ 'git@gist.github.com:' . split(name, '/')[-1] :
\ a:protocol . '://gist.github.com/'. split(name, '/')[-1]
elseif a:path =~# '\<git@\S\+'
\ || a:path =~# '\.git\s*$'
\ || get(a:opts, 'type', '') ==# 'git'
if a:path =~# '\<\%(bb\|bitbucket\):\S\+'
let name = substitute(split(a:path, ':')[-1],
\ '^//bitbucket.org/', '', '')
let uri = (a:protocol ==# 'ssh') ?
\ 'git@bitbucket.org:' . name :
\ a:protocol . '://bitbucket.org/' . name
else
let uri = a:path
endif
endif
return uri
endfunction"}}}
function! s:is_git_dir(path) abort "{{{
if isdirectory(a:path)
let git_dir = a:path
elseif filereadable(a:path)
" check if this is a gitdir file
" File starts with "gitdir: " and all text after this string is treated
" as the path. Any CR or NLs are stripped off the end of the file.
let buf = join(readfile(a:path, 'b'), "\n")
let matches = matchlist(buf, '\C^gitdir: \(\_.*[^\r\n]\)[\r\n]*$')
if empty(matches)
return 0
endif
let path = fnamemodify(a:path, ':h')
if fnamemodify(a:path, ':t') == ''
" if there's no tail, the path probably ends in a directory separator
let path = fnamemodify(path, ':h')
endif
let git_dir = neobundle#util#join_paths(path, matches[1])
if !isdirectory(git_dir)
return 0
endif
else
return 0
endif
" Git only considers it to be a git dir if a few required files/dirs exist
" and are accessible inside the directory.
" Note: we can't actually test file permissions the way we'd like to, since
" getfperm() gives the mode string but doesn't tell us whether the user or
" group flags apply to us. Instead, just check if dirname/. is a directory.
" This should also check if we have search permissions.
" I'm assuming here that dirname/. works on windows, since I can't test.
" Note: Git also accepts having the GIT_OBJECT_DIRECTORY env var set instead
" of using .git/objects, but we don't care about that.
for name in ['objects', 'refs']
if !isdirectory(neobundle#util#join_paths(git_dir, name))
return 0
endif
endfor
" Git also checks if HEAD is a symlink or a properly-formatted file.
" We don't really care to actually validate this, so let's just make
" sure the file exists and is readable.
" Note: it may also be a symlink, which can point to a path that doesn't
" necessarily exist yet.
let head = neobundle#util#join_paths(git_dir, 'HEAD')
if !filereadable(head) && getftype(head) != 'link'
return 0
endif
" Sure looks like a git directory. There's a few subtleties where we'll
" accept a directory that git itself won't, but I think we can safely ignore
" those edge cases.
return 1
endfunction "}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View file

@ -0,0 +1,119 @@
"=============================================================================
" FILE: hg.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
" Global options definition. "{{{
call neobundle#util#set_default(
\ 'g:neobundle#types#hg#command_path', 'hg')
call neobundle#util#set_default(
\ 'g:neobundle#types#hg#default_protocol', 'https',
\ 'g:neobundle_default_hg_protocol')
"}}}
function! neobundle#types#hg#define() abort "{{{
return s:type
endfunction"}}}
let s:type = {
\ 'name' : 'hg',
\ }
function! s:type.detect(path, opts) abort "{{{
if isdirectory(a:path.'/.hg')
" Local repository.
return { 'uri' : a:path, 'type' : 'hg' }
elseif isdirectory(a:path)
return {}
endif
let protocol = matchstr(a:path, '^.\{-}\ze://')
if protocol == '' || a:path =~#
\'\<\%(bb\|bitbucket\):\S\+'
\ || has_key(a:opts, 'type__protocol')
let protocol = get(a:opts, 'type__protocol',
\ g:neobundle#types#hg#default_protocol)
endif
if protocol !=# 'https' && protocol !=# 'ssh'
call neobundle#util#print_error(
\ 'Path: ' . a:path . ' The protocol "' . protocol .
\ '" is unsecure and invalid.')
return {}
endif
if a:path =~# '\<\%(bb\|bitbucket\):'
let name = substitute(split(a:path, ':')[-1],
\ '^//bitbucket.org/', '', '')
let uri = (protocol ==# 'ssh') ?
\ 'ssh://hg@bitbucket.org/' . name :
\ protocol . '://bitbucket.org/' . name
elseif a:path =~? '[/.]hg[/.@]'
\ || (a:path =~# '\<https://bitbucket\.org/'
\ || get(a:opts, 'type', '') ==# 'hg')
let uri = a:path
else
return {}
endif
return { 'uri' : uri, 'type' : 'hg' }
endfunction"}}}
function! s:type.get_sync_command(bundle) abort "{{{
if !executable(g:neobundle#types#hg#command_path)
return 'E: "hg" command is not installed.'
endif
if !isdirectory(a:bundle.path)
let cmd = 'clone'
let cmd .= printf(' %s "%s"', a:bundle.uri, a:bundle.path)
else
let cmd = 'pull -u'
endif
return g:neobundle#types#hg#command_path . ' ' . cmd
endfunction"}}}
function! s:type.get_revision_number_command(bundle) abort "{{{
if !executable(g:neobundle#types#hg#command_path)
return ''
endif
return g:neobundle#types#hg#command_path
\ . ' heads --quiet --rev default'
endfunction"}}}
function! s:type.get_revision_lock_command(bundle) abort "{{{
if !executable(g:neobundle#types#hg#command_path)
\ || a:bundle.rev == ''
return ''
endif
return g:neobundle#types#hg#command_path
\ . ' up ' . a:bundle.rev
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View file

@ -0,0 +1,75 @@
"=============================================================================
" FILE: none.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#types#none#define() abort "{{{
return s:type
endfunction"}}}
let s:type = {
\ 'name' : 'none',
\ }
function! s:type.detect(path, opts) abort "{{{
" No Auto detect.
return {}
endfunction"}}}
function! s:type.get_sync_command(bundle) abort "{{{
if isdirectory(a:bundle.path)
return ''
endif
" Try auto install.
let path = a:bundle.orig_path
let site = get(a:bundle, 'site', g:neobundle#default_site)
if path !~ '^/\|^\a:' && path !~ ':'
" Add default site.
let path = site . ':' . path
endif
for type in neobundle#config#get_types()
let detect = type.detect(path, a:bundle.orig_opts)
if !empty(detect)
return type.get_sync_command(
\ extend(copy(a:bundle), detect))
endif
endfor
return 'E: Failed to auto installation.'
endfunction"}}}
function! s:type.get_revision_number_command(bundle) abort "{{{
return ''
endfunction"}}}
function! s:type.get_revision_lock_command(bundle) abort "{{{
return ''
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View file

@ -0,0 +1,116 @@
"=============================================================================
" FILE: raw.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
" Global options definition. "{{{
call neobundle#util#set_default(
\ 'g:neobundle#types#raw#calc_hash_command',
\ executable('sha1sum') ? 'sha1sum' :
\ executable('md5sum') ? 'md5sum' : '')
"}}}
function! neobundle#types#raw#define() abort "{{{
return s:type
endfunction"}}}
let s:type = {
\ 'name' : 'raw',
\ }
function! s:type.detect(path, opts) abort "{{{
" No auto detect.
let type = ''
let name = ''
if a:path =~# '^https:.*\.vim$'
" HTTPS
let name = neobundle#util#name_conversion(a:path)
let type = 'raw'
elseif a:path =~#
\ '^https://www\.vim\.org/scripts/download_script.php?src_id=\d\+$'
" For www.vim.org
let name = 'vim-scripts-' . matchstr(a:path, '\d\+$')
let type = 'raw'
endif
return type == '' ? {} :
\ { 'name': name, 'uri' : a:path, 'type' : type }
endfunction"}}}
function! s:type.get_sync_command(bundle) abort "{{{
if a:bundle.script_type == ''
return 'E: script_type is not found.'
endif
let path = a:bundle.path
if !isdirectory(path)
" Create script type directory.
call mkdir(path, 'p')
endif
let filename = path . '/' . get(a:bundle,
\ 'type__filename', fnamemodify(a:bundle.uri, ':t'))
let a:bundle.type__filepath = filename
let cmd = neobundle#util#wget(a:bundle.uri, filename)
return cmd
endfunction"}}}
function! s:type.get_revision_number_command(bundle) abort "{{{
if g:neobundle#types#raw#calc_hash_command == ''
return ''
endif
if !filereadable(a:bundle.type__filepath)
" Not Installed.
return ''
endif
" Calc hash.
return printf('%s %s',
\ g:neobundle#types#raw#calc_hash_command,
\ a:bundle.type__filepath)
endfunction"}}}
function! s:type.get_revision_lock_command(bundle) abort "{{{
let new_rev = matchstr(a:bundle.new_rev, '^\S\+')
if a:bundle.rev != '' && new_rev != '' &&
\ new_rev !=# a:bundle.rev
" Revision check.
return printf('E: revision digest is not matched : "%s"(got) and "%s"(rev).',
\ new_rev, a:bundle.rev)
endif
" Not supported.
return ''
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View file

@ -0,0 +1,93 @@
"=============================================================================
" FILE: svn.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
" Global options definition. "{{{
call neobundle#util#set_default(
\ 'g:neobundle#types#svn#command_path', 'svn')
"}}}
function! neobundle#types#svn#define() abort "{{{
return s:type
endfunction"}}}
let s:type = {
\ 'name' : 'svn',
\ }
function! s:type.detect(path, opts) abort "{{{
if isdirectory(a:path)
return {}
endif
let type = ''
let uri = ''
if (a:path =~# '\<\%(file\|https\)://'
\ && a:path =~? '[/.]svn[/.]')
\ || a:path =~# '\<svn+ssh://'
let uri = a:path
let type = 'svn'
endif
return type == '' ? {} : { 'uri': uri, 'type' : type }
endfunction"}}}
function! s:type.get_sync_command(bundle) abort "{{{
if !executable(g:neobundle#types#svn#command_path)
return 'E: svn command is not installed.'
endif
if !isdirectory(a:bundle.path)
let cmd = 'checkout'
let cmd .= printf(' %s "%s"', a:bundle.uri, a:bundle.path)
else
let cmd = 'up'
endif
return g:neobundle#types#svn#command_path . ' ' . cmd
endfunction"}}}
function! s:type.get_revision_number_command(bundle) abort "{{{
if !executable(g:neobundle#types#svn#command_path)
return ''
endif
return g:neobundle#types#svn#command_path . ' info'
endfunction"}}}
function! s:type.get_revision_lock_command(bundle) abort "{{{
if !executable(g:neobundle#types#svn#command_path)
\ || a:bundle.rev == ''
return ''
endif
return g:neobundle#types#svn#command_path
\ . ' up -r ' . a:bundle.rev
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View file

@ -0,0 +1,146 @@
"=============================================================================
" FILE: vba.vim
" AUTHOR: Yu Huang <paulhybryant@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
" Global options definition. "{{{
call neobundle#util#set_default(
\ 'g:neobundle#types#vba#calc_hash_command',
\ executable('sha1sum') ? 'sha1sum' :
\ executable('md5sum') ? 'md5sum' : '')
"}}}
function! neobundle#types#vba#define() abort "{{{
return s:type
endfunction"}}}
let s:type = {
\ 'name' : 'vba',
\ }
function! s:type.detect(path, opts) abort "{{{
" No auto detect.
let type = ''
let name = ''
if a:path =~# '^https:.*\.vba\(\.gz\)\?$'
" HTTPS
" .*.vba / .*.vba.gz
let name = fnamemodify(split(a:path, ':')[-1],
\ ':s?/$??:t:s?\c\.vba\(\.gz\)*\s*$??')
let type = 'vba'
elseif a:path =~# '\.vba\(\.gz\)\?$' && filereadable(a:path)
" local
" .*.vba
let name = fnamemodify(a:path, ':t:s?\c\.vba\(\.gz\)*\s*$??')
let type = 'vba'
endif
if a:path =~# '^https:.*\.vmb$'
" HTTPS
" .*.vmb
let name = fnamemodify(split(a:path, ':')[-1],
\ ':s?/$??:t:s?\c\.vba\s*$??')
let type = 'vba'
elseif a:path =~# '\.vmb$' && filereadable(a:path)
" local
" .*.vmb
let name = fnamemodify(a:path, ':t:s?\c\.vba\s*$??')
let type = 'vba'
endif
return type == '' ? {} :
\ { 'name': name, 'uri' : a:path, 'type' : type }
endfunction"}}}
function! s:type.get_sync_command(bundle) abort "{{{
let path = a:bundle.path
if !isdirectory(path)
" Create script type directory.
call mkdir(path, 'p')
endif
let filename = path . '/' . get(a:bundle,
\ 'type__filename', fnamemodify(a:bundle.uri, ':t'))
let a:bundle.type__filepath = filename
let cmd = ''
if filereadable(a:bundle.uri)
call writefile(readfile(a:bundle.uri, 'b'), filename, 'b')
else
let cmd = neobundle#util#wget(a:bundle.uri, filename)
if cmd =~# '^E:'
return cmd
endif
let cmd .= ' && '
endif
let cmd .= printf('%s -u NONE' .
\ ' -c "set nocompatible"' .
\ ' -c "filetype plugin on"' .
\ ' -c "runtime plugin/gzip.vim"' .
\ ' -c "runtime plugin/vimballPlugin.vim"' .
\ ' -c "edit %s"' .
\ ' -c "UseVimball %s"' .
\ ' -c "q"', v:progpath, filename, path)
" let cmd .= printf(' rm %s &&', filename)
" let cmd .= printf(' rm %s/.VimballRecord', path)
return cmd
endfunction"}}}
function! s:type.get_revision_number_command(bundle) abort "{{{
if g:neobundle#types#vba#calc_hash_command == ''
return ''
endif
if !has_key(a:bundle, 'type__filepath')
\ || !filereadable(a:bundle.type__filepath)
" Not Installed.
return ''
endif
" Calc hash.
return printf('%s %s',
\ g:neobundle#types#vba#calc_hash_command,
\ a:bundle.type__filepath)
endfunction"}}}
function! s:type.get_revision_lock_command(bundle) abort "{{{
let new_rev = matchstr(a:bundle.new_rev, '^\S\+')
if a:bundle.rev != '' && new_rev != '' &&
\ new_rev !=# a:bundle.rev
" Revision check.
return printf('E: revision digest is not matched : "%s"(got) and "%s"(rev).',
\ new_rev, a:bundle.rev)
endif
" Not supported.
return ''
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,106 @@
"=============================================================================
" FILE: neobundle.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! unite#kinds#neobundle#define() abort "{{{
return s:kind
endfunction"}}}
let s:kind = {
\ 'name' : 'neobundle',
\ 'action_table': {},
\ 'parents' : ['uri', 'directory'],
\ 'default_action' : 'update',
\}
" Actions "{{{
let s:kind.action_table.update = {
\ 'description' : 'update bundles',
\ 'is_selectable' : 1,
\ 'is_start' : 1,
\ }
function! s:kind.action_table.update.func(candidates) abort "{{{
call unite#start_script([['neobundle/update', '!']
\ + map(copy(a:candidates), 'v:val.action__bundle_name')],
\ { 'log' : 1 })
endfunction"}}}
let s:kind.action_table.delete = {
\ 'description' : 'delete bundles',
\ 'is_invalidate_cache' : 1,
\ 'is_quit' : 0,
\ 'is_selectable' : 1,
\ }
function! s:kind.action_table.delete.func(candidates) abort "{{{
call call('neobundle#commands#clean', insert(map(copy(a:candidates),
\ 'v:val.action__bundle_name'), 0))
endfunction"}}}
let s:kind.action_table.reinstall = {
\ 'description' : 'reinstall bundles',
\ 'is_selectable' : 1,
\ }
function! s:kind.action_table.reinstall.func(candidates) abort "{{{
call neobundle#installer#reinstall(
\ map(copy(a:candidates), 'v:val.action__bundle'))
endfunction"}}}
let s:kind.action_table.preview = {
\ 'description' : 'view the plugin documentation',
\ 'is_quit' : 0,
\ }
function! s:kind.action_table.preview.func(candidate) abort "{{{
" Search help files.
let readme = get(split(globpath(
\ a:candidate.action__path, 'doc/*.?*', 1), '\n'), 0, '')
if readme == ''
" Search README files.
let readme = get(split(globpath(
\ a:candidate.action__path, 'README*', 1), '\n'), 0, '')
if readme == ''
return
endif
endif
let buflisted = buflisted(
\ unite#util#escape_file_searching(readme))
execute 'pedit' fnameescape(readme)
" Open folds.
normal! zv
normal! zt
if !buflisted
call unite#add_previewed_buffer_list(
\ bufnr(unite#util#escape_file_searching(readme)))
endif
endfunction"}}}
"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View file

@ -0,0 +1,143 @@
"=============================================================================
" FILE: neobundle.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! unite#sources#neobundle#define() abort "{{{
return s:source
endfunction"}}}
let s:source = {
\ 'name' : 'neobundle',
\ 'description' : 'candidates from bundles',
\ 'hooks' : {},
\ }
function! s:source.hooks.on_init(args, context) abort "{{{
let bundle_names = filter(copy(a:args), 'v:val != "!"')
let a:context.source__bang =
\ index(a:args, '!') >= 0
let a:context.source__bundles = neobundle#util#sort_by(
\ (empty(bundle_names) ?
\ neobundle#config#get_neobundles() :
\ neobundle#config#search(bundle_names)),
\ 'tolower(v:val.orig_name)')
endfunction"}}}
" Filters "{{{
function! s:source.source__converter(candidates, context) abort "{{{
for candidate in a:candidates
if candidate.source__uri =~
\ '^\%(https\?\|git\)://github.com/'
let candidate.action__uri = candidate.source__uri
let candidate.action__uri =
\ substitute(candidate.action__uri, '^git://', 'https://', '')
let candidate.action__uri =
\ substitute(candidate.action__uri, '.git$', '', '')
endif
endfor
return a:candidates
endfunction"}}}
let s:source.converters = s:source.source__converter
"}}}
function! s:source.gather_candidates(args, context) abort "{{{
let _ = map(copy(a:context.source__bundles), "{
\ 'word' : substitute(v:val.orig_name,
\ '^\%(https\?\|git\)://\%(github.com/\)\?', '', ''),
\ 'kind' : 'neobundle',
\ 'action__path' : v:val.path,
\ 'action__directory' : v:val.path,
\ 'action__bundle' : v:val,
\ 'action__bundle_name' : v:val.name,
\ 'source__uri' : v:val.uri,
\ 'source__description' : v:val.description,
\ 'is_multiline' : 1,
\ }
\")
let max = max(map(copy(_), 'len(v:val.word)'))
call unite#print_source_message(
\ '#: not sourced, X: not installed', self.name)
for candidate in _
let candidate.abbr =
\ neobundle#is_sourced(candidate.action__bundle_name) ? ' ' :
\ neobundle#is_installed(candidate.action__bundle_name) ? '#' : 'X'
let candidate.abbr .= ' ' . unite#util#truncate(candidate.word, max)
if candidate.source__description != ''
let candidate.abbr .= ' : ' . candidate.source__description
endif
if a:context.source__bang
let status = s:get_commit_status(candidate.action__bundle)
if status != ''
let candidate.abbr .= "\n " . status
endif
endif
let candidate.word .= candidate.source__description
endfor
return _
endfunction"}}}
function! s:get_commit_status(bundle) abort "{{{
if !isdirectory(a:bundle.path)
return 'Not installed'
endif
let type = neobundle#config#get_types(a:bundle.type)
let cmd = has_key(type, 'get_revision_pretty_command') ?
\ type.get_revision_pretty_command(a:bundle) :
\ type.get_revision_number_command(a:bundle)
if cmd == ''
return ''
endif
let cwd = getcwd()
try
call neobundle#util#cd(a:bundle.path)
let output = neobundle#util#system(cmd)
finally
call neobundle#util#cd(cwd)
endtry
if neobundle#util#get_last_status()
return printf('Error(%d) occurred when executing "%s"',
\ neobundle#util#get_last_status(), cmd)
endif
return output
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View file

@ -0,0 +1,190 @@
"=============================================================================
" FILE: neobundle/install.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! unite#sources#neobundle_install#define() abort "{{{
return [s:source_install, s:source_update]
endfunction"}}}
let s:source_install = {
\ 'name' : 'neobundle/install',
\ 'description' : 'install bundles',
\ 'hooks' : {},
\ 'default_kind' : 'word',
\ 'syntax' : 'uniteSource__NeoBundleInstall',
\ }
function! s:source_install.hooks.on_init(args, context) abort "{{{
let bundle_names = filter(copy(a:args), "v:val != '!'")
let a:context.source__bang =
\ index(a:args, '!') >= 0 || !empty(bundle_names)
let a:context.source__not_fuzzy = 0
call s:init(a:context, bundle_names)
endfunction"}}}
function! s:source_install.hooks.on_syntax(args, context) abort "{{{
syntax match uniteSource__NeoBundleInstall_Progress /(.\{-}):\s*.*/
\ contained containedin=uniteSource__NeoBundleInstall
highlight default link uniteSource__NeoBundleInstall_Progress String
syntax match uniteSource__NeoBundleInstall_Source /|.\{-}|/
\ contained containedin=uniteSource__NeoBundleInstall_Progress
highlight default link uniteSource__NeoBundleInstall_Source Type
syntax match uniteSource__NeoBundleInstall_URI /-> diff URI/
\ contained containedin=uniteSource__NeoBundleInstall
highlight default link uniteSource__NeoBundleInstall_URI Underlined
endfunction"}}}
function! s:source_install.hooks.on_close(args, context) abort "{{{
if !empty(a:context.source__processes)
for process in a:context.source__processes
if has('nvim')
call jobstop(process.proc)
else
call process.proc.waitpid()
endif
endfor
endif
endfunction"}}}
function! s:source_install.async_gather_candidates(args, context) abort "{{{
if !a:context.sync && empty(filter(range(1, winnr('$')),
\ "getwinvar(v:val, '&l:filetype') ==# 'unite'"))
return []
endif
let old_msgs = copy(neobundle#installer#get_updates_log())
if a:context.source__number < a:context.source__max_bundles
while a:context.source__number < a:context.source__max_bundles
\ && len(a:context.source__processes) <
\ g:neobundle#install_max_processes
let bundle = a:context.source__bundles[a:context.source__number]
call neobundle#installer#sync(bundle, a:context, 1)
call unite#clear_message()
call unite#print_source_message(
\ neobundle#installer#get_progress_message(bundle,
\ a:context.source__number,
\ a:context.source__max_bundles), self.name)
redrawstatus
endwhile
endif
if !empty(a:context.source__processes)
for process in a:context.source__processes
call neobundle#installer#check_output(a:context, process, 1)
endfor
" Filter eof processes.
call filter(a:context.source__processes, '!v:val.eof')
else
call neobundle#installer#update_log(
\ neobundle#installer#get_updated_bundles_message(
\ a:context.source__synced_bundles), 1)
call neobundle#installer#update_log(
\ neobundle#installer#get_errored_bundles_message(
\ a:context.source__errored_bundles), 1)
call neobundle#installer#update(
\ a:context.source__synced_bundles)
" Finish.
call neobundle#installer#update_log('Completed.', 1)
let a:context.is_async = 0
endif
return map(neobundle#installer#get_updates_log()[len(old_msgs) :], "{
\ 'word' : (v:val =~ '^\\s*\\h\\w*://' ? ' -> diff URI' : v:val),
\ 'is_multiline' : 1,
\ 'kind' : (v:val =~ '^\\s*\\h\\w*://' ? 'uri' : 'word'),
\ 'action__uri' : substitute(v:val, '^\\s\\+', '', ''),
\}")
endfunction"}}}
function! s:source_install.complete(args, context, arglead, cmdline, cursorpos) abort "{{{
return ['!'] +
\ neobundle#commands#complete_bundles(a:arglead, a:cmdline, a:cursorpos)
endfunction"}}}
let s:source_update = deepcopy(s:source_install)
let s:source_update.name = 'neobundle/update'
let s:source_update.description = 'update bundles'
function! s:source_update.hooks.on_init(args, context) abort "{{{
let a:context.source__bang =
\ index(a:args, 'all') >= 0 ? 2 : 1
let a:context.source__not_fuzzy = index(a:args, '!') >= 0
let bundle_names = filter(copy(a:args),
\ "v:val !=# 'all' && v:val !=# '!'")
call s:init(a:context, bundle_names)
endfunction"}}}
function! s:init(context, bundle_names) abort "{{{
let a:context.source__synced_bundles = []
let a:context.source__errored_bundles = []
let a:context.source__processes = []
let a:context.source__number = 0
let a:context.source__bundles = !a:context.source__bang ?
\ neobundle#get_force_not_installed_bundles(a:bundle_names) :
\ empty(a:bundle_names) ?
\ neobundle#config#get_enabled_bundles() :
\ a:context.source__not_fuzzy ?
\ neobundle#config#search(a:bundle_names) :
\ neobundle#config#fuzzy_search(a:bundle_names)
call neobundle#installer#_load_install_info(
\ a:context.source__bundles)
let reinstall_bundles =
\ neobundle#installer#get_reinstall_bundles(
\ a:context.source__bundles)
if !empty(reinstall_bundles)
call neobundle#installer#reinstall(reinstall_bundles)
endif
let a:context.source__max_bundles =
\ len(a:context.source__bundles)
call neobundle#installer#clear_log()
if empty(a:context.source__bundles)
let a:context.is_async = 0
call neobundle#installer#error(
\ 'Target bundles not found. You may use wrong bundle name.')
else
call neobundle#installer#update_log(
\ 'Update started: ' . strftime('(%Y/%m/%d %H:%M:%S)'))
endif
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View file

@ -0,0 +1,76 @@
"=============================================================================
" FILE: neobundle_lazy.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! unite#sources#neobundle_lazy#define() abort "{{{
return s:source
endfunction"}}}
let s:source = {
\ 'name' : 'neobundle/lazy',
\ 'description' : 'candidates from lazy bundles',
\ 'action_table' : {},
\ 'default_action' : 'source',
\ }
function! s:source.gather_candidates(args, context) abort "{{{
let _ = []
for bundle in filter(copy(neobundle#config#get_neobundles()),
\ '!v:val.sourced')
let name = substitute(bundle.orig_name,
\ '^\%(https\?\|git\)://\%(github.com/\)\?', '', '')
let dict = {
\ 'word' : name,
\ 'kind' : 'neobundle',
\ 'action__path' : bundle.path,
\ 'action__directory' : bundle.path,
\ 'action__bundle' : bundle,
\ 'action__bundle_name' : bundle.name,
\ 'source__uri' : bundle.uri,
\ }
call add(_, dict)
endfor
return _
endfunction"}}}
" Actions "{{{
let s:source.action_table.source = {
\ 'description' : 'source bundles',
\ 'is_selectable' : 1,
\ 'is_invalidate_cache' : 1,
\ }
function! s:source.action_table.source.func(candidates) abort "{{{
call call('neobundle#config#source',
\ map(copy(a:candidates), 'v:val.action__bundle_name'))
endfunction"}}}
"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View file

@ -0,0 +1,66 @@
"=============================================================================
" FILE: neobundle/log.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! unite#sources#neobundle_log#define() abort "{{{
return s:source
endfunction"}}}
let s:source = {
\ 'name' : 'neobundle/log',
\ 'description' : 'print previous neobundle install logs',
\ 'syntax' : 'uniteSource__NeoBundleLog',
\ 'hooks' : {},
\ }
function! s:source.hooks.on_syntax(args, context) abort "{{{
syntax match uniteSource__NeoBundleLog_Message /.*/
\ contained containedin=uniteSource__NeoBundleLog
highlight default link uniteSource__NeoBundleLog_Message Comment
syntax match uniteSource__NeoBundleLog_Progress /(.\{-}):\s*.*/
\ contained containedin=uniteSource__NeoBundleLog
highlight default link uniteSource__NeoBundleLog_Progress String
syntax match uniteSource__NeoBundleLog_Source /|.\{-}|/
\ contained containedin=uniteSource__NeoBundleLog_Progress
highlight default link uniteSource__NeoBundleLog_Source Type
syntax match uniteSource__NeoBundleLog_URI /-> diff URI/
\ contained containedin=uniteSource__NeoBundleLog
highlight default link uniteSource__NeoBundleLog_URI Underlined
endfunction"}}}
function! s:source.gather_candidates(args, context) abort "{{{
return map(copy(neobundle#installer#get_log()), "{
\ 'word' : (v:val =~ '^\\s*\\h\\w*://' ? ' -> diff URI' : v:val),
\ 'kind' : (v:val =~ '^\\s*\\h\\w*://' ? 'uri' : 'word'),
\ 'action__uri' : substitute(v:val, '^\\s\\+', '', ''),
\ }")
endfunction"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker

View file

@ -0,0 +1,265 @@
"=============================================================================
" FILE: neobundle_search.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()
function! unite#sources#neobundle_search#define() abort "{{{
" Init sources.
if !exists('s:neobundle_sources')
let s:neobundle_sources = {}
for define in map(split(globpath(&runtimepath,
\ 'autoload/neobundle/sources/*.vim', 1), '\n'),
\ "neobundle#sources#{fnamemodify(v:val, ':t:r')}#define()")
for dict in (type(define) == type([]) ? define : [define])
if !empty(dict) && !has_key(s:neobundle_sources, dict.name)
let s:neobundle_sources[dict.name] = dict
endif
endfor
unlet define
endfor
endif
return s:source
endfunction"}}}
let s:plugin_names = []
" Source rec.
let s:source = {
\ 'name' : 'neobundle/search',
\ 'description' : 'search plugins for neobundle',
\ 'hooks' : {},
\ 'action_table' : {},
\ 'default_action' : 'yank',
\ 'max_candidates' : 200,
\ 'syntax' : 'uniteSource__NeoBundleSearch',
\ 'parents' : ['uri'],
\ }
function! s:source.hooks.on_init(args, context) abort "{{{
let a:context.source__sources = copy(s:neobundle_sources)
if !empty(a:args)
let a:context.source__sources = filter(
\ a:context.source__sources,
\ 'index(a:args, v:key) >= 0')
endif
let a:context.source__input = a:context.input
if a:context.source__input == ''
let a:context.source__input =
\ unite#util#input('Please input search word: ', '',
\ 'customlist,unite#sources#neobundle_search#complete_plugin_names')
endif
endfunction"}}}
function! s:source.gather_candidates(args, context) abort "{{{
if neobundle#util#is_sudo()
call neobundle#util#print_error(
\ '"sudo vim" is detected. This feature is disabled.')
return []
endif
call unite#print_source_message('Search word: '
\ . a:context.source__input, s:source.name)
let candidates = []
let a:context.source__source_names = []
let s:plugin_names = []
for source in values(a:context.source__sources)
let source_candidates = source.gather_candidates(a:args, a:context)
let source_name = get(source, 'short_name', source.name)
for candidate in source_candidates
let candidate.source__source = source_name
if !has_key(candidate, 'source__script_type')
let candidate.source__script_type = ''
endif
if !has_key(candidate, 'source__description')
let candidate.source__description = ''
endif
endfor
let candidates += source_candidates
call add(a:context.source__source_names, source_name)
let s:plugin_names += map(copy(source_candidates), 'v:val.source__name')
endfor
call s:initialize_plugin_names(a:context)
return filter(candidates,
\ 'stridx(v:val.word, a:context.source__input) >= 0')
endfunction"}}}
function! s:source.complete(args, context, arglead, cmdline, cursorpos) abort "{{{
let arglead = get(a:args, -1, '')
return filter(keys(s:neobundle_sources),
\ "stridx(v:val, arglead) == 0")
endfunction"}}}
function! s:source.hooks.on_syntax(args, context) abort "{{{
syntax match uniteSource__NeoBundleSearch_DescriptionLine
\ / -- .*$/
\ contained containedin=uniteSource__NeoBundleSearch
syntax match uniteSource__NeoBundleSearch_Description
\ /.*$/
\ contained containedin=uniteSource__NeoBundleSearch_DescriptionLine
syntax match uniteSource__NeoBundleSearch_Marker
\ / -- /
\ contained containedin=uniteSource__NeoBundleSearch_DescriptionLine
syntax match uniteSource__NeoBundleSearch_Install
\ / Installed /
\ contained containedin=uniteSource__NeoBundleSearch
highlight default link uniteSource__NeoBundleSearch_Install Statement
highlight default link uniteSource__NeoBundleSearch_Marker Special
highlight default link uniteSource__NeoBundleSearch_Description Comment
endfunction"}}}
" Actions "{{{
let s:source.action_table.yank = {
\ 'description' : 'yank plugin settings',
\ 'is_selectable' : 1,
\ }
function! s:source.action_table.yank.func(candidates) abort "{{{
let @" = join(map(a:candidates,
\ "'NeoBundle ' . s:get_neobundle_args(v:val)"), "\n")
if has('clipboard')
call setreg(v:register, @")
endif
echo 'Yanked plugin settings!'
endfunction"}}}
let s:source.action_table.install = {
\ 'description' : 'direct install plugins',
\ 'is_selectable' : 1,
\ 'is_quit' : 0,
\ }
function! s:source.action_table.install.func(candidates) abort "{{{
for candidate in a:candidates
execute 'NeoBundleDirectInstall' s:get_neobundle_args(candidate)
endfor
endfunction"}}}
"}}}
" Filters "{{{
function! s:source.source__sorter(candidates, context) abort "{{{
return s:sort_by(a:candidates, 'v:val.source__name')
endfunction"}}}
function! s:source.source__converter(candidates, context) abort "{{{
let max_plugin_name = max(map(copy(a:candidates),
\ 'len(v:val.source__name)'))
let max_script_type = max(map(copy(a:candidates),
\ 'len(v:val.source__script_type)'))
let max_source_name = max(map(copy(a:context.source__source_names),
\ 'len(v:val)'))
let format = '%-'. max_plugin_name .'s %-'.
\ max_source_name .'s %-'. max_script_type .'s -- %s'
for candidate in a:candidates
let candidate.abbr = printf(format,
\ candidate.source__name, candidate.source__source,
\ candidate.source__script_type,
\ (neobundle#is_installed(candidate.source__name) ?
\ 'Installed' : candidate.source__description))
let candidate.is_multiline = 1
let candidate.kind =
\ get(candidate, 'action__path', '') != '' ?
\ 'file' : 'common'
endfor
return a:candidates
endfunction"}}}
let s:source.sorters = s:source.source__sorter
let s:source.converters = s:source.source__converter
"}}}
" Misc. "{{{
function! s:sort_by(list, expr) abort
let pairs = map(a:list, printf('[v:val, %s]', a:expr))
return map(s:sort(pairs,
\ 'a:a[1] == a:b[1] ? 0 : a:a[1] > a:b[1] ? 1 : -1'), 'v:val[0]')
endfunction
" Sorts a list with expression to compare each two values.
" a:a and a:b can be used in {expr}.
function! s:sort(list, expr) abort
if type(a:expr) == type(function('function'))
return sort(a:list, a:expr)
endif
let s:expr = a:expr
return sort(a:list, 's:_compare')
endfunction
function! s:_compare(a, b) abort
return eval(s:expr)
endfunction
function! s:get_neobundle_args(candidate) abort
return string(substitute(a:candidate.source__path,
\ '^https://github.com/', '', ''))
\ . (empty(a:candidate.source__options) ?
\ '' : ', ' . string(a:candidate.source__options))
\ . (a:candidate.source__description == '' ? '' :
\ ' " ' . a:candidate.source__description)
endfunction
function! unite#sources#neobundle_search#complete_plugin_names(arglead, cmdline, cursorpos) abort "{{{
return filter(s:get_plugin_names(), "stridx(v:val, a:arglead) == 0")
endfunction"}}}
function! s:initialize_plugin_names(context) abort "{{{
let cache_dir = neobundle#get_neobundle_dir() . '/.neobundle'
let path = 'plugin_names'
if a:context.is_redraw || !s:Cache.filereadable(cache_dir, path)
" Convert cache data.
call s:Cache.writefile(cache_dir, path, [string(s:plugin_names)])
endif
return s:get_plugin_names()
endfunction"}}}
function! s:get_plugin_names() abort "{{{
let cache_dir = neobundle#get_neobundle_dir() . '/.neobundle'
let path = 'plugin_names'
if empty(s:plugin_names) && s:Cache.filereadable(cache_dir, path)
sandbox let s:plugin_names =
\ eval(get(s:Cache.readfile(cache_dir, path), 0, '[]'))
endif
return neobundle#util#uniq(s:plugin_names)
endfunction"}}}
"}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker