Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

<Tab> inserts '<t_ý>SSuperTabForward' instead of triggering completions #48

Open
StanAngeloff opened this Issue Sep 17, 2012 · 19 comments

Comments

Projects
None yet
6 participants

I have replaced the very old tsaleh/vim-supertab with your project. After updating my .vimrc file, I am experiencing weird issues on Ubuntu 12.04, both in Vim and gVim.

When using <C-P>, <C-N> or <Tab>, I get either <t_ý>SSuperTabBackward or <t_ý>SSuperTabForward inserted. This happens in all buffers at any position.

That seems to be related to msanders/snipmate.vim. After disabling the Snipmate plug-in, Supertab behaves correctly.

Are the two plug-in incompatible? I can see there's code in Supertab to handle Snipmate, but it doesn't seem to be working or is outdated? Anything I can do to help debug/narrow this down?

Oh well, garbas/vim-snipmate works like a charm! Self-close.

EDIT: re-opening as it still happens on <C-P> and <C-N>, but not on <Tab>.

@StanAngeloff StanAngeloff reopened this Sep 17, 2012

ogier commented Sep 19, 2012

For what it's worth, I get similar behavior. In my case it seems that any mapping that contains <Plug> fails to execute. My inserted text is <Plug>SuperTabForward. It's not specific to SuperTab, it's just that SuperTab is one of the only plugins I use that has imap bindings with <Plug>, which means that extraneous text gets inserted instead of the plugin just silently doing nothing. Other plugins such as tpope/vim-surround that use <Plug> for nmap bindings just don't work at all.

This happens on ArchLinux and CentOS 6.3 for me.

ogier commented Sep 19, 2012

So I rooted out the problem. Apparently the way plugins use <Plug> bindings means that their bindings are translated according to langmap. At least, setting langmap to anything that intersected the letters in a <Plug> binding broke the binding for me. I don't know if this is an upstream bug in vim proper or not, but removing my langmap setting fixed these bindings.

Owner

ervandew commented Sep 20, 2012

Can you post an example langmap value which triggers the issue? This could either be a vim bug or it could have to do with the way supertab creates its mappings.

ogier commented Sep 20, 2012

langmap=ef triggers it, for example. Basically, the righthand side of bindings is translated when it gets executed according to langmap. For a silly example, the following works correctly:

:set langmap=px,xp
:inoremap <Tab> <Plug>SuxerTabForward

