ncm2 / ncm2-jedi

MIT License
23 stars 11 forks source link

Completion doesn't work inside markdown subscope #11

Closed gaalcaras closed 5 years ago

gaalcaras commented 6 years ago

Subscopes is one of my favourite features in ncm2. It works for CSS and some other sources, but not for ncm2-jedi.

Reproducible example

Minimal vimrc

call plug#begin('~/.vim/plugged')

Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-markdown-subscope'
Plug 'ncm2/ncm2-jedi'

call plug#end()

autocmd BufEnter * call ncm2#enable_for_buffer()
set completeopt=noinsert,menuone,noselect
set shortmess+=c

Markdown example

Hello world

```python
import re
``` 

Completion doesn't happen, ncm2-jedi doesn't suggest modules for instance.

Debug log

2018-11-16 14:36:14,865 [DEBUG @ ncm2_core.py:check_source_notify:273] 21552 - jedi is not ready
2018-11-16 14:36:14,869 [DEBUG @ ncm2_core.py:check_source_notify:273] 21552 - jedi is not ready

Temporary fix

As the log says, it seems like jedi has not yet been set to ready. Instead of setting it ready with yarp, just setting ready by default restores the expected behaviour:

let g:ncm2_jedi#source = extend(get(g:, 'ncm2_jedi#source', {}), {
            \ 'name': 'jedi',
            \ 'priority': 9,
            \ 'mark': 'py',
            \ 'scope': ['python'],
            \ 'subscope_enable': 1,
            \ 'complete_pattern': [
            \       '^\s*(import|from).*\s',
            \       '\.',
            \       '\(\s?',
            \       ',\s?'],
            \ 'on_complete': 'ncm2_jedi#on_complete',
            \ 'on_warmup': 'ncm2_jedi#on_warmup',
\ }, 'keep')

Maybe the bug has more to do with ncm2 itself? It seems to me that when it detects a subscope, it should be able to set the source to ready.

roxma commented 5 years ago

Fixed in https://github.com/ncm2/ncm2/issues/101