neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.43k stars 954 forks source link

python venv not working #1066

Closed Jerry-Moo closed 5 years ago

Jerry-Moo commented 5 years ago

I use Coc.nvim I set virtualenv success. But not working. there are two problem I found sometimes show me source pyls timeout after 1000ms . but sometimes show err as source jedi timeout after 1000ms emm...I can use function jump ctrl+] to into my project function..but When I want to check the package function. Seem like tornado or tornadb it was failed image image

pip list
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Package                       Version
----------------------------- ---------
astroid                       1.6.6
backports.functools-lru-cache 1.5
configparser                  3.7.4
contextlib2                   0.5.5
enum34                        1.1.6
future                        0.17.1
futures                       3.3.0
greenlet                      0.4.15
importlib-metadata            0.19
isort                         4.3.21
jedi                          0.14.1
lazy-object-proxy             1.4.1
mccabe                        0.6.1
msgpack                       0.6.1
parso                         0.5.1
pathlib2                      2.3.4
pip                           19.0.3
pluggy                        0.12.0
protobuf                      3.7.0
pylint                        1.9.5
pynvim                        0.3.2
python-jsonrpc-server         0.2.0
python-language-server        0.28.1
scandir                       1.10.0
setuptools                    40.8.0
singledispatch                3.4.0.3
six                           1.12.0
trollius                      2.2.post1
wheel                         0.33.1
wrapt                         1.11.2
zipp                          0.5.2

nvim I install vim-gutentags.vim here it's setting

1:       " gutentags搜索工程目录的标志,碰到这些文件/目录名就停止向上一级目录递归 "
2:       let g:gutentags_project_root = ['.root', '.svn', '.git', '.project']
3-       
4-       " 所生成的数据文件的名称 "
5:       let g:gutentags_ctags_tagfile = '.tags'
6-       
7:       " 将自动生成的 tags 文件全部放入 ~/.cache/tags 目录中,避免污染工程目录 "
8:       let s:vim_tags = expand('~/.cache/tags')
9:       let g:gutentags_cache_dir = s:vim_tags
10:      " 检测 ~/.cache/tags 不存在就新建 "
11:      if !isdirectory(s:vim_tags)
12:         silent! call mkdir(s:vim_tags, 'p')
13-      endif
14-      
15:      " 配置 ctags 的参数 "
16:      let g:gutentags_ctags_extra_args = []
17:      let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
18:      let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
19:      let g:gutentags_ctags_extra_args += ['--c-kinds=+px']

tagbar.vim setting

6-       let g:tagbar_autofocus = 1
7-       let g:tagbar_width=25
8-       let g:tagbar_type_go = {
9:                 \ 'ctagstype' : 'go',
10-                \ 'kinds'     : [
11-                \ 'p:package',
12-                \ 'i:imports',
....
29-                \ 'ctype' : 't',
30-                \ 'ntype' : 'n'
31-                \ },
32:                \ 'ctagsbin'  : 'gotags',
33:                \ 'ctagsargs' : '-sort -silent'
34-                \ }
NVIM v0.3.8
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20190704-11886-1ukicoc/neovim-0.3.8/build/config -I/tmp/neovim-20190704-11886-1ukicoc/neovim-0.3.8/src -I/usr/local/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/tmp/neovim-20190704-11886-1ukicoc/neovim-0.3.8/build/src/nvim/auto -I/tmp/neovim-20190704-11886-1ukicoc/neovim-0.3.8/build/include
Compiled by brew@Mojave.local

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

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.3.8/share/nvim"

Run :checkhealth for more info
stsewd commented 5 years ago

Try checking :CocCommand the option python.setInterpreter

Jerry-Moo commented 5 years ago

@stsewd I seted python.setInterpreter ... Still can not jump to package. You can found unable import celery

chemzqm commented 5 years ago

Looks like it's excepted, the module you have imported doesn't exists in that virtual env.

Jerry-Moo commented 5 years ago

@chemzqm
its exists

