Show completions' `ToolTip` as `--preview`
Would be nice to see CompletionMatches' .ToolTips in the fzf --preview-window.
Here's how I think this could work:
- get array of completions
- Generate JSON object: keys == CompletionText, values == ToolTip
- Write JSON to a temp file
- pass a command to
fzf --previewthat can lookup a value from a key in the JSON- If using
jq, could be:fzf --preview 'jq --raw-output --arg key "{1}" ".[$key]" /path/to/tempfile.json' - relying on an external binary is not ideal
-
fzfmight get support for reading directly from JSON, no need for externaljqbinary
- If using
Asked fzf about feasibility of adding a --preview mechanism that reads all previews as structured data, either via stdin or from a temp file: https://github.com/junegunn/fzf/issues/4601
I have thought about doing something like this in the past, but I couldn't think of an elegant way to save the tooltip state and reference it in the preview window.
How do you feel about my JSON temp file idea? Or a temp file format that's more friendly to being parsed by a simple sh-compatible shell?