From 66cb8b826477671fba81c2db5fbb080c7b89f955 Mon Sep 17 00:00:00 2001 From: Philip Kannegaard Hayes Date: Sun, 16 Jan 2022 04:33:29 -0800 Subject: [PATCH] [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. --- autoload/fzf/vim.vim | 7 ++++--- plugin/fzf.vim | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index 7fd8314..9fbdc3b 100644 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -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 " ------------------------------------------------------------------ diff --git a/plugin/fzf.vim b/plugin/fzf.vim index ac0177b..f7ae7d1 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -60,7 +60,7 @@ call s:defs([ \'command! -bar -bang Snippets call fzf#vim#snippets(0)', \'command! -bar -bang Commands call fzf#vim#commands(0)', \'command! -bar -bang Marks call fzf#vim#marks(0)', -\'command! -bar -bang Helptags call fzf#vim#helptags(0)', +\'command! -bar -bang Helptags call fzf#vim#helptags(fzf#vim#with_preview({ "placeholder": "--tag {2}:{3}:{4}" }), 0)', \'command! -bar -bang Windows call fzf#vim#windows(0)', \'command! -bar -bang -range=% Commits let b:fzf_winview = winsaveview() | ,call fzf#vim#commits(fzf#vim#with_preview({ "placeholder": "" }), 0)', \'command! -bar -bang -range=% BCommits let b:fzf_winview = winsaveview() | ,call fzf#vim#buffer_commits(fzf#vim#with_preview({ "placeholder": "" }), 0)',