roxma / nvim-completion-manager

:warning: PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
MIT License
917 stars 49 forks source link

Possibility to prioritize source of popup window #116

Open sassanh opened 7 years ago

sassanh commented 7 years ago

Currently if in a python buffer I type:

import requests
requests.pos

and select "post" from autocompletion list popup window shows:

snippet@0

If I disable ultisnips and restart vim I get

post(url, data=None, json=None, **kwargs)
    Sends a POST request.

    :param url: URL for the new :class:`Request` object.
    :param data: (optional) Dictionary (will be form-encoded), bytes, or file-like object to send in the body of the :class:`Request`.
    :param json: (optional) json data to send in the body of the :class:`Request`.
    :param \*\*kwargs: Optional arguments that ``request`` takes.
    :return: :class:`Response <Response>` object
    :rtype: requests.Response

Is it possible to achieve this without disabling ultisnips? some way to prioritize python help over ultisnips for popup window.

roxma commented 7 years ago

The snippet@0 is a workaround for snippet expansion, it is appended to the preview window, it does not control the display of the docstring Sends a POST request. if it exists.

It seems this is a behavior of the jedi library.

Here's my test on jedi-vim's omnifunc with set completeopt=menu,menuone,noinsert,noselect,preview:

Test 1:

import requests
requests.<c-x><c-o>

Then select the post item, the preview window does not appear

Test 2:

import requests
requests.pos<c-x><c-o>

Then select the post item, the preview window appears

// cc @davidhalter

minimal vimrc:

set nocompatible                     
syntax on                            
filetype plugin indent on            
set encoding=utf-8 fileencodings=ucs-bom,utf-8,gbk,gb18030,latin1 termencoding=utf-8                                                                  

call plug#begin(expand('<sfile>:h') . '/plugged/')                         
Plug 'davidhalter/jedi-vim'          
call plug#end()                      

set completeopt=menu,menuone,noinsert,noselect,preview  

gif:

peek 2017-08-18 10-13

sassanh commented 7 years ago

Well I think that's another issue or maybe I didn't get the relation. To clarify: my problem is when I have ultisnips disabled it shows doc string but when ultisnips is enabled instead of docstring it shows snippet@0. I want to somehow have docstring even when ultisnips is enabled.

sassanh commented 7 years ago

I confirm even when ultisnips is disabled it doesn't show docstring when I type request.p and then select post. But with ultisnips disabled it does show docstring with request.pos and then selecting post and when ultisnips is enabled it shows snippet@0 even when I type request.pos and then select post.

roxma commented 7 years ago

Well I think that's another issue or maybe I didn't get the relation

When the docstring returned by jedi is empty, but there's a snippet for the item, it only shows the snippet.

I want to somehow have docstring even when ultisnips is enabled.

Ultisnips should not affect the display of docstring if it's not empty. And I cannot reproduce the issue you described.

peek 2017-08-18 10-13

roxma commented 7 years ago

and when ultisnips is enabled it shows snippet@0 even when I type request.pos and then select post.

NCM caches the result when you typed ., in this case, you need to force refresh with the <Plug>(cm_force_refresh) key when the cursor is at pos|.

roxma commented 7 years ago

This gif shows my point.

peek 2017-08-18 10-13

sassanh commented 7 years ago

Yeah seems like it's related to cache. Is it possible to disable cache altogether?

roxma commented 7 years ago

Is it possible to disable cache altogether?

Not possible with current version. The cache control is hard-coded by ncm's jedi source.

sassanh commented 7 years ago

OK, thanks for info.

roxma commented 7 years ago

I decided to disable the caching of jedi source.

You could test this PR #128

roxma commented 7 years ago

This is how it looks like. I believe it should still be considered as an upstream bug.

116

sassanh commented 7 years ago

Unfortunately it doesn't work for me: https://asciinema.org/a/5XU59J75bDiC3pFgpwj6tu17S

roxma commented 7 years ago

It seems the no-cache version slows things down.

And unfortunately this will make fuzzy matching impossible, since jedi doesn't have builtin fuzzy matching: https://github.com/davidhalter/jedi/issues/827

roxma commented 7 years ago

Maybe I should revert the change.

sassanh commented 7 years ago

Yeah seems like we should wait for jedi.

roxma commented 7 years ago

I've pushed another update. Please test it in case the no-cache is not the cause.

sassanh commented 7 years ago

It's working for me now. Thanks.