[Helptags] Windows support (#423)

This commit is contained in:
Jan Edmund Lazo 2017-08-19 23:26:07 -04:00 committed by Junegunn Choi
parent 7e868c49ac
commit 914355df94

View file

@ -942,17 +942,22 @@ function! s:helptag_sink(line)
endfunction
function! fzf#vim#helptags(...)
if !executable('perl')
return s:warn('Helptags command requires perl')
if !executable('grep') || !executable('perl')
return s:warn('Helptags command requires grep and perl')
endif
let sorted = sort(split(globpath(&runtimepath, 'doc/tags'), '\n'))
let tags = exists('*uniq') ? uniq(sorted) : fzf#vim#_uniq(sorted)
if exists('s:helptags_script')
silent! call delete(s:helptags_script)
endif
let s:helptags_script = tempname()
call writefile(['/('.(s:is_win ? '^[A-Z]:\/.*?[^:]' : '.*?').'):(.*?)\t(.*?)\t/; printf(qq('.s:green('%-40s', 'Label').'\t%s\t%s\n), $2, $3, $1)'], s:helptags_script)
return s:fzf('helptags', {
\ 'source': "grep -H '.*' ".join(map(tags, 'shellescape(v:val)')).
\ "| perl -ne '/(.*?):(.*?)\t(.*?)\t/; printf(qq(".s:green('%-40s', 'Label')."\t%s\t%s\n), $2, $3, $1)' | sort",
\ 'source': 'grep -H ".*" '.join(map(tags, 'fzf#shellescape(v:val)')).
\ ' | perl -n '.fzf#shellescape(s:helptags_script).' | sort',
\ 'sink': s:function('s:helptag_sink'),
\ 'options': '--ansi +m --tiebreak=begin --with-nth ..-2'}, a:000)
\ 'options': ['--ansi', '+m', '--tiebreak=begin', '--with-nth', '..-2']}, a:000)
endfunction
" ------------------------------------------------------------------