0

I am compiling Vim on Linux (18.04 Ubuntu) on a new environment and I am experiencing an issue with a lot of my vimrc configuration, which has some inline python logic.

Basically the python code just errors like this: NameError: name 'vim' is not defined. My understanding is that the python integrated to vim automatically has the ability to import vim, and it should just work. Indeed echo has('python') definitely returns 1.

I've confirmed that:

  • package provided vim (which never has lua compiled in! argh!) works right.
  • my compiled vim has the python issues, regardless of if I compile just python2, both python2 and python3, specify the x86_64-linux-gnu config path or not (and have the compiled vim report python/dyn or python). It never works.

At this point I don't even care if I can find a properly compiled package of Vim that has everything I need in it. At this point now I need to get to the bottom what I am configuring wrong for the compilation.

1

This is really strange. Basically:

in my compiled vims, as long as I run py import vim, vim becomes defined thereafter and everything works.

So I can probably just add this statement in my vimrc and move on with my life.

There must be some undocumented compile or config flag that makes this happen automatically by default or something.

  • AFAIK import vim has never been added by default, and is always required. This is how it's documented in :help python-vim as well. It's possible there was some config that did this for you on your previous machine (e.g. vimrc or PYTHONSTARTUP env). – Martin Tournoij Jul 9 '18 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.