better menu for path completion
Closed this issue · 6 comments
Recipe paths are very long therefore it is not really neat using wildmenu.
Look at how Ctrl-P implemented its custom menu instead of using wildmenu.
Ctrl-P implements a completely custom menu, from what I can see. The easiest way to reuse that is to use Ctrl-P as it is with its given customization options:
g:ctrlp_user_command
to generate the "file list" (just returns:bob_package_tree_list
) (alternatively use CtrlPs "Line mode" (copy the content of the recipe tree into a buffer which will be searched by CtrlP) (see:h CtrlPLine
), seems more work with no gain)g:ctrlp_open_func
to define a function how to "open" the "file" (call the corresponding function of vim-bob)
Copying the functionality of the completion window would copy lots of code that has to be maintained. Factoring the functionality out into a separate plugin would be a lot of work.
g:ctrlp_user_command
is of no use, because it can only take a system command, not a vim-script function, we could query Bob here, but this would introduce some unnecessary delay. We want to use the list that was already cached during :BobInit
.
There is an API to use CtrlP, which is not documented in the original plugin, but in this actively maintained fork. Using this should be much cleaner than the previous variants.
Problems with the API:
- no way to pre-fill the command line (this seems to work only from mappings, not from functions or commands) (we could use multiple subsequent calls to CtrlP for each argument and stop for the first empty argument?)
- fuzzy-matching could be not optimal, normal matching with tab-completion seems faster, can this be done by changing the matcher algorithm?
Thinking more about this, the idea of BobProject
emerged. The idea there is to check the checkout path for all occurrences of the same leafe package. If they are equal they can be merged to one entry in the list and the path can be removed. This reduces the size of the list regarding number of entries and also regarding size of the entries and allows usage of the standard auto-completion mechanisms provided by vim.
It is currently only implemented in the experimental project mode, but should be done for all use-cases.
As soon as neovim/neovim#9607 is merged, it would also be possible to display the wildmenu entries in a popup menu where entries are vertically placed instead of horizontally like in the traditional wildmenu. Long path names won't be a problem anymore. 🎉
Closing this as done, because there are now two possibilities:
- Use vim-bobs project mode to significantly reduce the length of the list entries
- Use neovims popup menu as wild-menu.