bfredl / nvim-ipy

IPython/Jupyter plugin for Neovim
MIT License
423 stars 29 forks source link

IPyConnect issue #18

Open jredies opened 8 years ago

jredies commented 8 years ago

I understand that you already have similar issues posted here. I start nvim from a python2.7 virtualenv which has neovim and pyzmq installed (pip).

Also, I did:

cd rplugin; ln -s python3 python

The neovim config contains

if has('python')
py << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
    project_base_dir = os.environ['VIRTUAL_ENV']
    sys.path.insert(0, project_base_dir)
    activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
    execfile(activate_this, dict(__file__=activate_this))
EOF
endif

Hence, should activate that virtualenv within neovim. (Works with jedi.)

:IPython2 yields

no notification handler registered for "/users/is/jredies/.config/nvim/plugged/nvim-ipy/rplugin/python/nvim_ipy:function:IPyConnect"

and :UpdateRemotePlugins yields

function remote#host#UpdateRemotePlugins[6]..<SNR>19_RegistrationCommands[13]..remote#host#Require[13]..provider#pythonx#Require, line 13
Vim(let):E903: Could not spawn API job
function remote#host#UpdateRemotePlugins[6]..<SNR>19_RegistrationCommands[13]..remote#host#Require[13]..provider#pythonx#Require, line 22
Failed to load python3 host. You can try to see what happened by starting Neovim with the environment variable $NVIM_PYTHON_LOG_FILE set to a file and opening the generated log file. Also, the host stderr will be available in Neovim log, so it may contain useful informat
ion. See also ~/.nvimlog.
remote/host: python host registered plugins ['nvim_ipy']
remote/host: generated the manifest file in "/users/is/jredies/.dotfiles/nvim/.init.vim-rplugin~"

/users/is/jredies/.dotfiles/nvim/.init.vim-rplugin~ contains just

" ruby plugins

" python plugins
call remote#host#RegisterPlugin('python', '/users/is/jredies/.config/nvim/plugged/nvim-ipy/rplugin/python/nvim_ipy', [
      \ {'sync': v:false, 'name': 'IPyComplete', 'type': 'function', 'opts': {}},
      \ {'sync': v:true, 'name': 'IPyConnect', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'IPyInterrupt', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'IPyObjInfo', 'type': 'function', 'opts': {}},
      \ {'sync': v:true, 'name': 'IPyOmniFunc', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'IPyRun', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'IPyTerminate', 'type': 'function', 'opts': {}},
     \ ])

Starting nvim with $NVIM_PYTHON_LOG_FILE and running :UpdateRemotePlugins gives the following logfile (and another empty logfile):

2016-04-28 13:42:03,176 [INFO @ script_host.py:setup:50] 45143 - install import hook/path
2016-04-28 13:42:03,176 [INFO @ script_host.py:setup:55] 45143 - redirect sys.stdout and sys.stderr
bfredl commented 8 years ago

do you have latest nvim 0.1.4 (or master) and latest python-client (neovim pip2 package) 0.1.7 ?

What happens if you activate the virtualenv before starting neovim? (It might be too late to do it in init.vim)

jredies commented 8 years ago

NeoVim Version v0.1.5-92-g490804e (master) and

# yolk -a | grep vim
neovim          - 0.1.7        - active

So, the virtualenv is activate before I start neovim. As far as I understand this it is just activated within neovim during startup in the init.vim. Where would I put the code to activate it faster?

jredies commented 8 years ago

Using this

let g:python_host_prog = '/users/is/jredies/pyenvs/dev/bin/python'
let g:loaded_python3_provider = 1

instead of my above mentoined Python code snippet doesn't make a difference. I have put this and the Python Snippt respectively in a source ~/.config/nvim/python.vim which is sourced in my init.vim after handling the Plugin Manager.