lifepillar / vim-mucomplete

Chained completion that works the way you want!
MIT License
913 stars 18 forks source link

UltiSnips support #11

Closed markwu closed 8 years ago

markwu commented 8 years ago

Problems summary

UltiSnips's ForwardTrigger and BackwardTrigger not working

Environment Information

set nocompatible
filetype off

execute 'source ~/.vim/bundle/vim-plug/plug.vim'
call plug#begin('~/.vim/bundle/')

Plug 'junegunn/vim-plug'

" Put your bundle below here
Plug 'lifepillar/vim-mucomplete'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
" Put your bundle above here

call plug#end()

syntax on
filetype plugin indent on

" Put your plugin settings below here
let g:mucomplete#enable_auto_at_startup = 1

let g:UltiSnipsUsePythonVersion = 2
let g:UltiSnipsExpandTrigger="<C-J>"
let g:UltiSnipsJumpForwardTrigger="<C-J>"
let g:UltiSnipsJumpBackwardTrigger="<C-K>"
" Put _our plugin settings above here

The reproduce ways from Vim starting (Required!)

  1. :e test.php or set ft=php
  2. type foreach the popup menu will show up, choose it and hit <C-J> to expand it, then you can't not use <C-J> to jump next position

    Screen shot (if possible)

mucomplete

calebeby commented 8 years ago

Yeah, this would be useful.

lifepillar commented 8 years ago

I use UltiSnips with similar settings as yours, and I don't see conflicts. Could you please provide a step-by-step way to reproduce your problem?

markwu commented 8 years ago

Okay, I'll prepare a minimal vimrc and screencasts for you.

markwu commented 8 years ago

Hi @lifepillar I just update the comment with minimal vimrc and screencast, hope this help.

lifepillar commented 8 years ago

Ah, now I see. Could you please play a bit with the ultisnips-bug branch to see if things work better for you?

markwu commented 8 years ago

Thanks, It works like a charm.

lifepillar commented 8 years ago

Thanks for the feedback. The fix is not final (you may have issues with automatic completion stopping to work after completing a snippet), but at least I have an idea of how to solve this issue.

lifepillar commented 8 years ago

Ok, I have investigated that. It happens only with certain snippets. The specific example you have shown can be solved by editing php.snippets and putting the w flag next to the foreach snippet:

snippet foreach "foreach ($var as $value) { .. }" w
    foreach ($${1:variable} as $${2:value}) {
        ${0}
    }

So, I don't think that this is something that should be fixed in µcomplete.

calebeby commented 8 years ago

Can I use ultisnips in master branch yet, or is this functionality still in the other one?

lifepillar commented 8 years ago

Use master.

markwu commented 8 years ago

The problem is current UltiSnips and vim-snippets works great with YouCompletMe and NeoComplete, it must be something conflict between mucomplete and these plugins.

If you can give me some ideas why this happened, I'll do some investigations on this problem.

Thanks.

lifepillar commented 8 years ago

So far, I have only noted that snippets with flags like w do not have conflicts.

markwu commented 8 years ago

I turned off mucomplete auto completion, everything just works.

So, it might be UltiSnips forward jump trigger hijacked by something inside TextChangeI event.

Or, it also could be UltiSnips thinks no need to jump.

markwu commented 8 years ago

mucomplete

I compose a new screencast

  1. You can see in the first foreach, I keep hit <C-J>, it can expand and jump without any problems.
  2. In the second foreach, I typed $items and hit <C-J>, nothing happened.

How interesting.

lifepillar commented 8 years ago

Removing the 'omni' method from the completion list fixes the bug. So, the problem is a bad interaction between PHP's omnifunc function and UltiSnips. In fact, turn off µcomplete and type:

foreach<c-j>items<c-x><c-o>

and then <c-j> is screwed up. So, I stand by my assertion that this is not a problem for µcomplete to solve.

markwu commented 8 years ago

Okay, I just did the same test as you did, you convince me, you are right.

It seems phpcomplete break ultisnips, I tried javascript omni complete, it works great.

I'll report this issue to https://github.com/shawncplus/phpcomplete.vim .

Thanks.

markwu commented 8 years ago

Thanks for your hint.

I guess the problem never happened in YouCompleteMe & NeoComplete, because they just use phpcomplete.vim as a source to get candidate list and use their own customized complete function to complete the word.

markwu commented 7 years ago

@lifepillar

I think @complex857 (The maintainer of phpcomplete.vim) already fixed this bug in this commit https://github.com/shawncplus/phpcomplete.vim/commit/1d0041837432033593d407e4494939f3c4e411f8.

And, I already tested it with mucomplete and Ultisnips, these three plugins works great together.

Just for your information and thanks for your help.