vim-venu icon indicating copy to clipboard operation
vim-venu copied to clipboard

Searching for menu item

Open Timoses opened this issue 7 years ago • 4 comments

Opening the Venu and typing / could initiate a search functionality. Upon pressing ESC the user is put back to the original menu from where / was initiated.

Example menu:

  1. Markdown Preview
  2. Table of Contents (ToC)
    1. Github Flavor
    2. Redcarpet Flavor

Typing git toc should display matching items and give/select the item Github Flavor as the first result. Pressing enter executes that item.

Timoses avatar Dec 09 '18 07:12 Timoses

Have you evaluated the possibility of hooking into https://github.com/junegunn/fzf.vim ? If you offload the listing/filtering tasks to it you can focus on the core business of your plugin. I'm not in any way associated with FZF, just using it and being able to just hook your plugin into it would seem to be a nice and clean solution.

dkvasnicka avatar Dec 11 '18 09:12 dkvasnicka

A good example is the https://github.com/autozimu/LanguageClient-neovim plugin that fires up FZF to list the symbols in the document. https://github.com/autozimu/LanguageClient-neovim/blob/f9a9123582abfd0f0433e7f8813daf7e615a18b6/autoload/LanguageClient.vim#L139

dkvasnicka avatar Dec 11 '18 09:12 dkvasnicka

Thanks for the suggestion!

The underlying structure of the menu is composed of lists of dictionaries (menus), and each dictionary can contain another list of submenus. See here: https://github.com/Timoses/vim-venu/blob/master/autoload/venu.vim#L15 (cmd is the action called when the menu item is selected. However, if cmd stores a dictionary resembling a menu it will display that "submenu").

As stated in the initial issue comment, searching for "git toc" would have to match entries from several lists which have a parent-child relationship.

I haven't thought of how to implement it. I'm not sure how fzf would fit in. As far as I understand fzf offers searching/matching patterns from a list and also offers a terminal UI to make a selection. The part I see that could be useful is the pattern matching.

Timoses avatar Dec 11 '18 11:12 Timoses

I think you would have to resort to indentation to represent submenus (that's just my guess though). If that's an acceptable tradeoff is up to you ;)

dkvasnicka avatar Dec 11 '18 11:12 dkvasnicka