Skip to content

Commit 869b9e3

Browse files
authored
Merge pull request #730 from tsuyoshicho/fix/vitalizer-datafile
2 parents f3681f0 + 2aaf3ac commit 869b9e3

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

autoload/vitalizer.vim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,14 @@ function! vitalizer#vitalize(name, to, modules, hash) abort
488488
" Install modules.
489489
for [from, to] in s:install_module_files(module_files, vital_data.name, a:to)
490490
call s:copy(from, to)
491-
let raw_module = all_modules[s:file2module_name(to)]
492-
call s:autoloadablize(to, vital_data.name, raw_module)
491+
" .vim is module file/otherwise data file
492+
" module file need autoloadablize process
493+
if fnamemodify(to, ':e') ==# 'vim'
494+
let module_name = s:file2module_name(to)
495+
if has_key(all_modules, module_name)
496+
call s:autoloadablize(to, vital_data.name, all_modules[module_name])
497+
endif
498+
endif
493499
endfor
494500
let content = [vital_data.name, hash, ''] + installing_modules
495501
call writefile(content, vital_data.vital_file)

test/.themisrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ let g:testplugin_name = 'testplugin'
1414
let g:testplugin_root = g:root . '/test/_testdata/vital/' . g:testplugin_name . '/'
1515
let g:cyclic_module_root = g:root . '/test/_testdata/vital/cyclic/'
1616
let g:symlinkplugin_root = g:root . '/test/_testdata/vital/symlink_root/symlink/'
17+
let g:datafile_module_root = g:root . '/test/_testdata/vital/datatest/'
1718
call themis#option('runtimepath', g:testplugin_root)
1819
call themis#option('runtimepath', g:cyclic_module_root)
1920
call themis#option('runtimepath', g:symlinkplugin_root)
21+
call themis#option('runtimepath', g:datafile_module_root)
2022

2123
if $THEMIS_PROFILE !=# ''
2224
execute 'profile' 'start' $THEMIS_PROFILE
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test Data
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function! s:_vital_loaded(V) abort
2+
let s:V = a:V
3+
endfunction
4+
5+
function! s:_vital_depends() abort
6+
return {'modules':[], 'files':['DataTest.txt']}
7+
endfunction
8+
9+
function! s:dummy() abort
10+
return 0
11+
endfunction
12+

test/vital.vimspec

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Describe vital
66
let Filepath = Vital.import('System.Filepath')
77
let Prelude = Vital.import('Prelude')
88

9-
let vitalize_modules = ['Data.List', 'Data.LazyList', 'Data.String', 'Web.JSON', 'Cyclic1']
9+
let vitalize_modules = ['Data.List', 'Data.LazyList', 'Data.String', 'Web.JSON', 'Cyclic1', 'DataTest']
1010
call vitalizer#vitalize(g:testplugin_name, g:testplugin_root, vitalize_modules, '')
1111
End
1212

@@ -177,6 +177,7 @@ Describe vital
177177
Assert NotEmpty(vital#vital#import('Data.List'))
178178
Assert NotEmpty(vital#vital#import('Selfmodule'))
179179
Assert NotEmpty(vital#vital#import('Cyclic1'))
180+
Assert NotEmpty(vital#vital#import('DataTest'))
180181
End
181182
End
182183

@@ -238,6 +239,10 @@ Describe vital
238239
Assert True(V.import('Cyclic1').return1())
239240
End
240241

242+
It supports datafile dependencies
243+
Assert True(1 == len(readfile(Filepath.join(g:testplugin_root, 'autoload/vital/' . '_' . g:testplugin_name . '/DataTest.txt'))))
244+
End
245+
241246
Context wildignore handling
242247
Before all
243248
set wildignore+=*.vim
@@ -274,6 +279,7 @@ Describe vital
274279
Assert NotEmpty(V.import('Data.List'))
275280
Assert NotEmpty(V.import('Selfmodule'))
276281
Assert NotEmpty(V.import('Cyclic1'))
282+
Assert NotEmpty(V.import('DataTest'))
277283
End
278284
End
279285
End
@@ -313,6 +319,10 @@ Describe vital
313319
Assert True(V.Cyclic1.return1())
314320
End
315321

322+
It supports datafile dependencies
323+
Assert True(1 == len(readfile(Filepath.join(g:testplugin_root, 'autoload/vital/' . '_' . g:testplugin_name . '/DataTest.txt'))))
324+
End
325+
316326
Context wildignore handling
317327
Before all
318328
set wildignore+=*.vim

0 commit comments

Comments
 (0)