Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get this func.help wanted!! #1779

Closed
wsdjeg opened this issue Nov 15, 2015 · 21 comments
Closed

how to get this func.help wanted!! #1779

wsdjeg opened this issue Nov 15, 2015 · 21 comments

Comments

@wsdjeg
Copy link

wsdjeg commented Nov 15, 2015

hi @Valloric
i have add this to my vimrc

        let g:ycm_semantic_triggers =  {
                    \   'c' : ['->', '.'],
                    \   'objc' : ['->', '.'],
                    \   'ocaml' : ['.', '#'],
                    \   'cpp,objcpp' : ['->', '.', '::'],
                    \   'perl' : ['->'],
                    \   'php' : ['->', '::'],
                    \   'cs,javascript,d,python,perl6,scala,vb,elixir,go' : ['.'],
                    \   'java,jsp' : ['.'],
                    \   'vim' : ['re![_a-zA-Z]+[_\w]*\.'],
                    \   'ruby' : ['.', '::'],
                    \   'lua' : ['.', ':'],
                    \   'erlang' : [':'],
                    \ }

so afte '.',the completion words will,also i do not type every char of the string.
for example if i want get finalize() i just need to type fz
2015-11-15 15-27-22
but in this case

after Sys i start the completion manually by type <c-space>
get this result
2015-11-15 15-28-43
if i want SystemTray i need to type every char of this string,i hope just type less char to get the result i wantted

@wsdjeg
Copy link
Author

wsdjeg commented Nov 15, 2015

@artur-shaik i think maybe you kown what i want,i have read you vimrc,but i can not find the related configration

@vheon
Copy link
Contributor

vheon commented Nov 15, 2015

        let g:ycm_semantic_triggers =  {
                    \   'c' : ['->', '.'],
                    \   'objc' : ['->', '.'],
                    \   'ocaml' : ['.', '#'],
                    \   'cpp,objcpp' : ['->', '.', '::'],
                    \   'perl' : ['->'],
                    \   'php' : ['->', '::'],
                    \   'cs,javascript,d,python,perl6,scala,vb,elixir,go' : ['.'],
                    \   'java,jsp' : ['.'],
                    \   'vim' : ['re![_a-zA-Z]+[_\w]*\.'],
                    \   'ruby' : ['.', '::'],
                    \   'lua' : ['.', ':'],
                    \   'erlang' : [':'],
                    \ }

This doesn't seems relevant to the question.

You're talking about java code for which we don't provide a native semantic engine so you have to rely on some vimscript omnifunc. When we call the omnifunc for you (after a . in this example) then we are able to handle the normal behaviour of YCM and provide fuzzy search of the candidates. When you type <C-Space> to force completion then we simply do <C-X><C-O><C-P> which means that in this particular case all we do is call the vim omnifunc and there is no way for us to provide the same experience. Closing since this is not a YCM bug but a vim limitation more than everything. If I misunderstood something we can always reopen this.

@vheon vheon closed this as completed Nov 15, 2015
@wsdjeg
Copy link
Author

wsdjeg commented Nov 15, 2015

i have understand what you mean,thank you ,you mean after '.' YCM no only call omnifunc ,but also provide some fuzzy search,but c-space only call omni,just like type c-x c-o c-p

@puremourning
Copy link
Member

This is an interesting case: use YCM's OmniCompleter instead of just invoking omnicompletion when hitting the g:ycm_key_invoke_completion sequence in non-semantic supported files.

The use-case seems would be likely most useful when using something like eclim in combination with YCM, or, say another plugging providing a useful omnifunc (e.g. the one that currently works for racer, etc.).

Sounds fiddly to implement and probably rather niche. FWIW I believe we'd have to map the trigger to something like <C-R>=youcompleteme#InvokeOmniCompleter()<CR> and then have some way to force CreateCompletionRequest to ask the omni-completer. All very messy I think.

@vheon
Copy link
Contributor

vheon commented Nov 15, 2015

All very messy I think.

@puremourning I believe that is why is the way it is currently :)

@puremourning
Copy link
Member

Hah yes. Well I was bored (it's Sunday and it's dark and cold), so I have made a prototype of this and it isn't anywhere near as ugly as I thought. I'll post a demo in a bit, see what you all think.

