autocomplete conflict with vim-autoclose

Asked by Brian Gates

vim-autoclose is a plugin that automatically inserts the second half of a pair of characters, leaving the cursor in between
ie typing "[_" yields "[_]" where "_" indicates cursor position.

If one of the options in the ultisnips autocomplete function starts with such a character, vim-autoclose gets to it first
ie trying to get autocomplete to insert "[an, array]" by typing "[_" still yields "[_]".

I've tried to work around this by inserting vim.command("AutoCloseToggle") at various points in the python block in the snippet as well as in the autocomplete function itself, but I can't seem to get it straightened.

Any ideas?

Question information

Language:
English Edit question
Status:
Solved
For:
UltiSnips Edit question
Assignee:
No assignee Edit question
Solved by:
SirVer
Solved:
Last query:
Last reply:
Revision history for this message
Best SirVer (sirver) said :
#1

Well - switching editors I guess.

The problem is that Vim is kinda bad at chaining plugins - it was never intended for plugins to work together in this way. Neither of the plugins can know of each other (except for when they specifically check for clues that the other plugin is installed, like checking if a function of the other plugin is defined and working around the plugin then). The order of the autocommands is as they are defined - but as plugins are loaded alphabetically with plugin managers (except for vundle) this is often no help at all. And even then, it is very likely that the two plugins would confuse each other and you would not get the right thing.

You can try to use UltiSnips to do what the plugin is currently doing for you, but there are problems with this approach as well:
http://www.sirver.net/blog/2011/07/26/anonymous-snippets-in-ultisnips/

Revision history for this message
Brian Gates (bmathg) said :
#2

<i>Well - switching editors I guess.</i>

Right then, I'm off to learn emacs. :)

I just got it to work, I think. In the snippet:

`!p
auto = complete(t, match)
vim.command("AutoCloseOff")
snip.rv = [some text]`$1`!p if (snip.c != auto and (vim.command("AutoCloseOn") is None)) : snip.rv=auto`

I couldn't put the AutoCloseOn after a line break in the snippet or I'd get one in the output, and I couldn't figure out how to have multiple Python commands on the same line. Fortunately vim.command("AutoCloseOn") is always None, so I could sneak it into the if-test. That's probably as fragile as it looks, but it's ok at the moment.