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