@@ -100,25 +100,29 @@ function! s:search_dependence(modules)
100100  return  sort (keys (all ))
101101endfunction 
102102
103+ function !  s: is_camel_case
104+   return  ! empty (matchstr (a: str' ^\%([0-9A-Z]\l*\)\+$' 
105+ endfunction 
106+ 
107+ function !  s: is_module_name
108+   return  s: Land (map (split (a: str' \.' ' s:is_camel_case(v:val)' 
109+ endfunction 
110+ 
103111function !  s: module2file
104112  let  target =  a: name== # ' ' ' ' ' /' substitute (a: name' \W\+' ' /' ' g' 
105113  return  printf (' autoload/vital/__latest__%s.vim' 
106114endfunction 
107115
108- function !  s: camelize
109-   return  substitute (a: str' \%(^\|_\)\(\l\)' ' \u\1' ' g' 
110- endfunction 
111- 
112116function !  s: file2modulefile )
113-   let  tail =  matchstr (a: file' autoload/vital/_\w\+/\zs.*\ze\.vim$' 
114-   return  join (map (split (tail, ' [\\/]\+' ' s:camelize(v:val)' ' .' 
117+   let  filename =  s: FPunify_separator (a: file
118+   let  tail =  matchstr (filename, ' autoload/vital/_\w\+/\zs.*\ze\.vim$' 
119+   return  join (split (tail, ' [\\/]\+' ' .' 
115120endfunction 
116121
117- function !  s: all_modules
118-   let  pat =  ' ^.*\zs\<autoload/vital/.*' 
119-   return  filter (map (split (glob (
120-   \           g: vitalizer' /autoload/vital/**/*.vim' 1 ), " \n " 
121-   \           ' matchstr(s:FP.unify_separator(v:val), pat)' ' v:val!=""' 
122+ function !  s: available_module_names
123+   return  sort (s: Luniq (filter (map (split (globpath (&runtimepath ,
124+   \           ' autoload/vital/__latest__/**/*.vim' 1 ), " \n " 
125+   \           ' s:file2module(v:val)' ' s:is_module_name(v:val)' 
122126endfunction 
123127
124128function !  s: get_changes
@@ -240,8 +244,8 @@ function! vitalizer#vitalize(name, to, modules, hash)
240244    "  Check if all of specified modules exist. 
241245    let  missing =  copy (a: modules
242246    call  map (missing, ' substitute(v:val, "^[+-]", "", "")' 
243-     let  all_modules =  s: all_modules 
244-     call  filter (missing, ' index(all_modules, s:module2file( v:val) ) is -1' 
247+     let  all_modules =  s: available_module_names 
248+     call  filter (missing, ' index(all_modules, v:val) is -1' 
245249    if  ! empty (missing)
246250      throw  " vitalizer: Some modules don't exist: " join (missing, ' , ' 
247251    endif 
@@ -282,15 +286,25 @@ function! vitalizer#vitalize(name, to, modules, hash)
282286      endif 
283287    endif 
284288
289+     "  List and check the installing files. 
290+     let  install_files =  []
291+     for  f  in  files  +  s: REQUIRED_FILES
292+       let  after =  substitute (f , ' __latest__' ' _' a: name' ' 
293+       let  paths =  globpath (g: vitalizer' ,' runtimepath , f , 1 )
294+       let  from =  get (split (paths, " \n " 0 )
295+       if  ! filereadable (from)
296+         throw  ' vitalizer: Can not read the installing file: ' file 
297+       endif 
298+       call  add (install_files, [from, s: FPjoin (a: to
299+     endfor 
300+ 
285301    "  Remove previous vital. 
286302    call  s: uninstalla: to
287303
288304    "  Install vital. 
289305    let  short_hash =  hash[: s: HASH_SIZE
290-     for  f  in  files  +  s: REQUIRED_FILES
291-       let  after =  substitute (f , ' __latest__' ' _' a: name' ' 
292-       call  s: copys: FPjoin (g: vitalizerf ),
293-       \            s: FPjoin (a: to
306+     for  [from, to ] in  install_files
307+       call  s: copyto )
294308    endfor 
295309    let  content =  [a: name' ' +  installing_modules
296310    call  writefile (content, vital_file_name)
@@ -315,7 +329,7 @@ function! vitalizer#complete(arglead, cmdline, cursorpos)
315329    return  filter (options , ' stridx(v:val, a:arglead)!=-1' 
316330  elseif  len (args ) >  2  ||  (len (args ) ==  2  &&  a: cmdline= ~# ' \s$' 
317331    let  prefix =  a: arglead= ~# ' ^[+-]' a: arglead0 ] : ' ' 
318-     return  filter (map (s: all_modules ' prefix . s:file2module( v:val) ' 
332+     return  filter (map (s: available_module_names ' prefix . v:val' 
319333    \   ' stridx(v:val, a:arglead)!=-1' 
320334  else 
321335    return  map (filter (split (glob (a: arglead" *" 1 ), " \n " 
0 commit comments