navigator.lua icon indicating copy to clipboard operation
navigator.lua copied to clipboard

navigator.definition breaks with jedi_language_server

Open cj opened this issue 2 years ago • 1 comments

I'm using the latest version of navigator.lua with nvim 0.8:

I am getting this error with the command lua require('navigator.definition').definition():

Defination: RPC[Error] code_name = InvalidParams, message = "AttributeError: 'str' object has
no attribute 'as_uri'" data = "{'traceback': ['  File \"/Users/cj/apps/snap/snap-data/.venv/li
b/python3.10/site-packages/pygls/protocol.py\", line 324, in _handle_request\\n    self._execu
te_request(msg_id, handler, params)\\n', '  File \"/Users/cj/apps/snap/snap-data/.venv/lib/pyt
hon3.10/site-packages/pygls/protocol.py\", line 249, in _execute_request\\n    self._send_resp
onse(msg_id, handler(params))\\n', '  File \"/Users/cj/apps/snap/snap-data/.venv/lib/python3.1
0/site-packages/jedi_language_server/server.py\", line 246, in definition\\n    definitions =
[jedi_utils.lsp_location(name) for name in names]\\n', '  File \"/Users/cj/apps/snap/snap-data
/.venv/lib/python3.10/site-packages/jedi_language_server/server.py\", line 246, in <listcomp>\
\n    definitions = [jedi_utils.lsp_location(name) for name in names]\\n', '  File \"/Users/cj
/apps/snap/snap-data/.venv/lib/python3.10/site-packages/jedi_language_server/jedi_utils.py\",
line 77, in lsp_location\\n    return Location(uri=name.module_path.as_uri(), range=lsp_range(
name))\\n']}"{
  bufnr = 1,
  client_id = 5,
  method = "textDocument/definition",
  params = {
    position = {
      character = 17,
      line = 5
    },
    textDocument = {
      uri = "file:///Users/cj/apps/snap/snap-data/app/core/config.py"
    }
  }
}

lua vim.lsp.buf.definition() works with no errors.

Please let me know if you need any other information!

cj avatar Oct 26 '22 00:10 cj

Hi, Cj I did a quick test on jedi. It works fine for me. Do I need a specific python code and a specific definition to be found to reproduce?

Here is the code I used to test.

def greet(greeting, name):
    """
    This function greets to
    the person passed in as
    a parameter
    """
    print(greeting +        name + ". Good morning!")

def addition(num: int, num2: int = 2, num3: int = 3):
    return num + num2 + num3

def greet(greeting, name, msg1, msg2):
    """
    This function greets to
    the person passed in as
    a parameter
    """
    print(greeting + name + ". Good morning!")


greet("a", "b")  # I put my cursor on `greet`

ray-x avatar Oct 26 '22 02:10 ray-x