- OS: macOS Sierra, Ubuntu18.04LTS Desktop
- Python: 3.6.4(macOS 公式インストーラ), 3.6.6(Ubuntuデフォルト)
- Vim: macvim-kaoirya,
apt install vim-gnome
して入ったもの - 仮想環境: あるなし関係なくモジュールの補完がうまくいかないものがある
- なし→Python3.6が動く
- venv
- pipenv
let s:plug_dir = '~/.cache/plugged'
call plug#begin(s:plug_dir)
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
call plug#end()
if executable('pyls')
" pip install python-language-server
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'pyls',
\ 'cmd': {server_info->['pyls']},
\ 'whitelist': ['python'],
\ })
endif
autocmd FileType python setlocal omnifunc=lsp#complete
let g:lsp_log_verbose = 1
let g:lsp_log_file = expand('~/.cache/tmp/vim-lsp.log')
(注) palantir/python-language-server のtoxが3.5~3.7で動かなかったので、Python 3.4環境にインストールしている。環境を合わせるためにPython3.6にインストールしても同様な現象は発生している。
$ python3.4 -m pip list
Package Version
---------------------- -------
future 0.16.0
jedi 0.13.1
parso 0.3.1
pip 18.1
pluggy 0.7.1
python-jsonrpc-server 0.0.2
python-language-server 0.21.2
setuptools 40.4.3
wheel 0.32.1
-
pathlib:
以下のようのなサンプルを用意する
from pathlib import Path here = Path('test.txt') # ←ここまではオムニ補完が効く here.
- venv: "here."でオムニ補完しようとすると数秒待って"Path"だけ補完候補にでてくる
- pipenv: "here."でオムニ補完しようとするとすぐに「パターンは見つかりませんでした。」とメッセージがでてくる
木 10/11 02:14:03 2018:[{"response":{"data":{"__data__":"vim-lsp","server_name":"pyls"},"message":"server already started"}}]
木 10/11 02:14:03 2018:[{"response":{"data":{"__data__":"vim-lsp","init_result":{"id":1,"result":{"capabilities":{"executeCommandProvider":{"commands":[]},"documentHighlightProvider":true,"hoverProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"codeActionProvider":true,"textDocumentSync":2,"codeLensProvider":{"resolveProvider":false},"definitionProvider":true,"documentRangeFormattingProvider":true,"documentFormattingProvider":true,"documentSymbolProvider":true,"experimental":{},"renameProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":["."]}}},"jsonrpc":"2.0"},"server_name":"pyls"},"message":"lsp server already initialized"}}]
木 10/11 02:14:03 2018:[{"response":{"data":{"__data__":"vim-lsp","server_name":"pyls"},"message":"configuration sent"}}]
木 10/11 02:14:03 2018:[{"response":{"data":{"path":"file:///Users/kashewnuts/test.py","__data__":"vim-lsp","server_name":"pyls"},"message":"already opened"}}]
木 10/11 02:14:03 2018:[{"response":{"data":{"path":"file:///Users/kashewnuts/test.py","__data__":"vim-lsp","server_name":"pyls"},"message":"not dirty"}}]
木 10/11 02:14:03 2018:["--->",1,"pyls",{"method":"textDocument/completion","on_notification":"---funcref---","params":{"textDocument":{"uri":"file:///Users/kashewnuts/test.py"},"position":{"character":5,"line":7}}}]
木 10/11 02:14:03 2018:["<---",1,"pyls",{"response":{"id":5,"jsonrpc":"2.0","error":{"data":{"traceback":[" File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jsonrpc/endpoint.py\", line 113, in consume\n self._handle_request(message['id'], message['method'], message.get('params'))\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jsonrpc/endpoint.py\", line 182, in _handle_request\n handler_result = handler(params)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jsonrpc/dispatchers.py\", line 23, in handler\n return method(**(params or {}))\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/python_ls.py\", line 257, in m_text_document__completion\n return self.completions(textDocument['uri'], position)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/python_ls.py\", line 185, in completions\n completions = self._hook('pyls_completions', doc_uri, position=position)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/python_ls.py\", line 117, in _hook\n return hook_handlers(config=self.config, workspace=self.workspace, document=doc, **kwargs)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/hooks.py\", line 258, in __call__\n return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/manager.py\", line 67, in _hookexec\n return self._inner_hookexec(hook, methods, kwargs)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/_tracing.py\", line 82, in __call__\n return outcome.get_result()\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/callers.py\", line 76, in get_result\n raise ex[1].with_traceback(ex[2])\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/callers.py\", line 48, in from_call\n result = func()\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/_tracing.py\", line 80, in <lambda>\n outcome = _Result.from_call(lambda: self.oldcall(hook, hook_impls, kwargs))\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/manager.py\", line 61, in <lambda>\n firstresult=hook.spec_opts.get('firstresult'),\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/callers.py\", line 201, in _multicall\n return outcome.get_result()\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/callers.py\", line 76, in get_result\n raise ex[1].with_traceback(ex[2])\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/callers.py\", line 180, in _multicall\n res = hook_impl.function(*args)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/plugins/jedi_completion.py\", line 18, in pyls_completions\n } for d in definitions] or None\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/plugins/jedi_completion.py\", line 18, in <listcomp>\n } for d in definitions] or None\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/plugins/jedi_completion.py\", line 23, in _label\n params = ', '.join(param.name for param in definition.params)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jedi/cache.py\", line 143, in wrapper\n result = method(self, *args, **kwargs)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jedi/api/classes.py\", line 345, in params\n raise AttributeError('There are no params defined on this.')\n"]},"code":-32602,"message":"AttributeError: There are no params defined on this."}},"request":{"method":"textDocument/completion","jsonrpc":"2.0","id":5,"params":{"textDocument":{"uri":"file:///Users/kashewnuts/test.py"},"position":{"character":5,"line":7}}}}]
木 10/11 02:14:03 2018:["<---(stderr)",1,"pyls",["2018-10-11 02:14:03,872 UTC - ERROR - jsonrpc.endpoint - Failed to handle request 5","Traceback (most recent call last):"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jedi/cache.py\", line 141, in wrapper"," return dct[key]","KeyError: ((), frozenset())","","During handling of the above exception, another exception occurred:","","Traceback (most recent call last):"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jsonrpc/endpoint.py\", line 113, in consume"," self._handle_request(message['id'], message['method'], message.get('params'))"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jsonrpc/endpoint.py\", line 182, in _handle_request"," handler_result = handler(params)"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jsonrpc/dispatchers.py\", line 23, in handler"," return method(**(params or {}))"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/python_ls.py\", line 257, in m_text_document__completion"," return self.completions(textDocument['uri'], position)"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/python_ls.py\", line 185, in completions"," completions = self._hook('pyls_completions', doc_uri, position=position)"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/python_ls.py\", line 117, in _hook"," return hook_handlers(config=self.config, workspace=self.workspace, document=doc, **kwargs)"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/hooks.py\", line 258, in __call__"," return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/manager.py\", line 67, in _hookexec"," return self._inner_hookexec(hook, methods, kwargs)"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/_tracing.py\", line 82, in __call__"," return outcome.get_result()"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/callers.py\", line 76, in get_result"," raise ex[1].with_traceback(ex[2])"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/callers.py\", line 48, in from_call"," result = func()"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/_tracing.py\", line 80, in <lambda>"," outcome = _Result.from_call(lambda: self.oldcall(hook, hook_impls, kwargs))"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/manager.py\", line 61, in <lambda>"," firstresult=hook.spec_opts.get('firstresult'),"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/callers.py\", line 201, in _multicall"," return outcome.get_result()"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/callers.py\", line 76, in get_result"," raise ex[1].with_traceback(ex[2])"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pluggy/callers.py\", line 180, in _multicall"," res = hook_impl.function(*args)"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/plugins/jedi_completion.py\", line 18, in pyls_completions"," } for d in definitions] or None"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/plugins/jedi_completion.py\", line 18, in <listcomp>"," } for d in definitions] or None"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyls/plugins/jedi_completion.py\", line 23, in _label"," params = ', '.join(param.name for param in definition.params)"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jedi/cache.py\", line 143, in wrapper"," result = method(self, *args, **kwargs)"," File \"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/jedi/api/classes.py\", line 345, in params"," raise AttributeError('There are no params defined on this.')","AttributeError: There are no params defined on this.",""]]
木 10/11 10:09:35 2018:[{"response":{"data":{"__data__":"vim-lsp","server_name":"pyls"},"message":"server already started"}}]
木 10/11 10:09:35 2018:[{"response":{"data":{"__data__":"vim-lsp","init_result":{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"executeCommandProvider":{"commands":[]},"documentHighlightProvider":true,"hoverProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"codeActionProvider":true,"textDocumentSync":2,"codeLensProvider":{"resolveProvider":false},"definitionProvider":true,"documentRangeFormattingProvider":true,"documentFormattingProvider":true,"documentSymbolProvider":true,"experimental":{},"renameProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":["."]}}}},"server_name":"pyls"},"message":"lsp server already initialized"}}]
木 10/11 10:09:35 2018:[{"response":{"data":{"__data__":"vim-lsp","server_name":"pyls"},"message":"configuration sent"}}]
木 10/11 10:09:35 2018:[{"response":{"data":{"path":"file:///Users/kashewnuts/testenv/tests.py","__data__":"vim-lsp","server_name":"pyls"},"message":"already opened"}}]
木 10/11 10:09:35 2018:[{"response":{"data":{"path":"file:///Users/kashewnuts/testenv/tests.py","__data__":"vim-lsp","server_name":"pyls"},"message":"not dirty"}}]
木 10/11 10:09:35 2018:["--->",1,"pyls",{"method":"textDocument/completion","on_notification":"---funcref---","params":{"textDocument":{"uri":"file:///Users/kashewnuts/testenv/tests.py"},"position":{"character":5,"line":5}}}]
木 10/11 10:09:36 2018:["<---",1,"pyls",{"response":{"id":2,"jsonrpc":"2.0","error":{"data":{"traceback":[" File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jsonrpc/endpoint.py\", line 113, in consume\n self._handle_request(message['id'], message['method'], message.get('params'))\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jsonrpc/endpoint.py\", line 182, in _handle_request\n handler_result = handler(params)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jsonrpc/dispatchers.py\", line 23, in handler\n return method(**(params or {}))\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/python_ls.py\", line 257, in m_text_document__completion\n return self.completions(textDocument['uri'], position)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/python_ls.py\", line 185, in completions\n completions = self._hook('pyls_completions', doc_uri, position=position)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/python_ls.py\", line 117, in _hook\n return hook_handlers(config=self.config, workspace=self.workspace, document=doc, **kwargs)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/hooks.py\", line 258, in __call__\n return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/manager.py\", line 67, in _hookexec\n return self._inner_hookexec(hook, methods, kwargs)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/_tracing.py\", line 82, in __call__\n return outcome.get_result()\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py\", line 76, in get_result\n raise ex[1].with_traceback(ex[2])\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py\", line 48, in from_call\n result = func()\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/_tracing.py\", line 80, in <lambda>\n outcome = _Result.from_call(lambda: self.oldcall(hook, hook_impls, kwargs))\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/manager.py\", line 61, in <lambda>\n firstresult=hook.spec_opts.get('firstresult'),\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py\", line 201, in _multicall\n return outcome.get_result()\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py\", line 76, in get_result\n raise ex[1].with_traceback(ex[2])\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py\", line 180, in _multicall\n res = hook_impl.function(*args)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/plugins/jedi_completion.py\", line 18, in pyls_completions\n } for d in definitions] or None\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/plugins/jedi_completion.py\", line 18, in <listcomp>\n } for d in definitions] or None\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/plugins/jedi_completion.py\", line 23, in _label\n params = ', '.join(param.name for param in definition.params)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jedi/cache.py\", line 143, in wrapper\n result = method(self, *args, **kwargs)\n"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jedi/api/classes.py\", line 345, in params\n raise AttributeError('There are no params defined on this.')\n"]},"code":-32602,"message":"AttributeError: There are no params defined on this."}},"request":{"method":"textDocument/completion","jsonrpc":"2.0","id":2,"params":{"textDocument":{"uri":"file:///Users/kashewnuts/testenv/tests.py"},"position":{"character":5,"line":5}}}}]
木 10/11 10:09:36 2018:["<---(stderr)",1,"pyls",["2018-10-11 10:09:36,377 UTC - ERROR - jsonrpc.endpoint - Failed to handle request 2","Traceback (most recent call last):"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jedi/cache.py\", line 141, in wrapper"," return dct[key]","KeyError: ((), frozenset())","","During handling of the above exception, another exception occurred:","","Traceback (most recent call last):"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jsonrpc/endpoint.py\", line 113, in consume"," self._handle_request(message['id'], message['method'], message.get('params'))"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jsonrpc/endpoint.py\", line 182, in _handle_request"," handler_result = handler(params)"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jsonrpc/dispatchers.py\", line 23, in handler"," return method(**(params or {}))"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/python_ls.py\", line 257, in m_text_document__completion"," return self.completions(textDocument['uri'], position)"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/python_ls.py\", line 185, in completions"," completions = self._hook('pyls_completions', doc_uri, position=position)"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/python_ls.py\", line 117, in _hook"," return hook_handlers(config=self.config, workspace=self.workspace, document=doc, **kwargs)"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/hooks.py\", line 258, in __call__"," return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/manager.py\", line 67, in _hookexec"," return self._inner_hookexec(hook, methods, kwargs)"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/_tracing.py\", line 82, in __call__"," return outcome.get_result()"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py\", line 76, in get_result"," raise ex[1].with_traceback(ex[2])"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py\", line 48, in from_call"," result = func()"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/_tracing.py\", line 80, in <lambda>"," outcome = _Result.from_call(lambda: self.oldcall(hook, hook_impls, kwargs))"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/manager.py\", line 61, in <lambda>"," firstresult=hook.spec_opts.get('firstresult'),"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py\", line 201, in _multicall"," return outcome.get_result()"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py\", line 76, in get_result"," raise ex[1].with_traceback(ex[2])"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py\", line 180, in _multicall"," res = hook_impl.function(*args)"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/plugins/jedi_completion.py\", line 18, in pyls_completions"," } for d in definitions] or None"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/plugins/jedi_completion.py\", line 18, in <listcomp>"," } for d in definitions] or None"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyls/plugins/jedi_completion.py\", line 23, in _label"," params = ', '.join(param.name for param in definition.params)"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jedi/cache.py\", line 143, in wrapper"," result = method(self, *args, **kwargs)"," File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jedi/api/classes.py\", line 345, in params"," raise AttributeError('There are no params defined on this.')","AttributeError: There are no params defined on this.",""]]
以下のように
asyncomplete(-lsp).vim
を導入して<C-x><C-u>
で補完しようとしても補完できないことを確認。