So far as I can tell, the only way to reliably work around this issue is to have the results of all your mappings be ex-mode commands. Of course, presumably this relies on not remapping the : character (I don't do this, but someone else might).

This seems to be an upstream issue, I can't think of any situations in which translating the right-hand side of a mapping by langmap is useful. I ranted a bit about it on the vim dev mailing list, though they haven't approved my email yet.

Owner

ervandew commented Sep 20, 2012

I'm going to play with it some more tomorrow, but yeah this is looking like a vim issue to me as well. The way the mappings are defined certainly isn't the problem since I can toggle the langmap value and the mappings go from working to not working accordingly in the same vim session.

Thanks for posting the issue to the mailing list. That was going to be my next step. I'm on the list as well so I'll keep an eye out for your message and post any input I have as necessary.

So I rooted out the problem. Apparently the way plugins use <Plug> bindings means that their bindings are translated according to langmap.
@ogier

Ah, interesting. In my case langmap is blank, e.g., there's no value for it. I looked for any bundles that might set it up explicitly, but I couldn't find any.

I've traced it down to ForwardBack. There's something going on with:

exec "let map = \"" . escape(a:map, '<') . "\""

Also in my case pumvisible() is always 0 which is very odd. I'd need to carry on poking around for a while to figure this one out.

Owner

ervandew commented Sep 20, 2012

I've traced it down to ForwardBack.

Can you temporally remove supertab, then startup vim and post the results of the following commands:

:verbose imap <c-n>
:verbose imap <c-p>

Then with supertab re-added, can you restart vim and run those commands again and post the results.

Also in my case pumvisible() is always 0

Can you also post the result of the following:

:verbose set completeopt?

Can you temporally remove supertab, then startup vim and post the results of the following commands:

:verbose imap <c-n>
:verbose imap <c-p>
:verbose imap <c-n>
No mapping found
:verbose imap <c-p>
No mapping found

Then with supertab re-added, can you restart vim and run those commands again and post the results.

:verbose imap <c-n>
i  <C-N>         <C-R>=<SNR>48_ForwardBack("n", "<Plug>SuperTabForward")<CR>
        Last set from ~/.vim/bundle/supertab/plugin/supertab.vim
:verbose imap <c-p>
i  <C-P>         <C-R>=<SNR>48_ForwardBack("p", "<Plug>SuperTabBackward")<CR>
        Last set from ~/.vim/bundle/supertab/plugin/supertab.vim

Can you also post the result of the following:

:verbose set completeopt?
:verbose set completeopt?
  completeopt=menu,preview

For tracing purposes, I changed ForwardBack to:

  function! s:ForwardBack(command, map)
    echom 'a:command = ' . a:command
    echom 'a:map = ' . a:map
    exec "let map = \"" . escape(a:map, '<') . "\""
    echom "let map = \"" . escape(a:map, '<') . "\""
    echom 'pumvisible() = ' . pumvisible()
    echom 'map = ' . map
    return pumvisible() ? s:SuperTab(a:command) : map
  endfunction

and on pressing <C-N> the following results in :messages<CR>:

a:command = n
a:map = <Plug>SuperTabForward
let map = "\<Plug>SuperTabForward"
pumvisible() = 0
map = <80><fd>SSuperTabForward

I hope those help, let me know if I can run anything else.

Owner

ervandew commented Sep 20, 2012

i <C-N> <C-R>=<SNR>48_ForwardBack("n", "<Plug>SuperTabForward")<CR>

That's odd. Do you have supertab installed in more than one place (you can use :scriptnames to see if supertab shows up more than once)? If not, is supertab loading more than once (throw an echom at the top of supertab.vim after the two conditionals)?

I'm managing Vim plug-ins using Vundle (.vimrc for reference). I wiped out all existing bundles just in case:

$ rm -R ~/.vim/bundle
$ vim -c 'BundleInstall' -c 'qa!'

This should give me a pretty clean environment to work from. Here's the output of :scriptnames:

:redir >> ~/.vimscriptnames
:scriptnames
:redir END
  1: /usr/share/vim/vimrc
  2: /usr/share/vim/vim73/debian.vim
  3: /usr/share/vim/vim73/syntax/syntax.vim
  4: /usr/share/vim/vim73/syntax/synload.vim
  5: /usr/share/vim/vim73/syntax/syncolor.vim
  6: /usr/share/vim/vim73/filetype.vim
  7: ~/.vimrc
  8: /usr/share/vim/vim73/ftoff.vim
  9: ~/.vim/autoload/pathogen.vim
 10: /usr/share/vim/vim73/syntax/nosyntax.vim
 11: ~/.vim/bundle/mustache.vim/ftdetect/mustache.vim
 12: ~/.vim/bundle/tmux.vim/ftdetect/tmux.vim
 13: ~/.vim/bundle/vim-coffee-script/ftdetect/coffee.vim
 14: ~/.vim/bundle/vim-coffee-script/ftdetect/eco.vim
 15: ~/.vim/bundle/vim-git/ftdetect/git.vim
 16: ~/.vim/bundle/vim-haml/ftdetect/haml.vim
 17: ~/.vim/bundle/vim-handlebars/ftdetect/handlebars.vim
 18: ~/.vim/bundle/vim-javascript/ftdetect/javascript.vim
 19: ~/.vim/bundle/vim-json/ftdetect/json.vim
 20: ~/.vim/bundle/vim-less/ftdetect/less.vim
 21: ~/.vim/bundle/vim-markdown/ftdetect/markdown.vim
 22: ~/.vim/bundle/vim-task/ftdetect/task.vim
 23: ~/.vim/bundle/vim-zend55/colors/vim-zend55.vim
 24: /usr/share/vim/vim73/ftplugin.vim
 25: /usr/share/vim/vim73/indent.vim
 26: ~/.vim/bundle/vundle/autoload/vundle.vim
 27: ~/.vim/bundle/vundle/autoload/vundle/config.vim
 28: ~/.vim/bundle/detectindent/plugin/detectindent.vim
 29: ~/.vim/bundle/csapprox/plugin/CSApprox.vim
 30: ~/.vim/bundle/tabular/plugin/Tabular.vim
 31: ~/.vim/bundle/gitv/plugin/gitv.vim
 32: ~/.vim/bundle/zencoding-vim/plugin/zencoding.vim
 33: ~/.vim/bundle/tagbar/plugin/tagbar.vim
 34: ~/.vim/bundle/tlib_vim/plugin/02tlib.vim
 35: ~/.vim/bundle/vim-snipmate/plugin/snipMate.vim
 36: ~/.vim/bundle/vim-addon-mw-utils/autoload/funcref.vim
 37: ~/.vim/bundle/vim-snipmate/plugin/snipMateInterface.vim
 38: ~/.vim/bundle/vim-task/plugin/task.vim
 39: ~/.vim/bundle/nerdcommenter/plugin/NERD_commenter.vim
 40: ~/.vim/bundle/nerdtree/plugin/NERD_tree.vim
 41: ~/.vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim
 42: ~/.vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim
 43: ~/.vim/bundle/syntastic/plugin/syntastic.vim
 44: ~/.vim/bundle/gundo.vim/plugin/gundo.vim

Using echom at the top of supertab/plugin/supertab.vim yields two messages. I added:

if exists("loaded_supertab")
  finish
endif
let loaded_supertab = 1

and that seems to fix the issue in question. W00t!

@ervandew ervandew added a commit that referenced this issue Sep 21, 2012

@ervandew ervandew added check to prevent loading supertab more than once
addresses one of the issues reported in #48
7ee7f77
Owner

ervandew commented Sep 21, 2012

That's weird that supertab is loaded twice but doesn't show up in :scriptnames at all.

Hi. I have the same issue as Stan and found this issue. :scriptnames lists supertab exactly once for me. Patch with loaded_supertab check fixed the issue for me as well. Could it be propagated to the mainstream?

Owner

ervandew commented Oct 25, 2012

It was added about a month ago: 7ee7f77

Indeed, thanks. I was using SuperTab-continued. in my Vundle config. Switched to ervandew/supertab.git.

Shirk commented Feb 11, 2013

Just to highlight an issue / feature that happens quiet often with vim plugins:
feedkeys() has an optional second parameter called 'mode' which defaults to 'remap'.

In this case your plugin will probably break if you have langmap's active.
If you use 'n' (noremap) as second parameter to feedkeys() then it will ignore the langmap and work for everyone.
I have to resort to this manual patching frequently as I use a langmap to map hjkl navigation to a dvorak layout.

Owner

ervandew commented Feb 13, 2013

Yes, for cases where the plugin is able to, feedkeys is handy, but in this case vim is modifying the defined mapping even after it has been defined, so I don't see how feedkeys would be helpful in this case, if that's what you are suggesting.

Shirk commented Feb 13, 2013

Indeed you're right since it's already the = that gets mixed up..
In the meantime I had a deeper look at the exact langmap behavior and (just for reference) this will fix it for supertab:

autocmd InsertEnter * let g:saved_langmap=&langmap | set langmap&
autocmd InsertLeave * let langmap=g:saved_langmap

Still not an ideal solution but at least a workaround.

mknod commented Mar 18, 2013

I wanted to let others know that I had this problem and it was caused by 2 system installed plugins that were conflicting with my vundle install. On arch I did a pacman -R vim-ultisnips vim-supertab and after that I was able to happily use supertab again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment