Coder Social home page Coder Social logo

ncm2-jedi's Introduction

ncm2-jedi

Python completion for ncm2 via the great jedi library.

Config

g:ncm2_jedi#python_version

Defaults to 3.

If set to 2, the jedi completion process is started with the python specified by :help g:python_host_prog.

If set to 3, the jedi completion process is started with the python specified by :help g:python3_host_prog.

g:ncm2_jedi#environment

Read jedi-environments for more information.

If this option is not set, ncm2-jedi uses the following priority scheme:

  • $VIRTUAL_ENV -> jedi.get_default_environment
  • $CONDA_PREFIX
  • jedi.get_default_environment

g:ncm2_jedi#settings

Defaults to {}.

Read jedi-settings for more information.

g:ncm2_jedi#call_sig_hint

Defaults to 1

Set it to 0 to disable function argument hint

ncm2-jedi's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ncm2-jedi's Issues

AttributeError: 'PosixPath' object has no attribute 'endswith'

Hello, I am using neovim v0.4.4 on arch linux. I have python, python-pynvim, python-jedi packages installed. But ncm2_jedi does not work. The error message shown at the bottom is : [ncm2_jedi@yarp] AttributeError: 'PosixPath' object has no attribute 'endswith' .

Recursion error on completion

When you try to complete on a stdlib module, a recursion error occurs.

Minimal Example

import os

os.get<trigger completion>

Error traceback

...
[ncm2_jedi@yarp]     doc += name.py__doc__()
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/names.py", line 634, in py__doc__
[ncm2_jedi@yarp]     return _merge_name_docs(names)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/names.py", line 22, in _merge_name_docs
[ncm2_jedi@yarp]     doc += name.py__doc__()
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/names.py", line 236, in py__doc__
[ncm2_jedi@yarp]     return _merge_name_docs(names)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/names.py", line 22, in _merge_name_docs
[ncm2_jedi@yarp]     doc += name.py__doc__()
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/names.py", line 634, in py__doc__
[ncm2_jedi@yarp]     return _merge_name_docs(names)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/names.py", line 22, in _merge_name_docs
[ncm2_jedi@yarp]     doc += name.py__doc__()
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/names.py", line 236, in py__doc__
[ncm2_jedi@yarp]     return _merge_name_docs(names)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/names.py", line 22, in _merge_name_docs
[ncm2_jedi@yarp]     doc += name.py__doc__()
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/names.py", line 628, in py__doc__
[ncm2_jedi@yarp]     names = convert_names(names, prefer_stub_to_compiled=False)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/gradual/conversion.py", line 141, in convert_names
[ncm2_jedi@yarp]     names, prefer_stub_to_compiled=prefer_stub_to_compiled)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/utils.py", line 20, in wrapper
[ncm2_jedi@yarp]     return list(func(*args, **kwargs))
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/gradual/conversion.py", line 63, in _try_stub_to_python_names
[ncm2_jedi@yarp]     values = convert_values(name.infer(), ignore_compiled=prefer_stub_to_compiled)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/gradual/conversion.py", line 157, in convert_values
[ncm2_jedi@yarp]     for stub_value in values
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/common/value.py", line 32, in from_sets
[ncm2_jedi@yarp]     for set_ in sets:
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/gradual/conversion.py", line 157, in <genexpr>
[ncm2_jedi@yarp]     for stub_value in values
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/gradual/conversion.py", line 28, in _stub_to_python_value_set
[ncm2_jedi@yarp]     values = _infer_from_stub(stub_module_context, qualified_names, ignore_compiled)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/gradual/conversion.py", line 50, in _infer_from_stub
[ncm2_jedi@yarp]     non_stubs = non_stubs.py__getattribute__(name)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/base_value.py", line 395, in py__getattribute__
[ncm2_jedi@yarp]     return ValueSet.from_sets(c.py__getattribute__(*args, **kwargs) for c in self._set)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/common/value.py", line 32, in from_sets
[ncm2_jedi@yarp]     for set_ in sets:
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/base_value.py", line 395, in <genexpr>
[ncm2_jedi@yarp]     return ValueSet.from_sets(c.py__getattribute__(*args, **kwargs) for c in self._set)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/base_value.py", line 88, in py__getattribute__
[ncm2_jedi@yarp]     names = self.goto(name_or_str, name_context, analysis_errors)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/base_value.py", line 77, in goto
[ncm2_jedi@yarp]     names = finder.filter_name(filters, name_or_str)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/finder.py", line 36, in filter_name
[ncm2_jedi@yarp]     names = filter.get(string_name)
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/filters.py", line 240, in get
[ncm2_jedi@yarp]     return [n for filter in self._filters for n in filter.get(name)]
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/filters.py", line 240, in <listcomp>
[ncm2_jedi@yarp]     return [n for filter in self._filters for n in filter.get(name)]
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/filters.py", line 82, in get
[ncm2_jedi@yarp]     _get_definition_names(self._used_names, name),
[ncm2_jedi@yarp]   File "~/.pyenv/versions/py3nvim/lib/python3.7/site-packages/jedi/inference/filters.py", line 57, in _get_definition_names
[ncm2_jedi@yarp]     for_module = _definition_name_cache[used_names]
[ncm2_jedi@yarp]   File "~/.pyenv/versions/3.7.6/lib/python3.7/weakref.py", line 396, in __getitem__
[ncm2_jedi@yarp]     return self.data[ref(key)]
[ncm2_jedi@yarp] RecursionError: maximum recursion depth exceeded

