1

I regularly use <leader>d to go to a function definition. When this definition is from another file, it brings me to the import line of the file.

How can I use jedi-vim to go to the file that defines the function imported on that line?

krumpelstiltskin
  • 486
  • 7
  • 17

1 Answers1

3

It sounds like there is something wrong with your configuration... Double check that your filetype is indeed python. This should work, according to the documentation:

5.2. g:jedi#goto_command

Function: jedi#goto()

Default: <leader>d

Go to definition (or assignment)

This function first tries jedi#goto_definitions, and falls back to jedi#goto_assignments for builtin modules. It produces an error if nothing could be found. NOTE: this implementation is subject to change. Ref: https://github.com/davidhalter/jedi/issues/570

This command tries to find the original definition of the function/class under the cursor. Just like the jedi#goto_assignments() function, it does not work if the definition isn't in a Python source file.

The difference between jedi#goto_assignments() and jedi#goto_definitions() is that the latter performs recursive lookups. Take, for example, the following module structure:

# file1.py:
from file2 import foo

# file2.py:
from file3 import bar as foo

# file3.py
def bar():
    pass

The jedi#goto_assignments() function will take you to the

from file2 import foo

statement in file1.py, while the jedi#goto_definitions() function will take you all the way to the

def bar():

line in file3.py.

George Hilliard
  • 15,402
  • 9
  • 58
  • 96
  • You are correct. It does work with installed libraries. I didn't realize this. The problem is with libraries I've written. I'm going to ask another question related to this problem. – krumpelstiltskin Oct 25 '16 at 08:43
  • The other question is at http://stackoverflow.com/questions/40235611/using-goto-with-user-defined-modules-in-jedi-vim. – krumpelstiltskin Nov 14 '16 at 23:42