Open eyalk11 opened 1 year ago
@eyalk11 to help debug, can you please send me a link to a GitHub repo that contains an example directory of Python modules you're trying to get Jedi to analyze, along with what exactly you're trying to do (search workspace, get auto-completion, jump to definition, etc)
Also, some info that will make this easier to debug:
Telescope lsp_workspace_symbols
. I think that what confuses it is that I use
sys.path.insert dynamically there inside __init___.py
But that doesn't explain the extra path thing. It does analyze the symbols of runsit.py , but not of most of the project.
I wish it had ignored sys.path and worked with all py files in the directory.
https://github.com/eyalk11/compare-my-stocks
current relevant config (on_attach defines keymaps).
require('telescope').setup{}
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
require'lspconfig'.jedi_language_server.setup{
capabilities = capabilities,
on_attach = on_attach,
root_dir = function() return vim.loop.cwd() end,
init_options = {
workspace = {
extraPaths ={'./gui','./engine','./input'}
}
}
}
Thanks a lot
I got crash several times when I added the workspace directory to vim (src/compare_my_stocks). I use the windows \ in there.
vim.lsp.buf.add_workspace_folder
The root compare-my-stocks is already there.
Also, it keeps saying
[INFO][2022-11-02 01:46:57] ...lsp/handlers.lua:489 "No pyproject.toml file found."
[WARN][2022-11-02 01:46:57] ...lsp/handlers.lua:487 "stubPath C:\\Users\\ekarni\\mypy\\stockscomp\\typings is not a valid directory."
Though I am not sure it is your client.
See the traceback in the log.
[DEBUG][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:364 "rpc.send" { jsonrpc = "2.0", method = "workspace/didChangeWorkspaceFolders", params = { event = { added = { { name = "C:\\Users\\ekarni\\compare-my-stocks\\src\\compare_my_stocks", uri = "file:///C:/Users/ekarni/compare-my-stocks/src/compare_my_stocks" } }, removed = { {} } } }}
[DEBUG][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:364 "rpc.send" { jsonrpc = "2.0", method = "workspace/didChangeWorkspaceFolders", params = { event = { added = { { name = "C:\\Users\\ekarni\\compare-my-stocks\\src\\compare_my_stocks", uri = "file:///C:/Users/ekarni/compare-my-stocks/src/compare_my_stocks" } }, removed = { {} } } }}
[DEBUG][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:364 "rpc.send" { jsonrpc = "2.0", method = "workspace/didChangeWorkspaceFolders", params = { event = { added = { { name = "C:\\Users\\ekarni\\compare-my-stocks\\src\\compare_my_stocks", uri = "file:///C:/Users/ekarni/compare-my-stocks/src/compare_my_stocks" } }, removed = { {} } } }}
[DEBUG][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:364 "rpc.send" { jsonrpc = "2.0", method = "workspace/didChangeWorkspaceFolders", params = { event = { added = { { name = "C:\\Users\\ekarni\\compare-my-stocks\\src\\compare_my_stocks", uri = "file:///C:/Users/ekarni/compare-my-stocks/src/compare_my_stocks" } }, removed = { {} } } }}
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" 'Traceback (most recent call last):\r\n File "c:\\users\\ekarni\\appdata\\local\\nvim-data\\lsp_servers\\jedi_language_server\\venv\\lib\\site-packages\\pygls\\protocol.py", line 152, in deserialize_message\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' deserialize_params(data, get_params_type)\r\n File "c:\\users\\ekarni\\appdata\\local\\nvim-data\\lsp_servers\\jedi_language_server\\venv\\lib\\site-packages\\pygls\\protocol.py", line 138, in deserialize_params\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" " data['params'] = params_type(**params)\r\n"
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' File "c:\\users\\ekarni\\appdata\\local\\nvim-data\\lsp_servers\\jedi_language_server\\venv\\lib\\site-packages\\pygls\\lsp\\types\\basic_structures.py", line 58, in __init__\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' super().__init__(**data)\r\n File "pydantic\\main.py", line 342, in pydantic.main.BaseModel.__init__\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" "pydantic.error_wrappers.ValidationError: 2 validation errors for DidChangeWorkspaceFoldersParams\r\nevent -> removed -> 0 -> uri\r\n field required (type=value_error.missing)\r\nevent -> removed -> 0 -> name\r\n field required (type=value_error.missing)\r\n"
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" '\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File "C:\\Users\\ekarni\\.pyenv\\pyenv-win\\versions\\3.9\\lib\\runpy.py", line 197, in _run_module_as_main\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' return _run_code(code, main_globals, None,\r\n File "C:\\Users\\ekarni\\.pyenv\\pyenv-win\\versions\\3.9\\lib\\runpy.py", line 87, in _run_code\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" " exec(code, run_globals)\r\n"
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' File "C:\\Users\\ekarni\\AppData\\Local\\nvim-data\\lsp_servers\\jedi_language_server\\venv\\Scripts\\jedi-language-server.exe\\__main__.py", line 7, in <module>\r\n File "c:\\users\\ekarni\\appdata\\local\\nvim-data\\lsp_servers\\jedi_language_server\\venv\\lib\\site-packages\\jedi_language_server\\cli.py", line 125, in cli\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' SERVER.start_io()\r\n File "c:\\users\\ekarni\\appdata\\local\\nvim-data\\lsp_servers\\jedi_language_server\\venv\\lib\\site-packages\\pygls\\server.py", line 225, in start_io\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' self.loop.run_until_complete(\r\n File "C:\\Users\\ekarni\\.pyenv\\pyenv-win\\versions\\3.9\\lib\\asyncio\\base_events.py", line 642, in run_until_complete\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' return future.result()\r\n File "c:\\users\\ekarni\\appdata\\local\\nvim-data\\lsp_servers\\jedi_language_server\\venv\\lib\\site-packages\\pygls\\server.py", line 78, in aio_readline\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" " proxy(b''.join(message))\r\n File \"c:\\users\\ekarni\\appdata\\local\\nvim-data\\lsp_servers\\jedi_language_server\\venv\\lib\\site-packages\\pygls\\protocol.py\", line 456, in data_received\r\n"
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' json.loads(body.decode(self.CHARSET),\r\n File "C:\\Users\\ekarni\\.pyenv\\pyenv-win\\versions\\3.9\\lib\\json\\__init__.py", line 359, in loads\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' return cls(**kw).decode(s)\r\n File "C:\\Users\\ekarni\\.pyenv\\pyenv-win\\versions\\3.9\\lib\\json\\decoder.py", line 337, in decode\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' obj, end = self.raw_decode(s, idx=_w(s, 0).end())\r\n File "C:\\Users\\ekarni\\.pyenv\\pyenv-win\\versions\\3.9\\lib\\json\\decoder.py", line 353, in raw_decode\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" ' obj, end = self.scan_once(s, idx)\r\n File "c:\\users\\ekarni\\appdata\\local\\nvim-data\\lsp_servers\\jedi_language_server\\venv\\lib\\site-packages\\pygls\\protocol.py", line 154, in deserialize_message\r\n'
[ERROR][2022-11-02 01:42:44] .../vim/lsp/rpc.lua:439 "rpc" "jedi-language-server" "stderr" " raise JsonRpcInvalidParams()\r\npygls.exceptions.JsonRpcInvalidParams: Invalid Params\r\n"
@eyalk11 in your example, you should specify your path from the root of your git repository (eg, where you've put your setup.py
).
So: extraPaths ={'./src/compare_my_stocks/gui','./src/compare_my_stocks/engine','./src/compare_my_stocks/input'}
The above works for me when using the repository you referenced:
Thanks for the effort. It doesn't work in my environment. How is it best to debug it?
Not sure, but please let me know if you figure out what's wrong. Happy to add your findings to a FAQ in case someone else has a similar issue
I am on windows.
My current config is:
And it simply doesn't recognize much of my workspace. I tried using \ as well. How can I see what folders it uses as workspace? Can I access jedi.Project somehow?
Also I did the following try:
And it worked!