From 602d98b7ebee4feee280140f720c85effe2eb722 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 29 Aug 2015 00:43:06 +0900 Subject: [PATCH] Fix #1 - Helptags to update &rtp when required --- plugin/fzf.vim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 66e5ea5..e18fbae 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -474,16 +474,22 @@ command! -bang Marks call s:marks(0) " Help tags " ------------------------------------------------------------------ function! s:helptag_sink(line) - execute 'help' split(a:line)[0] + let [tag, file, path] = split(a:line, "\t")[0:2] + let rtp = fnamemodify(path, ':p:h:h') + if stridx(&rtp, rtp) < 0 + execute 'set rtp+='.s:escape(rtp) + endif + execute 'help' tag endfunction function! s:helptags(bang) let tags = split(globpath(&runtimepath, '**/doc/tags'), '\n') call s:fzf({ - \ 'source': 'cat '.join(map(tags, 'shellescape(v:val)'))."| sort | awk '{printf \"%-40s%s\\n\", $1, $2}'", + \ 'source': "grep -H '.*' ".join(map(tags, 'shellescape(v:val)')). + \ "| perl -ne '/(.*?):(.*?)\t(.*?)\t/; printf(qq(\x1b[33m%-40s\x1b[m\t%s\t%s\n), $2, $3, $1)' | sort", \ 'sink': function('s:helptag_sink'), - \ 'options': '+m --tiebreak=begin'}, a:bang) + \ 'options': '--ansi +m --tiebreak=begin --with-nth ..-2'}, a:bang) endfunction command! -bang Helptags call s:helptags(0)