1

Is pyright goto definition command supposed to jump into the different modules?

I import python class like this from a.b.c import Foo.

When my cursor is on a = Foo() and I call lua vim.lsp.buf.definition() nvim jumps only to the top of the file but does not follow the definition into the other module. Executing the same command on the top import moves nowhere.

I use the following script in my init.vim to set up the root_dir

local util = require("lspconfig/util")

lspconfig.pyright.setup({
  root_dir = function(fname)
    return util.root_pattern(".git", "setup.py",  "setup.cfg", "pyproject.toml", "requirements.txt")(fname) or
      util.path.dirname(fname)
  end
})
Lajos
  • 2,549
  • 6
  • 31
  • 38
  • 1
    Short answer - yes it is, it's working on my machine. Did you try lua vim.lsp.buf.declaration()? And do you have your root directory configured properly? Look here https://github.com/microsoft/pyright/blob/main/docs/configuration.md – kosciej16 Dec 15 '21 at 23:59
  • Yes, I have the root directory setup and I also added the declaration. I added an example to my question. How could I verify if the value is correct? – Lajos Dec 16 '21 at 01:13
  • 1
    Thank you, I found it. In my `init.vim` ```on_attach = on_attach``` property was not passed to `pyright` lsp config. I add the key bindings in the on_attach function. – Lajos Dec 16 '21 at 01:22
  • Glad to hear that! – kosciej16 Dec 16 '21 at 01:29

0 Answers0