@vheon
Copy link
Contributor

vheon commented Nov 15, 2015

@puremourning 👍

@puremourning
Copy link
Member

OK It took me longer than I expected. It was working very nicely, except it didn't work for any of my supposed use cases (specifically: eclim and vim-racer). Joy. Anyway that turned out to be a sort-of-bug in YCM in the way it interacts with the omnifunc. It's quite detailed, so I'll spare you the explanation for now, but here's a quick demo using eclim (for java) and vim-racer (for rust).

In each test I type some stuff like Sys and f then hit <C-Space>. I think use YCM's word-boundary-chars fuzzy search to narrow down the list.

eclim

ycm-omnicompleter-force-java

vim-racer

ycm-omnicompleter-force

It's not perfect as the initial query string must be a real prefix, but interested in thoughts.

@vheon
Copy link
Contributor

vheon commented Nov 15, 2015

@puremourning so let's say that you don't type anything and press <C-Space> it would then provide fuzzy search?

@puremourning
Copy link
Member

yes, sort of. Actually, the g:ycm_cache_omnifunc sort of gets in the way of this - it doesn't re-query each time i don't think. I haven't looked into it much yet.

I've pushed the code here: https://github.com/puremourning/YouCompleteMe/tree/force-omni-completer

note - it's really just a prototype/hack at the moment, so please don't think less of me if it is ugly and poorly tested 😁

@wsdjeg
Copy link
Author

wsdjeg commented Nov 16, 2015

it is very strange why javacomplete cannot do that,it is the func of ycm or eclim

@puremourning
Copy link
Member

@vheon actually, it seems to work. I tried it with the problematic php completer:

ycm-omnicompleter-force-php

@wsdjeg The demo above is with some changes to YCM. I haven't used javacomplete, but you're welcome to check out my branch and see if it works for you.

@wsdjeg
Copy link
Author

wsdjeg commented Nov 16, 2015

greate,i hope this for a long time ,and i will check it tonoght,if it works well,i think most omnifunc will be nicer,such as origin html xml omnifuc

@puremourning
Copy link
Member

gave it a quick test - seems to work with javacomplete2.

@wsdjeg
Copy link
Author

wsdjeg commented Nov 16, 2015

greate,i think @artur-shaik will be glad to hear this!

@artur-shaik
Copy link

@puremourning nice work. Thank you.
@wsdjeg thank you for mention.

@wsdjeg
Copy link
Author

wsdjeg commented Nov 16, 2015

@artur-shaik @puremourning
i have check this branch,for java html xml js css and any other vim origin omnifunc ,it works very well,but still has some issue!
for example

not work well with BackSpace

here is out put for Sys
2015-11-16 19-50-08
then i type t or any other char will get nothilng but then i type backspace type t again, will get this
2015-11-16 19-52-57
maybe first time get result but second time will not

you can try with type any char and type backspace and type this char again

error with complete java annotation

here is javacomplete OUT PUT OF C-X C-O
2015-11-16 20-01-29

and here is YCM
2015-11-16 20-01-44

because YCM donot check @
the output just same as Ove
2015-11-16 20-13-39

after @Override
both words well and both of ycm and javacomplet can not search ,just need tpye c-n or c-p to select what i want.
2015-11-16 20-17-58

MAYBE THIS IS THE FEAUTURE OF JAVACOMPLETE2

@puremourning
Copy link
Member

Thanks for testing

I think it is because YCM doesn't consider @ to be an identifier character, though I thought thought my branch would use the omnifunc decision about that. Probably YCM internals. I'll look when inhale some time.

@wsdjeg
Copy link
Author

wsdjeg commented Nov 16, 2015

thank you

@puremourning
Copy link
Member

Well, this particular problem with javacomplete and @ symbols in completions is quite difficult to fit into YCM's ethos. I had a go, but unfortunately couldn't find a simple solution. Maybe I will look more, but no promises, as even if I get it to work, the other devs. might not love the solution 😁

@wsdjeg
Copy link
Author

wsdjeg commented Nov 17, 2015

yes how about iusse with backspace

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants