From ffd54224a0742c5b6e03cc9f51789de5c5de16a7 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 18 Feb 2016 01:34:04 +0900 Subject: [PATCH] Fix #410 - Do not load irrelevant syntax files --- plug.vim | 8 ++++++-- test/workflow.vader | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/plug.vim b/plug.vim index 23de2ac..1b56637 100644 --- a/plug.vim +++ b/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 diff --git a/test/workflow.vader b/test/workflow.vader index 75d908e..d54dd37 100644 --- a/test/workflow.vader +++ b/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()