pappasam / jedi-language-server

A Python language server exclusively for Jedi. If Jedi supports it well, this language server should too.
MIT License
596 stars 45 forks source link

Odd `'Workspace' object has no attribute'_root_path'` error with nvim-lspconfig #287

Closed Skaytacium closed 12 months ago

Skaytacium commented 12 months ago

Information

neovim version: 0.9.2 jedi-language-server version: 0.41.1 LuaJIT version: 2.1.0 python version: 3.11.5 OS: Void Linux x86-64 5.19.17_1 glibc

Error message:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp.lua:1308: RPC[Error] code_name = InternalError, message = "AttributeError: 'Workspace' object has no attribute '_root_path'" data = "{'traceback': ['  File \"/home/skay/.local/lib/python3.11/site-packages/pygls/protocol.py\", line 400, in _handle_request
    self._execute_request(msg_id, handler, params)
', '  File \"/home/skay/.local/lib/python3.11/site-packages/pygls/protocol.py\", line 322, in _execute_request
    self._send_response(msg_id, handler(params))
                                ^^^^^^^^^^^^^^^
', '  File \"/home/skay/.local/lib/python3.11/site-packages/pygls/protocol.py\", line 137, in decorator
    ret_val = base_func(self, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
', '  File \"/home/skay/.local/lib/python3.11/site-packages/jedi_language_server/server.py\", line 149, in lsp_initialize
    if server.workspace.root_path
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
', '  File \"/home/skay/.local/lib/python3.11/site-packages/pygls/workspace/workspace.py\", line 224, in root_path
    return self._root_path
           ^^^^^^^^^^^^^^^
']}"
stack traceback:
        [C]: in function 'assert'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1308: in function 'cb'
        vim/_editor.lua:263: in function <vim/_editor.lua:262>

relevant neovim lsp configuration:

local lsp = require "lspconfig"
local coq = require "coq".lsp_ensure_capabilities
...
local on_attach = function(_, bufnr)
    local bufopts = { noremap=true, silent=true, buffer=bufnr }
    vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
    vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
    vim.keymap.set("n", "gh", vim.lsp.buf.hover, bufopts)
    vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
    vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, bufopts)
    vim.keymap.set("n", "gR", vim.lsp.buf.rename, bufopts)
    vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
    vim.keymap.set("n", "gf", vim.lsp.buf.formatting, bufopts)
end
...
lsp.jedi_language_server.setup(coq { on_attach = on_attach })

installed plugins:

    barbar.nvim
    clangd_extensions.nvim
    coq.artifacts
    coq_nvim
    emmet-vim
    gruvbox
    indent-blankline.nvim
    lualine.nvim
    nvim-lspconfig
    nvim-treesitter **(it DOES have python installed)**
    nvim-treesitter-context
    nvim-web-devicons
    packer.nvim
    plenary.nvim
    presence.nvim
    rust-tools.nvim
    telescope-file-browser.nvim
    telescope-fzf-native.nvim
    telescope.nvim
    trouble.nvim
    vim-commentary
    vim-easy-align
    vim-fugitive
    vim-hexokinase
    vim-surround

Expected behavior

The LSP server shouldn't error out and work with my autocomplete and there is no root directory, it is a single file.

Actual behavior

LSP server errors out as soon as the file is opened.

lavish440 commented 12 months ago

I am getting the same error since today afternoon. Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp.lua:1308: RPC[Error] code_name = InternalError, message = "AttributeError: 'Workspace' object has no attribute '_root_path'" data = "{'traceback': [' File \ "/home/lavish/.local/lib/python3.11/site-packages/pygls/protocol.py\", line 400, in _handle_request\\n self._execute_request(msg_id, handler, params)\\n', ' File \"/home/lavish/.local/lib/python3.11/site-packages/pygls/protocol.py\" , line 322, in _execute_request\\n self._send_response(msg_id, handler(params))\\n ^^^^^^^^^^^^^^^\\n', ' File \"/home/lavish/.local/lib/python3.11/site-packages/pygls/protocol.py\", line 137, in decor ator\\n ret_val = base_func(self, *args, **kwargs)\\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', ' File \"/home/lavish/.local/lib/python3.11/site-packages/jedi_language_server/server.py\", line 149, in lsp_initialize\\n i f server.workspace.root_path\\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', ' File \"/home/lavish/.local/lib/python3.11/site-packages/pygls/workspace/workspace.py\", line 224, in root_path\\n return self._root_path\\n ^^^^^^^^^^ ^^^^^\\n']}" stack traceback: [C]: in function 'assert' /usr/share/nvim/runtime/lua/vim/lsp.lua:1308: in function '' vim/_editor.lua: in function <vim/_editor.lua:0>

pappasam commented 12 months ago

I've raised upstream

pappasam commented 12 months ago

I believe this has been resolved with the latest pygls release!