Просмотр исходного кода

Fix #410 - Do not load irrelevant syntax files

Junegunn Choi 10 лет назад
Родитель
Сommit
ffd54224a0
2 измененных файлов с 13 добавлено и 2 удалено
  1. 6 2
      plug.vim
  2. 7 0
      test/workflow.vader

+ 6 - 2
plug.vim

@@ -411,7 +411,7 @@ function! s:remove_triggers(name)
   call remove(s:triggers, a:name)
 endfunction
 
-function! s:lod(names, types)
+function! s:lod(names, types, ...)
   for name in a:names
     call s:remove_triggers(name)
     let s:loaded[name] = 1
@@ -423,6 +423,9 @@ function! s:lod(names, types)
     for dir in a:types
       call s:source(rtp, dir.'/**/*.vim')
     endfor
+    for file in a:000
+      call s:source(rtp, file)
+    endfor
     if exists('#User#'.name)
       execute 'doautocmd User' name
     endif
@@ -430,7 +433,8 @@ function! s:lod(names, types)
 endfunction
 
 function! s:lod_ft(pat, names)
-  call s:lod(a:names, ['plugin', 'after/plugin', 'syntax', 'after/syntax'])
+  let syn = 'syntax/'.a:pat.'.vim'
+  call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn)
   execute 'autocmd! PlugLOD FileType' a:pat
   if exists('#filetypeplugin#FileType')
     doautocmd filetypeplugin FileType

+ 7 - 0
test/workflow.vader

@@ -935,6 +935,7 @@ Execute (Filetype-based on-demand loading):
   call ReloadPlug()
   call plug#begin()
   Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
+  Plug '$PLUG_FIXTURES/yyy', { 'for': 'yyy' }
   call plug#end()
 
   AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
@@ -942,6 +943,10 @@ Execute (Filetype-based on-demand loading):
   setf xxx
   AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin', 'xxx/syntax', 'xxx/after/syntax', 'xxx/ftplugin', 'xxx/after/ftplugin', 'xxx/indent', 'xxx/after/indent', 'xxx/syntax', 'xxx/after/syntax'], g:xxx
 
+  " syntax/xxx.vim and after/syntax/xxx.vim should not be loaded (#410)
+  setf yyy
+  AssertEqual ['yyy/ftdetect', 'yyy/after/ftdetect', 'yyy/plugin', 'yyy/after/plugin'], g:yyy
+
 Before:
 
 **********************************************************************
@@ -992,6 +997,8 @@ Execute (PlugStatus should not contain (not loaded)):
   q
 
 Execute (Load plugin from PlugStatus screen with L key in normal mode):
+  call ResetPlug()
+  unlet! g:yyy
   call plug#begin()
   Plug '$PLUG_FIXTURES/yyy', { 'on': [] }
   call plug#end()