Townk / vim-autoclose

This plugin for Vim enable an auto-close chars feature for you. For instance if you type an '(', ``autoclose`` will automatically insert a ')' and put the cursor between than.
http://townk.github.com/vim-autoclose/
503 stars 66 forks source link

Incompatibility with other plugins and <Enter> maps #25

Closed Townk closed 12 years ago

Townk commented 12 years ago

I just receive this bug report by email and I don't want to loose track of it:


Whenever I use an auto-complete feature (the built-in VIM one or omnicppcomplete) an annoying effect appears: if the auto-complete popup is visible and I press to select the current option, the current option is inserted after the cursor (as should be), but, unfortunately, a carriage return is also inserted (as shouldn't be).

I have the following details: If I disable autoclose, the carriage return is not inserted. If I comment out the line inoremap =Enter() in CreateExtraMaps, the carriage return is not inserted, but this, of course, disables the really nice indentation of a {} block that you have implemented. At the moment, I am forced to live with this option as the insertion is much more distracting. My understanding is that this behavior is a result of a misinteraction between autocomplete and supertab because without supertab, the default behavior for vim is to insert the carriage return after hitting enter. However, supertab adds the nice functionality of just completing the selection on and I would like to keep that if possible.


artm commented 12 years ago

Ah, I see. I'll have to look into that, the Enter / Space expansion is still a bit experimental.

artm commented 12 years ago

do I get it right, to see this problem I need just our plugin + supertab?

Townk commented 12 years ago

I think so, but I honestly didn't had time to test it myself

glanotte commented 12 years ago

I am experiencing a conflict between the two. checking out head on both breaks the end behavior in ruby. I was able to isolate it to the most recent commit for your repo, and the conflict was with vim-endwise. I did catch some weirdness with supertab as well, but it was less defined.

If I create a new file foo.rb and type def foo<cr>, no end is created.

if I checkout the b63af10761e5b783aecd189847c73ca3202bb5fd commit, the behavior is fixed.

I hope this helps.

sanchopansa commented 12 years ago

@artm Hi -- I was the person to originally report the issue, so I thought I would clarify, since github seems to have stripped portions of my email posted above by Townk.

  1. You only need supertab and autoclose to reproduce this.
  2. Open a file for editing in vim, enter insert mode and use the built-in vim autocompletion c-x c-p. Supertab allows you to use tab to cycle through the available options. Hit Enter on one of the options: the option is inserted after the cursor, but also a newline is inserted.
  3. Remove autoclose and repeat the steps in 2. The text is inserted and this time no new line is inserted.

Thanks for looking into this and let me know if you cannot reproduce it and/or if you need additional details.

thenoseman commented 12 years ago

@glanotte: workaround in your .vimrc: let g:AutoCloseExpandEnterOn = ""

glanotte commented 12 years ago

@thenoseman:

Thanks, it worked like a charm

installero commented 12 years ago

@thenoseman:

Thanx! That worked for me too!

Townk commented 12 years ago

As far as I could check here this problem happens because of the popup menu being shown. We do have an option on AutoClose that lets you define a special behavior for certain keys when the popup menu is visible.

Using this allow you to tell AutoClose to issue a "" when is pressed and the popup menu is visible. This most likely will fix the "Compatibility" problem with SuperTab.

Here is what I use on my own .vimrc:

let g:AutoClosePumvisible = {"Esc": "", "Enter": ""}

I'll add these maps as the default behavior so no one has to worry about this in the future.

alexbel commented 11 years ago

It seems to me that supertab capability problem still appears. I've tried clean vim installation on openSUSE and on ubuntu with latest versions of supertab and autoclose. When you hit ESC on element in popup menu, this element actually will not appear. The text would be the same as you typed and vim would be in 'insert' mode instead of 'normal' mode.