[Helptags] add preview window to :Helptags command (#1357)

+ In `fzf#vim#helptags`, we now also parse out the ex-command in the
  perl script so it's available for the preview (this is just an
  extra `\t(.*)` appended to the original regex).

+ Add the `--tag` placeholder to `:Helptags` with corresponding
  arguments.
This commit is contained in:
Philip Kannegaard Hayes
2022-01-16 04:33:29 -08:00
committed by GitHub
parent d6aa21476b
commit 66cb8b8264
2 changed files with 5 additions and 4 deletions

View File

@@ -1087,12 +1087,13 @@ function! fzf#vim#helptags(...)
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)
call writefile(['/('.(s:is_win ? '^[A-Z]:[\/\\].*?[^:]' : '.*?').'):(.*?)\t(.*?)\t(.*)/; printf(qq('.s:green('%-40s', 'Label').'\t%s\t%s\t%s\n), $2, $3, $1, $4)'], s:helptags_script)
return s:fzf('helptags', {
\ 'source': 'grep -H ".*" '.join(map(tags, 'fzf#shellescape(v:val)')).
\ 'source': 'grep --with-filename ".*" '.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', '..3']}, a:000)
endfunction
" ------------------------------------------------------------------

View File

@@ -60,7 +60,7 @@ call s:defs([
\'command! -bar -bang Snippets call fzf#vim#snippets(<bang>0)',
\'command! -bar -bang Commands call fzf#vim#commands(<bang>0)',
\'command! -bar -bang Marks call fzf#vim#marks(<bang>0)',
\'command! -bar -bang Helptags call fzf#vim#helptags(<bang>0)',
\'command! -bar -bang Helptags call fzf#vim#helptags(fzf#vim#with_preview({ "placeholder": "--tag {2}:{3}:{4}" }), <bang>0)',
\'command! -bar -bang Windows call fzf#vim#windows(<bang>0)',
\'command! -bar -bang -range=% Commits let b:fzf_winview = winsaveview() | <line1>,<line2>call fzf#vim#commits(fzf#vim#with_preview({ "placeholder": "" }), <bang>0)',
\'command! -bar -bang -range=% BCommits let b:fzf_winview = winsaveview() | <line1>,<line2>call fzf#vim#buffer_commits(fzf#vim#with_preview({ "placeholder": "" }), <bang>0)',