health#jedi#check

jedi

Jedi-vim debug information

jedi-vim version
  • jedi-vim git version: e83112f
  • jedi git submodule status: 3ad3dc08b8bf9d749b2d0d9fca038657711c82f2 pythonx/jedi (v0.16.0-11-g3ad3dc08)
  • parso git submodule status: c864ca60d1a2f36524a4f79013a7de223e65e19d pythonx/parso (v0.6.0)
Global Python

Using Python version 3 to access Jedi.

  • global sys.executable: ~/.pyenv/versions/py3nvim/bin/python
  • global sys.version: 3.7.6 (default, Jan 15 2020, 11:43:24), [GCC 7.4.0]
  • global site module: ~/.pyenv/versions/3.7.6/lib/python3.7/site.py
Jedi
  • path: ~/.local/share/nvim/plugged/jedi-vim/pythonx/jedi/jedi/__init__.py
  • version: 0.16.1
Jedi environment: <SameEnvironment: 3.7.6 in /home/bosdch1/.pyenv/versions/py3nvim>
  • executable: /home/bosdch1/.pyenv/versions/py3nvim/bin/python
  • sys_path:
    • ~/.pyenv/versions/3.7.6/lib/python37.zip
    • ~/.pyenv/versions/3.7.6/lib/python3.7
    • ~/.pyenv/versions/3.7.6/lib/python3.7/lib-dynload
    • ~/.pyenv/versions/py3nvim/lib/python3.7/site-packages
Known environments
  • <Environment: 3.6.9 in /usr> (/usr/bin/python3.6)

  • <Environment: 2.7.17 in /usr> (/usr/bin/python2.7)

Settings
g:jedi#goto_stubs_command = '' (default: '<leader>s')
g:jedi#usages_command = 'gr' (default: '<leader>n')
g:jedi#completions_command = '' (default: '<C-Space>')
g:jedi#rename_command = '<leader>rn' (default: '<leader>r')
g:jedi#goto_assignments_command = '' (default: '<leader>g')
g:jedi#goto_command = 'gd' (default: '<leader>d')
g:jedi#completions_enabled = 0 (default: 1)

health#provider#check

Clipboard (optional)

  • OK: Clipboard tool found: xclip

Python 2 provider (optional)

  • INFO: pyenv: Path: ~/.pyenv/libexec/pyenv
  • INFO: pyenv: Root: ~/.pyenv
  • INFO: Using: g:python_host_prog = "~/.pyenv/versions/py2nvim/bin/python"
  • INFO: Executable: ~/.pyenv/versions/py2nvim/bin/python
  • INFO: Python version: 2.7.16
  • INFO: pynvim version: 0.4.1
  • WARNING: Could not contact PyPI to get latest version.
  • ERROR: HTTP request failed: error: curl error with https://pypi.python.org/pypi/pynvim/json: 6

