I'm thinking of migrating from Vim to NeoVim. I decided to begin with a bit of Python code in my .vimrc that sets the backup directory.

Using the documentation, I wrote the following script:

"------------------------------------------------------------ " Set swap file directory with Python python << endpython import neovim, os.path from os import getcwd, environ from hashlib import md5 cwd = getcwd() m = md5() m.update(cwd) swd = m.hexdigest() full_swd = os.path.join(environ['HOME'], '.config', 'nvim', '.swap', swd) if not os.path.exists(full_swd): os.makedirs(full_swd) nvim = neovim.attach('socket', path=environ['NVIM_LISTEN_ADDRESS']) nvim.command('set backupdir=' + full_swd) nvim.command('set directory=' + full_swd) endpython "------------------------------------------------------------

The problem I encountered is that this script hangs, even though I'm capable of repeating it via the command line. I tried to insert print statements in various places of the script, and it looks like this is the blocking line:

nvim.command('set backupdir=' + full_swd)

What am I doing wrong? Thank you very much.