update vital
This commit is contained in:
parent
a6b3c10b41
commit
5c6f3cd9a7
@ -1,5 +1,5 @@
|
|||||||
function! vital#of(name) abort
|
function! vital#of(name) abort
|
||||||
let files = globpath(&runtimepath, 'autoload/vital/' . a:name . '.vital')
|
let files = globpath(&runtimepath, 'autoload/vital/' . a:name . '.vital', 1)
|
||||||
let file = split(files, "\n")
|
let file = split(files, "\n")
|
||||||
if empty(file)
|
if empty(file)
|
||||||
throw 'vital: version file not found: ' . a:name
|
throw 'vital: version file not found: ' . a:name
|
||||||
|
@ -87,7 +87,7 @@ let s:overwin = {
|
|||||||
\ 'cursor': 'HitAHintCursor',
|
\ 'cursor': 'HitAHintCursor',
|
||||||
\ },
|
\ },
|
||||||
\ 'jump_first_target_keys': [],
|
\ 'jump_first_target_keys': [],
|
||||||
\ 'do_shade': s:FALSE,
|
\ 'do_shade': s:TRUE,
|
||||||
\ }
|
\ }
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ function! s:edit_content(content, ...) abort
|
|||||||
let options = extend({
|
let options = extend({
|
||||||
\ 'edit': 1,
|
\ 'edit': 1,
|
||||||
\}, get(a:000, 0, {}))
|
\}, get(a:000, 0, {}))
|
||||||
let guard = s:G.store('&l:modifiable')
|
let guard = s:G.store(['&l:modifiable'])
|
||||||
let saved_view = winsaveview()
|
let saved_view = winsaveview()
|
||||||
try
|
try
|
||||||
let &l:modifiable=1
|
let &l:modifiable=1
|
||||||
|
@ -185,9 +185,9 @@ function! s:instance.restore() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:guard = {}
|
let s:guard = {}
|
||||||
function! s:store(...) abort
|
function! s:store(targets) abort
|
||||||
let resources = []
|
let resources = []
|
||||||
for meta in a:000
|
for meta in a:targets
|
||||||
if s:Prelude.is_list(meta)
|
if s:Prelude.is_list(meta)
|
||||||
if len(meta) == 1
|
if len(meta) == 1
|
||||||
call add(resources, s:_new_instance(meta[0]))
|
call add(resources, s:_new_instance(meta[0]))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
let s:plugin_name = expand('<sfile>:t:r')
|
let s:plugin_name = expand('<sfile>:t:r')
|
||||||
let s:vital_base_dir = expand('<sfile>:h')
|
let s:vital_base_dir = expand('<sfile>:h')
|
||||||
let s:project_root = expand('<sfile>:h:h:h')
|
let s:project_root = expand('<sfile>:h:h:h')
|
||||||
let s:is_vital_vim = s:plugin_name is# '_latest__'
|
let s:is_vital_vim = s:plugin_name is# 'vital'
|
||||||
|
|
||||||
let s:loaded = {}
|
let s:loaded = {}
|
||||||
let s:cache_sid = {}
|
let s:cache_sid = {}
|
||||||
@ -25,11 +25,18 @@ function! vital#{s:plugin_name}#of() abort
|
|||||||
return s:new(s:plugin_name)
|
return s:new(s:plugin_name)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! vital#{s:plugin_name}#import(...) abort
|
||||||
|
if !exists('s:V')
|
||||||
|
let s:V = s:new(s:plugin_name)
|
||||||
|
endif
|
||||||
|
return call(s:V.import, a:000, s:V)
|
||||||
|
endfunction
|
||||||
|
|
||||||
let s:Vital = {}
|
let s:Vital = {}
|
||||||
|
|
||||||
function! s:new(plugin_name) abort
|
function! s:new(plugin_name) abort
|
||||||
let base = deepcopy(s:Vital)
|
let base = deepcopy(s:Vital)
|
||||||
let base.plugin_name = a:plugin_name
|
let base._plugin_name = a:plugin_name
|
||||||
return base
|
return base
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -103,18 +110,10 @@ endfunction
|
|||||||
let s:Vital.unload = s:_function('s:unload')
|
let s:Vital.unload = s:_function('s:unload')
|
||||||
|
|
||||||
function! s:exists(name) abort dict
|
function! s:exists(name) abort dict
|
||||||
let b = exists(printf('*vital#_%s#%s#import', self.plugin_name, substitute(a:name, '\.', '#', 'g')))
|
if a:name !~# '\v^\u\w*%(\.\u\w*)*$'
|
||||||
if b
|
throw 'vital: Invalid module name: ' . a:name
|
||||||
return b
|
|
||||||
endif
|
endif
|
||||||
let name_path = substitute(a:name, '\.', '/', 'g')
|
return s:_module_path(a:name) isnot# ''
|
||||||
let path = printf('%s/_%s/%s.vim', s:vital_base_dir, self.plugin_name, name_path)
|
|
||||||
let b = filereadable(path)
|
|
||||||
if b
|
|
||||||
return b
|
|
||||||
endif
|
|
||||||
let path = printf('%s/_%s/%s.vim', s:vital_base_dir, '_latest__', name_path)
|
|
||||||
let b = filereadable(path)
|
|
||||||
endfunction
|
endfunction
|
||||||
let s:Vital.exists = s:_function('s:exists')
|
let s:Vital.exists = s:_function('s:exists')
|
||||||
|
|
||||||
@ -125,6 +124,11 @@ function! s:search(pattern) abort dict
|
|||||||
endfunction
|
endfunction
|
||||||
let s:Vital.search = s:_function('s:search')
|
let s:Vital.search = s:_function('s:search')
|
||||||
|
|
||||||
|
function! s:plugin_name() abort dict
|
||||||
|
return self._plugin_name
|
||||||
|
endfunction
|
||||||
|
let s:Vital.plugin_name = s:_function('s:plugin_name')
|
||||||
|
|
||||||
function! s:_self_vital_files() abort
|
function! s:_self_vital_files() abort
|
||||||
let builtin = printf('%s/__%s__/', s:vital_base_dir, s:plugin_name)
|
let builtin = printf('%s/__%s__/', s:vital_base_dir, s:plugin_name)
|
||||||
let installed = printf('%s/_%s/', s:vital_base_dir, s:plugin_name)
|
let installed = printf('%s/_%s/', s:vital_base_dir, s:plugin_name)
|
||||||
@ -178,45 +182,76 @@ let s:Vital._import = s:_function('s:_import')
|
|||||||
|
|
||||||
" s:_get_module() returns module object wihch has all script local functions.
|
" s:_get_module() returns module object wihch has all script local functions.
|
||||||
function! s:_get_module(name) abort dict
|
function! s:_get_module(name) abort dict
|
||||||
try
|
let funcname = s:_import_func_name(self.plugin_name(), a:name)
|
||||||
let module = vital#_{self.plugin_name}#{substitute(a:name, '\.', '#', 'g')}#import()
|
if s:_exists_autoload_func_with_source(funcname)
|
||||||
catch /E117: Unknown function:/
|
return call(funcname, [])
|
||||||
" Retry to support loading self modules.
|
else
|
||||||
let module = s:_get_builtin_module(a:name)
|
return s:_get_builtin_module(a:name)
|
||||||
endtry
|
endif
|
||||||
return module
|
|
||||||
endfunction
|
endfunction
|
||||||
let s:Vital._get_module = s:_function('s:_get_module')
|
|
||||||
|
|
||||||
function! s:_get_builtin_module(name) abort
|
function! s:_get_builtin_module(name) abort
|
||||||
return s:sid2sfuncs(s:_module_sid(a:name))
|
return s:sid2sfuncs(s:_module_sid(a:name))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:vital_builtin_dir = printf('autoload/vital/__%s__/', s:is_vital_vim ? '*' : s:plugin_name)
|
if s:is_vital_vim
|
||||||
|
" For vital.vim, we can use s:_get_builtin_module directly
|
||||||
|
let s:Vital._get_module = s:_function('s:_get_builtin_module')
|
||||||
|
else
|
||||||
|
let s:Vital._get_module = s:_function('s:_get_module')
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! s:_import_func_name(plugin_name, module_name) abort
|
||||||
|
return printf('vital#_%s#%s#import', a:plugin_name, s:_dot_to_sharp(a:module_name))
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:_module_sid(name) abort
|
function! s:_module_sid(name) abort
|
||||||
let module_path = substitute(a:name, '\.', '/', 'g') . '.vim'
|
let path = s:_module_path(a:name)
|
||||||
let module_rel_path = s:vital_builtin_dir . module_path
|
|
||||||
let path = get(split(globpath(s:_module_sid_base_dir(), module_rel_path, 1), "\n"), 0, '')
|
|
||||||
if !filereadable(path)
|
if !filereadable(path)
|
||||||
throw 'vital: module not found: ' . a:name
|
throw 'vital: module not found: ' . a:name
|
||||||
endif
|
endif
|
||||||
let p = substitute('autoload/vital/__\w\+__/' . module_path, '/', '[/\\\\]\\+', 'g')
|
let vital_dir = s:is_vital_vim ? '__\w\+__' : printf('_\{1,2}%s\%%(__\)\?', s:plugin_name)
|
||||||
|
let base = join([vital_dir, ''], '[/\\]\+')
|
||||||
|
let p = base . substitute('' . a:name, '\.', '[/\\\\]\\+', 'g')
|
||||||
let sid = s:_sid(path, p)
|
let sid = s:_sid(path, p)
|
||||||
if !sid
|
if !sid
|
||||||
call s:_source(path)
|
call s:_source(path)
|
||||||
let sid = s:_sid(path, p)
|
let sid = s:_sid(path, p)
|
||||||
if !sid
|
if !sid
|
||||||
throw 'vital: cannot get <SID> from path'
|
throw printf('vital: cannot get <SID> from path: %s', path)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
return sid
|
return sid
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:_module_path(name) abort
|
||||||
|
return get(s:_extract_files(a:name, s:vital_files()), 0, '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:_module_sid_base_dir() abort
|
function! s:_module_sid_base_dir() abort
|
||||||
return s:is_vital_vim ? &rtp : s:project_root
|
return s:is_vital_vim ? &rtp : s:project_root
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:_dot_to_sharp(name) abort
|
||||||
|
return substitute(a:name, '\.', '#', 'g')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" It will sources autoload file if a given func is not already defined.
|
||||||
|
function! s:_exists_autoload_func_with_source(funcname) abort
|
||||||
|
if exists('*' . a:funcname)
|
||||||
|
" Return true if a given func is already defined
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
" source a file which may include a given func definition and try again.
|
||||||
|
let path = 'autoload/' . substitute(substitute(a:funcname, '#[^#]*$', '.vim', ''), '#', '/', 'g')
|
||||||
|
call s:_runtime(path)
|
||||||
|
return exists('*' . a:funcname)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:_runtime(path) abort
|
||||||
|
execute 'runtime' fnameescape(a:path)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:_source(path) abort
|
function! s:_source(path) abort
|
||||||
execute 'source' fnameescape(a:path)
|
execute 'source' fnameescape(a:path)
|
||||||
endfunction
|
endfunction
|
||||||
@ -297,7 +332,7 @@ else
|
|||||||
if a:list[i] ==# a:list[i - 1]
|
if a:list[i] ==# a:list[i - 1]
|
||||||
call remove(a:list, i)
|
call remove(a:list, i)
|
||||||
endif
|
endif
|
||||||
let i -= 1
|
let i -= 1
|
||||||
endwhile
|
endwhile
|
||||||
return a:list
|
return a:list
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
easymotion
|
easymotion
|
||||||
fdf7e768bdfac4f1b60d784a6d1016d09e37efcc
|
64a8be0c1fbfbf944043fb22f16bab8c28756459
|
||||||
|
|
||||||
Over.Commandline.Base
|
Over.Commandline.Base
|
||||||
Over.Commandline.Modules.Cancel
|
Over.Commandline.Modules.Cancel
|
||||||
|
Loading…
Reference in New Issue
Block a user