Python 3 provider (optional)

  • INFO: pyenv: Path: ~/.pyenv/libexec/pyenv
  • INFO: pyenv: Root: ~/.pyenv
  • INFO: Using: g:python3_host_prog = "~/.pyenv/versions/py3nvim/bin/python"
  • INFO: Executable: ~/.pyenv/versions/py3nvim/bin/python
  • INFO: Python version: 3.7.6
  • INFO: pynvim version: 0.4.1
  • WARNING: Could not contact PyPI to get latest version.
  • ERROR: HTTP request failed: error: curl error with https://pypi.python.org/pypi/pynvim/json: 6

Python virtualenv

  • OK: no $VIRTUAL_ENV

Output of :version

NVIM v0.5.0-363-g31614d3eb
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-pr
ototypes -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/
travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/ho
me/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-42ac83d1-057a-458c-bd3f-e8353b2ab058

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/home/travis/build/neovim/bot-ci/build/neovim/build/nvim.AppDir/usr/share/nvim"

function hints out of window

2019-08-26 14-08-06 的屏幕截图

the popup hint of func's args out of window bound, there are three problems:

  • the popup can be more left;
  • the 'param' word is not need;
  • the popup should be fold to multi lines.

ncm2-jedi is not work

I add ncm2-jedi and ncm2-go,ncm2-go works well
when I open new python file , it just tell me
[ncm2_jedi@yarp] Job is dead. cmd=['/usr/local/opt/python/bin/python3.7', '-u',.......

Neovim gutter icon inconsistant.

I am getting this weird behaviour. If i write some garbage, I get the correct gutter icon like so:

screenshot

When I correct the mistake, the gutter icon persists. Any idea?

screenshot2

when edit .py file in neovim,it shows TypeError.

[ncm2_jedi@yarp] TypeError: init() takes from 1 to 2 positional arguments but 5 positional arguments (and 1 keywo
rd-only argument) were given
^show with red in command area
also it give me no keyword in floating window.
How can i fix it?

Possible speed up option by disabling type information

Hi there,

First, thanks for this awesome autocomplete plugin!

You may know that jedi can be quit slow for big libraries (e.g. see #4). However retrieving the completions is actually quite fast, but requesting the types/description of those is slow (davidhalter/jedi#1116).

Completion can be sped up by seconds by changing the lines requesting the type/description. In particular:

menu=complete.description,

if (complete.type == 'function' or complete.type == 'class'):

I think this will break snippet support (I do not know since I do not use it)

E.g. this change makes initial completion of tensorflow go from 8 seconds to 1-2 seconds on my machine.

Maybe it is nice to add a 'speed' option. I could give it a go and create a pull request if you like?

PS: if you use my hacky fork of jedi, variable name completion becomes nearly instant: https://github.com/HansPinckaers/jedi

Thanks again,
Hans

why my ncm2-jedi does not identify third-party module

First of all ,thank you very much for doing great job .It works very well on my archlinux when I develop C program.But when I develop Python program , it can not identify third-party module like pandas,numpy.I use virtualenv python 3.6.5. Can you help me?

[ncm2_jedi@yarp] Job is dead

I'm on mac. I've been able to trace the error, not sure what to do next:

ncm2_jedi.vim:
18 if g:ncm2_jedi#python_version != 2 19 let g:ncm2_jedi#proc = yarp#py3('ncm2_jedi') 20 else

nvim-yarp/pythonx/yarp.py
nvim.call('yarp#core#channel_started', yarpid, nvim.channel_id)

the actual call:
args: ['~/.vim/bundle/nvim-yarp/pythonx/yarp.py', '/var/folders/jg/ftzn1w1d0p10bn6znb8y5pfc0000gp/T/nvimusOWoh/0', '3', 'ncm2_jedi']

in the above, the socket file is wrong, every time. If manually run the command with the right file, it seems to run with out errors

any help is appreciated

Looks like jedi is not handling f-strings properly

If you try autocompletion on this snippet, just try to insert an extra " in the printf(f"wh line, you'll see that jedi is returning bad results, looks like jedi doesn't fully support f-strings yet:

#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    """Main function."""
    print(f"wh)


if __name__ == "__main__":
    main()

2019-02-02 08:47:03,905 [INFO @ ncm2_jedi.py:on_complete:54] 15064 - context [{'filepath': '/home/viniarck/repos/algos-structures-python/f_strs.py', 'typed': '    print(f"wh', 'scope_match': 'python', 'startccol': 13, 'mode': 'i', 'word_pattern': '(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\\'\\"\\,\\.\\<\\>\\/\\?\\s]+)', 'time': 1549104423.904316, 'lnum': 7, 'bufnr': 2, 'changedtick': 157, 'manual': False, 'base': 'wh', 'ccol': 15, 'filetype': 'python', 'curpos': [0, 7, 15, 0, 15], 'tick': [[0, 7, 15], 0], 'early_cache': False, 'context_id': 119, 'scope': 'python', 'matcher': {'name': 'abbrfuzzy'}, 'source': {'subscope_enable': 1, 'early_cache': 0, 'name': 'jedi', 'scope': ['python'], 'mark': 'py', 'on_warmup': 'ncm2_jedi#on_warmup', 'ready': 1, 'enable': 1, 'auto_popup': 1, 'priority': 9, 'complete_pattern': ['^\\s*(import|from).*\\s', '\\.', '\\(\\s?', ',\\s?'], 'on_complete': 'ncm2_jedi#on_complete'}, 'scope_level': 1, 'bcol': 15, 'match_end': 12}]
2019-02-02 08:47:03,906 [WARNING @ session.py:handler:221] 15064 - error caught while processing notification 'b'on_complete' [{b'filepath': b'/home/viniarck/repos/algos-structures-python/f_strs.py', b'typed': b'    print(f"wh', b'scope_match': b'python', b'startccol': 13, b'mode': b'i', b'word_pattern': b'(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\\'\\"\\,\\.\\<\\>\\/\\?\\s]+)', b'time': 1549104423.904316, b'lnum': 7, b'bufnr': 2, b'changedtick': 157, b'manual': False, b'base': b'wh', b'ccol': 15, b'filetype': b'python', b'curpos': [0, 7, 15, 0, 15], b'tick': [[0, 7, 15], 0], b'early_cache': False, b'context_id': 119, b'scope': b'python', b'matcher': {b'name': b'abbrfuzzy'}, b'source': {b'subscope_enable': 1, b'early_cache': 0, b'name': b'jedi', b'scope': [b'python'], b'mark': b'py', b'on_warmup': b'ncm2_jedi#on_warmup', b'ready': 1, b'enable': 1, b'auto_popup': 1, b'priority': 9, b'complete_pattern': [b'^\\s*(import|from).*\\s', b'\\.', b'\\(\\s?', b',\\s?'], b'on_complete': b'ncm2_jedi#on_complete'}, b'scope_level': 1, b'bcol': 15, b'match_end': 12}, [b'#!/usr/bin/env python', b'# -*- coding: utf-8 -*-', b'', b'', b'def main():', b'    """Main function."""', b'    print(f"wh)', b'', b'', b'if __name__ == "__main__":', b'    main()']]': Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/pynvim/msgpack_rpc/session.py", line 217, in handler
    self._notification_cb(name, args)
  File "/usr/lib/python3.7/site-packages/pynvim/api/nvim.py", line 222, in filter_notification_cb
    notification_cb(name, args)
  File "/home/viniarck/.config/nvim/.cache/init.vim/.dein/pythonx/yarp.py", line 36, in on_notification
    getattr(module_obj, method)(*args)
  File "/home/viniarck/.dotfiles/roles/dotfiles/files/config/nvim/.cache/init.vim/.dein/pythonx/ncm2.py", line 203, in on_complete
    on_complete_impl(context, *args)
  File "/home/viniarck/.config/nvim/repos/github.com/ncm2/ncm2-jedi/pythonx/ncm2_jedi.py", line 88, in on_complete
    completions = script.completions()
  File "/home/viniarck/.local/lib/python3.7/site-packages/jedi/api/__init__.py", line 174, in completions
    completions = completion.completions()
  File "/home/viniarck/.local/lib/python3.7/site-packages/jedi/api/completion.py", line 98, in completions
    completion_names = self._get_context_completions()
  File "/home/viniarck/.local/lib/python3.7/site-packages/jedi/api/completion.py", line 126, in _get_context_completions
    grammar, self._code_lines, self._module_node, self._position
  File "/home/viniarck/.local/lib/python3.7/site-packages/jedi/api/helpers.py", line 130, in get_stack_at_position
    raise SystemError("This really shouldn't happen. There's a bug in Jedi.")
SystemError: This really shouldn't happen. There's a bug in Jedi.

I'm using ncm2-jedi commit 0003b01 to reproduce this.

Completion doesn't work inside markdown subscope

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.

AttributeError: module 'jedi' has no attribute 'Script'

The following error occurs, autocompletion not working:

[ncm2_jedi@yarp] AttributeError: module 'jedi' has no attribute 'Script'

vimrc:

Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2'
Plug 'ncm2/ncm2-jedi'
Plug 'ncm2/ncm2-bufword'
autocmd BufEnter * call ncm2#enable_for_buffer()

messages:

[ncm2_jedi@yarp] Traceback (most recent call last):
[ncm2_jedi@yarp]   File "/home/XXXX/.vim/plugged/nvim-yarp/pythonx/yarp.py", line 30, in on_notification
[ncm2_jedi@yarp]     getattr(module_obj, method)(*args)
[ncm2_jedi@yarp]   File "/home/XXXX/.vim/plugged/ncm2/pythonx/ncm2.py", line 206, in on_complete
[ncm2_jedi@yarp]     on_complete_impl(context, *args)
[ncm2_jedi@yarp]   File "/home/XXXX/.vim/plugged/ncm2-jedi/pythonx/ncm2_jedi.py", line 40, in on_complete
[ncm2_jedi@yarp]     script = jedi.Script(src, lnum, len(typed), path)
[ncm2_jedi@yarp] AttributeError: module 'jedi' has no attribute 'Script'

A solution that worked:

Reinstall jedi in the host python3 (g:python3_host_prog) via pip, and the error is gone. Not sure why module jedi had pointed to a wrong (maybe old) version previously.

Unfortunately it is documented nowhere and error handling seems not robust. For example, we may detect jedi is well installed and import-able using the host python3 interpreter, and warn users if not.

Any other thoughts how we can improve this, as many users might experience this error?

Completions not working in virtual environment created with pyenv and venv

Issue

Completions are not working for packages I installed in a virtual environment that was created with a python installation managed by pyenv.

Steps to reproduce

  • Use a fresh Python executable (no site packages) installed with pyenv (not system python) to create a virtual environment (e.g. python -m venv .venv).
  • Install packages in this environment (e.g. .venv/bin/python -m pip install requests).
  • Open a fresh python buffer and type import ... (no special syntax).

Expected behavior

I can see the packages of my virtual environment in the completions list. I can also complete modules, methods etc. from installed packages.

Completions work fine with plain jedi-vim (no ncm2).

Actual behavior

I can not see completions of packages of the activated environment. Instead I can only see completions of my system python, which is a different version and not even the python executable I used when creating the virtual environment.

Minimal vimrc

call plug#begin('~/.local/share/nvim/plugged')
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-jedi'
Plug 'davidhalter/jedi-vim'
call plug#end()

set nocompatible

let script_dir = fnamemodify(expand('<sfile>'), ':h')
let &runtimepath .= ','.script_dir.','.script_dir.'/after'

syntax on
filetype plugin indent on

autocmd BufEnter * call ncm2#enable_for_buffer()

set completeopt=noinsert,menuone,noselect

Output of “:verbose JediDebugInfo”

#### Jedi-vim debug information

##### jedi-vim version

 - jedi-vim git version: 0.10.0-3-g4f2499e
 - jedi git submodule status:  005f69390c4b1a3b864e7373cfcbdaf95e65411d pythonx/jedi (v0.15.1)
 - parso git submodule status:  c0ace63a6905500e18d8ac06af1a0a9057e63498 pythonx/parso (v0.5.1)

##### Global Python

Using Python version 3 to access Jedi.
 - global sys.version: `3.6.8 (default, Aug 20 2019, 17:12:48), [GCC 8.3.0]`
 - global site module: `/usr/lib/python3.6/site.py`

##### Jedi

 - path: `~/.local/share/nvim/plugged/jedi-vim/pythonx/jedi/jedi/__init__.py`
 - version: 0.15.1

##### Jedi environment: <Environment: 3.7.4 in /tmp/myapp/.venv>

 - executable: /tmp/myapp/.venv/bin/python
 - sys_path:
    - `~/.pyenv/versions/3.7.4/lib/python37.zip`
    - `~/.pyenv/versions/3.7.4/lib/python3.7`
    - `~/.pyenv/versions/3.7.4/lib/python3.7/lib-dynload`
    - `/tmp/myapp/.venv/lib/python3.7/site-packages`

##### Known environments

 - <Environment: 3.7.4 in /tmp/myapp/.venv> (/tmp/myapp/.venv/bin/python)
 - <Environment: 3.7.4 in ~/.pyenv/versions/3.7.4> (~/.pyenv/versions/3.7.4/bin/python3.7)
 - <Environment: 3.6.8 in /usr> (/usr/bin/python3.6)
 - <Environment: 2.7.15 in /usr> (/usr/bin/python2.7)

##### Settings

g:jedi#completions_enabled = 0 (default: 1)

  omnifunc=python3complete#Complete
        Zuletzt gesetzt in /tmp/.mount_nvimt3iaAF/usr/share/nvim/runtime/ftplugin/python.vim line 41
  completeopt=noinsert,menuone,noselect
        Zuletzt gesetzt in ~/dotfiles/nvim/.config/nvim/init.vim line 178

#### :version

NVIM v0.4.0-2014-g554566cce
Build type: RelWithDebInfo
LuaJIT 2.0.5
Features: +acl +iconv +tui

Output of :checkhealth provider

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 2 provider (optional)
  - INFO: pyenv: Path: ~/.pyenv/libexec/pyenv
  - INFO: pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.
  - INFO: pyenv: Root: ~/.pyenv
  - INFO: Using: g:python_host_prog = "/usr/bin/python2"
  - WARNING: $VIRTUAL_ENV exists but appears to be inactive. This could lead to unexpected results.
    - ADVICE:
      - If you are using Zsh, see: http://vi.stackexchange.com/a/7654
  - INFO: Executable: /usr/bin/python2
  - INFO: Python version: 2.7.15
  - INFO: pynvim version: 0.3.2

## Python 3 provider (optional)
  - INFO: pyenv: Path: ~/.pyenv/libexec/pyenv
  - INFO: pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.
  - INFO: pyenv: Root: ~/.pyenv
  - INFO: Using: g:python3_host_prog = "/usr/bin/python3"
  - WARNING: $VIRTUAL_ENV exists but appears to be inactive. This could lead to unexpected results.
    - ADVICE:
      - If you are using Zsh, see: http://vi.stackexchange.com/a/7654
  - INFO: Executable: /usr/bin/python3
  - INFO: Python version: 3.6.8
  - INFO: pynvim version: 0.3.2

Add g:ncm2_jedi#settings

Some packages like numpy, torch, tensorflow are so large and it takes a long time to complete them.
Anyway to cache it ahead?
Thanks.

Code completion in Python chunk within R Markdown not working

Posting this issue here as suggested at jalvesaq/Nvim-R#442

I am using 'ncm2/ncm2-jedi' to do completion for py files. This works perfectly well. I do not get completion to work though for python chunks within rmd files (The completion works for R chunks).
Having temporarily switched from 'ncm2/ncm2-jedi' to 'davidhalter/jedi' had no effect either.

I have tried after having disabled all plugins except the following:

Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'gaalcaras/ncm-R'
Plug 'jalvesaq/Nvim-R'
Plug 'jalvesaq/R-Vim-runtime'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
Plug 'w0rp/ale'
Plug 'ncm2/ncm2-ultisnips'
Plug 'ncm2/ncm2-jedi'

Syntax highlighting is working for both, R and Python within chunks.
System: NVIM v0.5.0-dev on Ubuntu 18

can't work if add option `--remote-tab-silent`

When I modify a python file in windows, it can't complete, it work fine in linux.

Plug 'roxma/vim-hug-neovim-rpc'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-tmux'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-pyclang'
Plug 'ncm2/ncm2-jedi'
Plug 'jsfaint/ncm2-vim'
Plug 'Shougo/neco-vim'
Plug 'jsfaint/ncm2-syntax'
Plug 'Shougo/neco-syntax'

ncm2_log_py3_ncm2_core:

2018-07-18 11:38:47,610 [INFO @ ncm2_core.py:load_plugin:69] 21356 - send vimscript plugin d:\tool\vim\plugged\gen_tags.vim\ncm2-plugin\ncm2_gtags.vim
2018-07-18 11:38:47,618 [INFO @ ncm2_core.py:load_plugin:69] 21356 - send vimscript plugin d:\tool\vim\plugged\ncm2-bufword\ncm2-plugin\ncm2_bufword.vim
2018-07-18 11:38:47,621 [INFO @ ncm2_core.py:load_plugin:69] 21356 - send vimscript plugin d:\tool\vim\plugged\ncm2-tmux\ncm2-plugin\ncm2_tmux.vim
2018-07-18 11:38:47,624 [INFO @ ncm2_core.py:load_plugin:69] 21356 - send vimscript plugin d:\tool\vim\plugged\ncm2-path\ncm2-plugin\ncm2_path.vim
2018-07-18 11:38:47,625 [INFO @ ncm2_core.py:load_plugin:69] 21356 - send vimscript plugin d:\tool\vim\plugged\ncm2-pyclang\ncm2-plugin\ncm2_libclang.vim
2018-07-18 11:38:47,626 [INFO @ ncm2_core.py:load_plugin:69] 21356 - send vimscript plugin d:\tool\vim\plugged\ncm2-jedi\ncm2-plugin\ncm2_jedi.vim
2018-07-18 11:38:47,628 [INFO @ ncm2_core.py:load_plugin:69] 21356 - send vimscript plugin d:\tool\vim\plugged\ncm2-vim\ncm2-plugin\ncm2_vim.vim
2018-07-18 11:38:47,629 [INFO @ ncm2_core.py:load_plugin:69] 21356 - send vimscript plugin d:\tool\vim\plugged\ncm2-syntax\ncm2-plugin\ncm2_syntax.vim

reproduce way:

gvim t.py
i
import os

vim / neovim - autocomplete stop working after seven repetitions

I use vim / nvim as editor. The code to completion working.
But if something happens seven times in a program, this stopped working.

For example:

import cadquery as cq
part = (cq.Workplane("XY")
.circle(10)
.extrude(10)
.faces(">Z")
.circle(10)
.extrude(10)
.faces(">Z")
.circle(10)
.extrude(10)
.faces(">Z")
.circle(10)
.extrude(10)
.faces(">Z")
.circle(10)
.extrude(10)
.faces(">Z")
.circle(10)
.extrude(10)
.faces(">Z")
.circle(10)
)

After the seventh ".circle()", (or seventh .lineTo(), etc. ) the code completion stop working.
I tried this with several add-ons, always the same result.

"davidhalter/jedi-vim", "ncm2/ncm2-jedi"

I thought this was a cadquery bug, I reported this problem on the cadquery (CadQuery/cadquery#823).
I received this answer:

"This is not a CadQuery problem. You probably should report this to vim/nvim developers or to developers of whatever auto-completion plugin you are using with it."

Could this be a vim / neovim or ncm2-Jedi question?

Starts many jedi jobs and high memory usage over time

ncm2-jedi uses large amounts of memory (1-2GB) after getting new completions on python files.

Usage description

I observe this behavior with completion on a script using matplotlib, pandas, numpy. The used amount of memory increases with receiving more completions and will remain static if no completions are obtained.

Observations

A large number of ncm2_jedi and jedi jobs are visible in htop, all of them started by same ncm2_jedi parent job.

System setup

Archlinux with python 3.7.0, python-jedi 0.13.1-1, neovim 0.3.1-1, python-neovim 0.2.6-2.

Minimal vimrc for reproduction

call plug#begin()
"" Neovim configuration
function! DoRemote(arg)
        UpdateRemotePlugins
endfunction
" Autocompletion
Plug 'roxma/nvim-yarp'  " nvim framework
Plug 'ncm2/ncm2'
"" NCM Completion sources
Plug 'ncm2/ncm2-jedi', {'for': 'python'}
call plug#end()

" ncm2 completion manager settings
" enable ncm2 for all buffers
autocmd BufEnter * call ncm2#enable_for_buffer()
" IMPORTANTE: :help Ncm2PopupOpen for more information
set completeopt=noinsert,menuone,noselect
set shortmess+=c  " hide some messages
inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"

Nasty error bug: "error caught in notification handler"

Most of the time when I try writing code into a .py file, I get many error messages, where the first says something like:

[ncm2_jedi@yarp] error caught in notification handler 'on_complete [...]'

Needless to say, this renders the plugin unusable, since it makes editing code barely possible.

For example, in a file called "test.py" I have the following silly code:

# this is a simple Python script to illustrate my issue
import os
a = 2
for i in range(0, a):
    if i % 2 == 0:
        print(i/0)

# end of file ----------------- #

I simply open such file, then I try editing and get the error messages I send attached here.

messages.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.