def get_import_path_given_word(vim: object) -> str | None:
= vim.eval('expand("<cword>")')
word
for package, words in package_and_word.items():
if word in words:
= f"from {package} import {word}"
import_string print(import_string)
return import_string
This function above is used in vim_python.py
imported
into vim.
The vim.eval
literally runs the string passed in as vim
code and export the vim object into python object
For example, the following two vim commands are equivalent.
:py3 print(vim.eval('expand("<cword>")'))
:echom expand("<cword>")
See also :help if_pyth.txt