Vim popup menu, like the omni autocomplete popup - vim

I'm making a Vim Script. I want to make a popup that offers alternatives. It should work the same as the Omni-popup, but not replace the string or go through the omni functions. Like this:
I've haxxed in the functionality I need by using the completefunc and the auto command event CompleteDone, just to get the popup. But it's really ugly and messy, since I'm not using it for auto completion.
Is there a way to use this popup but with full control, not going through the omni-complete functionality? Like populating it with values and receive the value selected?
I know you can just place the alternatives in an other buffer and just grab the input from there. But it disturbs the work flow, I want a popup.

The insert mode popup menu is only meant for completions, as you've correctly found out. There is not other precedence for popup menus as a general selector in Vim, so such functionality is not there and is difficult to emulate. (In GVIM, one can populate a right mouse button popup menu, but this would need to be triggered by a mouse key press.)
The "Vim way" would be to :echo the list of menu items and query (via getchar() or input()), or just use confirm() or inputlist(). Examples built into Vim are the query in :tselect.
Plugins often use a split scratch buffer to build a more elaborate menu; this can even be combined with 'completefunc', as any text entry into the scratch buffer is discarded, anyway.
The FuzzyFinder - buffer/file/command/tag/etc explorer plugin uses this, and even provides an API for custom uses, cp. :help fuf-callbackitem-mode. That's certainly worth a look, though the menu would still be located at the top, not inside the current buffer.

Do either of these do what you want?
:help inputdialog()
:help inputlist()

Related

How to expand an UltiSnips snippet using <c-y> in the YouCompleteMe pop-up menu?

This problem really hit a nerve with me. I have both YouCompleteMe and UltiSnips installed on my vim 8.0 editor. It seems that both of these plugins use the tab key for doing the auto-completion and that has created an incompatibility that has been also addressed by this question. My question is more specific, though. When I write a piece of code like <html, there is a pop-up menu that shows me all related snippets for that code.
I use the tab key to navigate through that menu but when I hit ctrl+y to accept and therefore expand one of these snippets, nothing happens! I think this structure suggests that it's possible to somehow choose one of those snippets from the menu without trying to define a shortcut for UltiSnip. What am I doing wrong? How should I navigate and choose those snippets?
I also would not want to stuff my vim with any new plugins (like supertab, etc.).
The solution was actually a lot simpler than I expected. In the beginning, I felt stupid for not knowing it but when I find a similar question like this one, I thought that probably many were fallen into the same trap.
I don't know whether to name it a bug or not but it's how Ultisnips and YouCompleteMe work together. In order to expand a snippet, you have to write the initializer exactly as it's defined. Of course, this seems obvious, but when you see a pop-up menu of different snippets, you might think they can be chosen but it only works if you already wrote the snippet initializer exactly as it's defined.
So when a snippet is called "html5"---as it's shown in my question---writing an extra opening bracket (<) will cause it to stop working. It cannot be expanded.
Also, don't forget to check out Siegfried Gevatter configuration. It's not possible to use tab key both for navigating into the pop-up menu and expanding the snippets.
P.S. It was nice if navigating through the pop-up menu could change the whole word (including the angle bracket), not just what succeeds it. This feature works this way in most of the other editors I see and that's probably why I wasn't able to spot the problem in the beginning.

Switch between panes in VIM for codepen.io?

When using vim mode in codepen.io, how do you switch between panes as ctrl+w+w doesn't work as it closes the window tab. What other codepen.io specific key bindings are there?
It'd probably be better to ask the project maintainers, but it does not seem like it's possible. There's a whole page on their blog post that hints as to why. It also has a link to the project providing that functionality.

vim: where is the autocompletion preview window for ctags generated tags?

The documentation for the "completeopt" options says:
...
A comma separated list of options for Insert mode completion
|ins-completion|. The supported values are:
...
preview Show extra information about the currently selected
completion in the preview window. Only works in
combination with "menu" or "menuone".
For me this sounds that if "menu" and "preview" is set, you always get a preview window for the current autocompleted item, so for a ctags tag I expected to see a preview of the file, where the item is defined (the same as I would press CTRL-W-} on a tag under the cursor).
But it seems this preview window is only available for omni-completion, if the set omnifunc supports it. How could I also get a preview window for autocompleted tags?
The built-in completions don't have much additional stuff to show, so this feature is only available for custom completions (as you'd correctly assumed), namely via the info attribute in the returned completion items, see :help complete-items.
If you really would like additional information about tags (but there isn't much, see :help tags-file-format), you'd have to write a custom completion (sourced from taglist()) and populate the mentioned info attribute.
This is far from perfect but you can set showfulltag to get more information for each suggestion.
Without set showfulltag:
With set showfulltag:
As you can see, the completion menu becomes a little crowded and you must skip entries but well…
Using the preview window would be so much nicer.
See :help 'showfulltag'.

Vimscript: How can I implement interactive method argument autocompletion?

I am writing a plugin for vim in which I am calling a ruby script.
The script finds the arguments for the method and I have managed to display them in the popup using completefunc. Here is how it looks.
This is great but if I chose one of the options the popup closes and I lose the rest. Is there a way that I can keep the popup open and use it to paste things in while typing? I do feel like I am misusing the popup as it seems to be designed for single word auto-completion. If that is the case could someone suggest an elegant alternative approach?
Best,
Dionysis
There's no way around closing the popup menu after a candidate has been selected and inserted into the buffer. However, nothing prevents you from automatically re-triggering the same completion (using feedkeys() and the CursorMovedI event), provided the conditions for continued completion are given.
The AutoComplPop - Automatically opens popup menu plugin does this; you can check its implementation for details.

Vim omnicompletion: optional preview window

I've searched for different types of workarounds to deal with the preview window splitting the current window to display documentation when doing a selection in Omnicompletion, like closing the preview window if it exists when you leave insert mode.
However, those solutions are impractical. Sometimes you may want to go into the preview window to read some documentation about the current completing module, but with the autocommand in place this would not be possible.
Even if it would, I am looking to have the documentation never show up because I really don't want it.
Reading the source code in pythoncomplete.vim I see that the value for the documentation is hard coded and it will force the preview window to show up if this has any contents (it skips this if it can't come up with docs for the module).
Is there a global option that I am not aware to tell Vim to never display docs? Or be able to toggle it?
If I do want to read the docs in a split window allow me to do so (maybe with some shortcut) otherwise don't show me anything.
I really want to avoid having to copy/paste pythoncomplete.vim to tweak this particular setting to my liking.
The preview is controlled by the global 'completeopt' setting. To turn that off, use
:set completeopt-=preview

Resources