From 2ac5f2d86b27f517d4e9aac09f1e6af16dc262b1 Mon Sep 17 00:00:00 2001 From: h_east Date: Thu, 28 Jun 2018 20:49:24 +0900 Subject: [PATCH 1/5] Respect git managed tags --- plug.vim | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plug.vim b/plug.vim index 52c6b2a..3d95317 100644 --- a/plug.vim +++ b/plug.vim @@ -600,13 +600,28 @@ function! s:update(force, names) call s:update_impl(1, a:force, a:names) endfunction +function! s:is_exec_helptags(docdir) + execute 'lcd' a:docdir + let result = v:false + let exts = uniq(sort(map(s:glob(a:docdir, '*.{txt,??x}'), 'v:val[-3:]'))) + for ext in exts + let tagname = 'tags' . (ext == 'txt' ? '' : '-' . ext[:1]) + if !filereadable(tagname) || empty(s:system('git ls-files ' . tagname)) + let result = v:true + break + endif + endfor + lcd - + return result +endfunc + function! plug#helptags() if !exists('g:plugs') return s:err('plug#begin was not called') endif for spec in values(g:plugs) let docd = join([s:rtp(spec), 'doc'], '/') - if isdirectory(docd) + if isdirectory(docd) && s:is_exec_helptags(docd) silent! execute 'helptags' s:esc(docd) endif endfor From 03592a8b4c1ff0907b13cf2b297bc9fe0f88f8e9 Mon Sep 17 00:00:00 2001 From: h_east Date: Sat, 30 Jun 2018 21:18:52 +0900 Subject: [PATCH 2/5] Fix test failed --- plug.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plug.vim b/plug.vim index 3d95317..a2a12b6 100644 --- a/plug.vim +++ b/plug.vim @@ -601,17 +601,15 @@ function! s:update(force, names) endfunction function! s:is_exec_helptags(docdir) - execute 'lcd' a:docdir let result = v:false let exts = uniq(sort(map(s:glob(a:docdir, '*.{txt,??x}'), 'v:val[-3:]'))) for ext in exts let tagname = 'tags' . (ext == 'txt' ? '' : '-' . ext[:1]) - if !filereadable(tagname) || empty(s:system('git ls-files ' . tagname)) + if !filereadable(a:docdir .'/'. tagname) || empty(s:system('cd ' . s:shellesc(a:docdir) . ' && git ls-files ' . tagname)) let result = v:true break endif endfor - lcd - return result endfunc From 2a1fd8281a1a1cddf14baa57aeb4cccf0d80b630 Mon Sep 17 00:00:00 2001 From: h_east Date: Sat, 30 Jun 2018 22:50:11 +0900 Subject: [PATCH 3/5] Fix vim72 test failed --- plug.vim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plug.vim b/plug.vim index a2a12b6..93eb107 100644 --- a/plug.vim +++ b/plug.vim @@ -601,16 +601,14 @@ function! s:update(force, names) endfunction function! s:is_exec_helptags(docdir) - let result = v:false let exts = uniq(sort(map(s:glob(a:docdir, '*.{txt,??x}'), 'v:val[-3:]'))) for ext in exts let tagname = 'tags' . (ext == 'txt' ? '' : '-' . ext[:1]) if !filereadable(a:docdir .'/'. tagname) || empty(s:system('cd ' . s:shellesc(a:docdir) . ' && git ls-files ' . tagname)) - let result = v:true - break + return 1 endif endfor - return result + return 0 endfunc function! plug#helptags() From 6014409b5922618984e8caa14c451eeb8d390e48 Mon Sep 17 00:00:00 2001 From: h_east Date: Sun, 1 Jul 2018 00:29:20 +0900 Subject: [PATCH 4/5] Fix vim72 test failed (again) Add s:uniq() and use it --- plug.vim | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plug.vim b/plug.vim index 93eb107..81e2648 100644 --- a/plug.vim +++ b/plug.vim @@ -601,7 +601,7 @@ function! s:update(force, names) endfunction function! s:is_exec_helptags(docdir) - let exts = uniq(sort(map(s:glob(a:docdir, '*.{txt,??x}'), 'v:val[-3:]'))) + let exts = s:uniq(sort(map(s:glob(a:docdir, '*.{txt,??x}'), 'v:val[-3:]'))) for ext in exts let tagname = 'tags' . (ext == 'txt' ? '' : '-' . ext[:1]) if !filereadable(a:docdir .'/'. tagname) || empty(s:system('cd ' . s:shellesc(a:docdir) . ' && git ls-files ' . tagname)) @@ -2111,6 +2111,23 @@ function! s:git_validate(spec, check_branch) return [err, err =~# 'PlugClean'] endfunction +if exists('*uniq') + function! s:uniq(list) abort + return uniq(a:list) + endfunction +else + function! s:uniq(list) abort + let i = len(a:list) - 1 + while 0 < i + if a:list[i] ==# a:list[i - 1] + call remove(a:list, i) + endif + let i -= 1 + endwhile + return a:list + endfunction +endif + function! s:rm_rf(dir) if isdirectory(a:dir) call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(a:dir)) From d3d4f5603f71b6110d55c2d2dab8461e5dc3fb13 Mon Sep 17 00:00:00 2001 From: h_east Date: Wed, 11 Jul 2018 21:54:28 +0900 Subject: [PATCH 5/5] Rename function from 'is_exec_helptags()' to 'do_need_exec_helptags()'. --- plug.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plug.vim b/plug.vim index 81e2648..66dd784 100644 --- a/plug.vim +++ b/plug.vim @@ -600,7 +600,7 @@ function! s:update(force, names) call s:update_impl(1, a:force, a:names) endfunction -function! s:is_exec_helptags(docdir) +function! s:do_need_exec_helptags(docdir) let exts = s:uniq(sort(map(s:glob(a:docdir, '*.{txt,??x}'), 'v:val[-3:]'))) for ext in exts let tagname = 'tags' . (ext == 'txt' ? '' : '-' . ext[:1]) @@ -617,7 +617,7 @@ function! plug#helptags() endif for spec in values(g:plugs) let docd = join([s:rtp(spec), 'doc'], '/') - if isdirectory(docd) && s:is_exec_helptags(docd) + if isdirectory(docd) && s:do_need_exec_helptags(docd) silent! execute 'helptags' s:esc(docd) endif endfor