From 93c03cd2067e432726aeefd56eec8c4ca8d701df Mon Sep 17 00:00:00 2001 From: step- Date: Thu, 9 Feb 2023 15:59:38 +0100 Subject: [PATCH] feat: add g:wiki_fzf_tags_opts Pass additional options to fzf in :WikiFzfTags, e.g. to add a previewer. Similar in spirit to #157. Viewer example using [bat](https://github.com/sharkdp/bat) included. --- autoload/wiki/fzf.vim | 8 +++++++- doc/wiki.txt | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/autoload/wiki/fzf.vim b/autoload/wiki/fzf.vim index 0da6f0d..628f4fd 100644 --- a/autoload/wiki/fzf.vim +++ b/autoload/wiki/fzf.vim @@ -39,11 +39,17 @@ function! wiki#fzf#tags() abort "{{{1 endfor endfor + let l:fzf_opts = join([ + \ '-d": |:\d+$" ', + \ '--expect=ctrl-l --prompt "WikiTags> " ', + \ g:wiki_fzf_tags_opts, + \]) + " Feed tags to FZF call fzf#run(fzf#wrap({ \ 'source': l:results, \ 'sink*': funcref('s:accept_tag'), - \ 'options': '--expect=ctrl-l --prompt "WikiTags> " ' + \ 'options': l:fzf_opts \})) endfunction diff --git a/doc/wiki.txt b/doc/wiki.txt index f140e3d..5e38f78 100644 --- a/doc/wiki.txt +++ b/doc/wiki.txt @@ -471,13 +471,24 @@ OPTIONS *wiki-config-options* A string with additional user options for |WikiFzfPages|. This can be used e.g. to add a previewer. Users should be aware that the page candidates are "prettified" with the `--with-nth=1` and `-d` options for fzf, so to obtain - the page path in a previewer option one must use the field index expression 1. + the page path in a previewer option one must use the field index expression `1`. E.g.: >vim let g:wiki_fzf_pages_opts = '--preview "cat {1}"' < Default: `''` +*g:wiki_fzf_tags_opts* + A string with additional user options for |WikiFzfTags|. This can be used + e.g. to add a previewer. Users should be aware that the page candidates are + "prettified" with the `-d` option for fzf, so to obtain the page path in a + previewer option one must use the field index expression `2..`. + E.g.: >vim + + let g:wiki_fzf_tags_opts = '--preview "bat --color=always {2..}"' +< + Default: `''` + *g:wiki_global_load* |wiki.vim| is inherently agnostic in that it assumes any recognized filetype specifies a wiki. However, some people might want to load |wiki.vim| for @@ -1390,6 +1401,10 @@ the commands are also available as mappings of the form `(wiki-[name])`. *WikiFzfTags* Open |fzf| and search for tags. + One may pass additional options to fzf with the |g:wiki_fzf_tags_opts| + option. This allows more fine grained control of fzf, e.g. to add + a previewer. + *(wiki-fzf-toc)* *WikiFzfToc* Open |fzf| and list table of contents entries for the current wiki page.