Hacker News new | past | comments | ask | show | jobs | submit login

Autocomplete with Conda has got no support - if anyone has any idea other than; https://github.com/cjrh/vim-conda



Well, if you genuinely want a braindead alternative to `vim-conda`, you're welcome to this brittle hack I use. (For my purposes, fast-and-dirty has been an efficient solution, but I don't actually recommend this to anyone.)

Add it to your `ftplugin/python.vim`. Requires you to have activated the Conda environment before opening the Python file, uses hard-coded Python versions, doesn't work with multiple environments, doesn't bother with `os.path.join` so no Windows compatibility, etc etc. Like I said: a hack.

  " Cheap trick to use the Conda environment with omnicompletion
  python3 << EOF
  import os
  import sys
  cenv = os.environ.get('CONDA_PREFIX')
  if cenv is not None:
      # Taken from `sys.path` as reported by ipython
      sys.path.insert(0, cenv + '/lib/python3.5/site-packages')
      sys.path.insert(0, cenv + '/lib/python3.5/lib-dynload')
      sys.path.insert(0, cenv + '/lib/python3.5/plat-linux')
      sys.path.insert(0, cenv + '/lib/python3.5')
      sys.path.insert(0, cenv + '/lib/python35.zip')
      sys.path.insert(0, cenv + '/bin')
  EOF
  set omnifunc=python3complete#Complete
edit: mentioned `os.path.join` to warn Windows users and fixed in-place bugfix.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: