Fix #1 - Helptags to update &rtp when required

This commit is contained in:
Junegunn Choi 2015-08-29 00:43:06 +09:00
parent f73ac9283d
commit 602d98b7eb

View file

@ -474,16 +474,22 @@ command! -bang Marks call s:marks(<bang>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(<bang>0)