You can see when I move line 45 and try ctrl+] it show me tag not found: ConnectionPool. virtualenv was exists and I use :CocComand python.setInterpreter

I have install coc-pyls coc-python

image

image

image

image

chemzqm commented 5 years ago

I have install coc-pyls coc-python

You should only use one of them, not both.

The tag not found issue doesn't related to coc.nvim, it doesn't provide tags for you.

chemzqm commented 5 years ago

Try start python repl with your virtual env then use import.

Jerry-Moo commented 5 years ago

@chemzqm I try source to virtualenv and open vim. then it show me source jedi timeout after 1000ms. image image

here its my tag setting vim-gutentags.vim

1:       " gutentags搜索工程目录的标志,碰到这些文件/目录名就停止向上一级目录递归 "                     │  /Users/jerrymoo/.config/nvim/│    3 " tagbar默认去这个目录中寻找ctags
  2:       let g:gutentags_project_root = ['.root', '.svn', '.git', '.project']                           │  ▷ colors/                    │    4 " let g:tagbar_ctags_bin='/usr/local/bin/ctags'·
  3-                                                                                                      │  ▼ core/                      │    5 " 启动 时自动focus
  4-       " 所生成的数据文件的名称 "                                                                     │    ▷ dein/                    │    6 let g:tagbar_autofocus = 1
  5:       let g:gutentags_ctags_tagfile = '.tags'                                                        │    ▼ plugins/                 │    7 let g:tagbar_width=25
  6-                                                                                                      │        allkey.vim             │    8 let g:tagbar_type_go = {
  7:       " 将自动生成的 tags 文件全部放入 ~/.cache/tags 目录中,避免污染工程目录 "                      │        coc.vim                │    9           \ 'ctagstype' : 'go',
  8:       let s:vim_tags = expand('~/.cache/tags')                                                       │        ctrlf.vim              │   10           \ 'kinds'     : [
  9:       let g:gutentags_cache_dir = s:vim_tags                                                         │        fzf.vim                │   11           \ 'p:package',
  10:      " 检测 ~/.cache/tags 不存在就新建 "                                                            │        neoformat.vim          │   12           \ 'i:imports',
  11:      if !isdirectory(s:vim_tags)                                                                    │        nerdtree.vim           │   13           \ 'c:constants',
  12:         silent! call mkdir(s:vim_tags, 'p')                                                         │        startify.vim           │   14           \ 'v:variables',
  13-      endif                                                                                          │        tagbar.vim             │   15           \ 't:types',
  14-                                                                                                     │        vim-choosewin.vim      │   16           \ 'n:interfaces',
  15:      " 配置 ctags 的参数 "                                                                          │        vim-go.vim             │   17           \ 'w:fields',
  16:      let g:gutentags_ctags_extra_args = []                                                          │        vim-gutentags.vim      │   18           \ 'e:embedded',
  17:      let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']                           │        vim-multiple-cursors.v→│   19           \ 'm:methods',
  18:      let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']                                        │        vista.vim              │   20           \ 'r:constructor',
  19:      let g:gutentags_ctags_extra_args += ['--c-kinds=+px']                                          │    ▷ themes/                  │   21           \ 'f:functions'
  20-                                                                                                     │      deinrc.vim               │   22           \ ],
  21-      "----------vim-preview配置-----------------------------------------                            │      filetype.vim             │   23           \ 'sro' : '.',
  22-      "P 预览 大p关闭
Jerry-Moo commented 5 years ago

@chemzqm both my global python and virtualenv install pylint jedi image

chemzqm commented 5 years ago

Why you have #! /bin/bash at first line of your python file, looks like jedi failed to parse your file.

Jerry-Moo commented 5 years ago

I am not sure what its problem? Could you give me some idea? image image

Jerry-Moo commented 5 years ago

sometimes it work...but still show me source languageserver.python timeout after 1000ms image

chemzqm commented 5 years ago

PYLS is known to have this performance issue, you can increase timeout

Jerry-Moo commented 5 years ago

@chemzqm thank u very much..I fix it ...I incr timeout to 3000ms.