Git Product home page Git Product logo

Comments (21)

hstarmans avatar hstarmans commented on June 3, 2024 1

@cjrh The code is not Python 2 and Python 3 compatible. This is, however, easy to fix and test. Several other vim plugins have tackled this issue.
Do you have any experience with using vim-conda with YouCompleteMe?
It uses a Jedi-based completion engine for Python 2 and 3 (using the JediHTTP wrapper) or can I only use jedi-vim?
I will submit a pull request but need to test the plugin a bit with vim-ipython and YouCompleteMe and / or jedi-vim .

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

Hi Henrik

I recently merged a pull request that had print statements without parentheses. I think this might be causing the crash. I don't personally use vim compiled against Python 3 so I never pick these things up.

I've made a fix in 9977b0a, could you please try to update and see if that works for you? If not, it would be great for you to check which older commit of vim-conda did work for you, so that we can figure out where the problem began.

Good luck!

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

I had another look at the pull request I merged. The print statements were not modified by the PR, they already lacked parens. So it seems unlikely to have made a difference.

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

In your vim config, I see -python which means no Python 2 support. Pretty much the entire vim-conda plugin is executed with python blocks. In your vim, I'm guessing that if you go into command mode and try to run py 1 you get an error, whereas if you run py3 1 you get 1 returned? If this is the case, there probably isn't much we can do. If you look inside the source code for vim-conda.vim, you will see a bunch of Python sections that begin with

python << EOF
    blah
    blah
    blah
    blah
EOF

That python reference in the python << EOF line might already be causing the crash. Perhaps for Python 3 it should say python3 << EOF instead?

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

Ok, I'm feeling somewhat confident that the main issue is that vim-conda is explicitly calling python in all those embedded blocks. This is not going to work for Python 3, since there are explicit commands for Python 3.

This has been bugging me for a long time, and I guess it's time to do something about it!

I'm going to refactor vim-conda to remove all the Python out of the vim file and into a separate Python file, and instead call it with the pyfile command. Doing it like this will allow me to check whether to call either pyfile or py3file (using, e.g., has('python') and has('python3')) and should therefore make it possible to call both. This obviously also means that all the Python code will have to be compatible with both 2 and 3.

from vim-conda.

hholst80 avatar hholst80 commented on June 3, 2024

I tried replacing all the python << EOF with python3 << EOF and added a few hacks for str/bytes objects but I got this:

image

diff --git a/plugin/vim-conda.vim b/plugin/vim-conda.vim
index ae3dfcc..f52e5f0 100644
--- a/plugin/vim-conda.vim
+++ b/plugin/vim-conda.vim
@@ -78,7 +79,7 @@ def insert_system_py_sitepath():
     """ Add the system $PATH Python's site-packages folders to the
     embedded Python's sys.path. This is for Jedi-vim code completion. """
     cmd = "import site, sys, os; sys.stdout.write(os.path.pathsep.join(site.getsitepackages()))"
-    sitedirs = vim_conda_runpyshell(cmd).split(os.path.pathsep)
+    sitedirs = vim_conda_runpyshell(bytes(cmd, 'utf-8')).split(bytes(os.path.pathsep, 'utf-8'))
@@ -87,6 +88,7 @@ def insert_system_py_sitepath():
     #     libdir = os.path.dirname(sitedirs[0])
     #     if libdir not in sys.path:
     #         sys.path.insert(0, libdir)
+    sitedirs = [bytes(sitedir) for sitedir in sitedirs]
     for sitedir in sitedirs:
         if sitedir not in sys.path:
             sys.path.insert(0, sitedir)
@@ -122,6 +124,7 @@ else:
         # See also: http://bugs.python.org/issue3905
         # stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         stdin=subprocess.PIPE, stderr=subprocess.PIPE)
+    output = ''.join(chr(int(x)) for x in output)

from vim-conda.

hholst80 avatar hholst80 commented on June 3, 2024

The YouCompleteMe package is probably a good reference to look at for figuring out how to deal with Vim python (2.x) and python 3 in the same vim package.

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

I tried replacing all the python << EOF with python3 << EOF and added a few hacks for str/bytes objects but I got this:

Thanks for taking a look at this. That error you see is coming from YouCompleteMe, but I'm not sure what it means.

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

Actually, I'm wrong, the original exception was RuntimeError: dict size changing during iteration, not the YCM ImportError.

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

Ok I found the problem, it's here:

https://github.com/cjrh/vim-conda/blob/master/plugin/vim-conda.vim#L375

The code is:

for key, value in envnames.items():
    if value == default_prefix:
        current_env = key
        # Don't provide current_env as an option for user
        del envnames[key]

This code was a bit lazy on my part. I just wanted to remove the entry for the current prefix, but of course in Python 3 dict methods return views much of time.

As you can see above I've made a fix in cf901d9. I have not tested it though, so if you could let me know whether that problem goes away that would great.

from vim-conda.

hholst80 avatar hholst80 commented on June 3, 2024

I'm heading to island for a week but I sent a mail to myself to have a check as soon as I get back. Thanks for looking into it!

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

@hholst80 No problem, and thanks for your work 👍

from vim-conda.

machbio avatar machbio commented on June 3, 2024

@cjrh I had thought about this, but then I thought you only supported python 2, sorry about this

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

@machbio On my platform vim links against either Python 2 or 3, but not both, so I had to make a choice and I chose 2. (and though I play with neovim, which has facilities for working with both, I haven't wholescale switched yet). On the other hand, all the Python code I write, at least for the past two years is in Python 3. I know that it's a problem, but it's not an easy problem unfortunately.

YouCompleteMe has a solution for this problem: it calls Jedi via an intermediate HTTP server, and that server calls the Python env of your choice to provide completion in that environment. However, I am wary to recommend (and/or build direct integration with) YCM right now, because it can be tricky to install.

from vim-conda.

hholst80 avatar hholst80 commented on June 3, 2024

The dictionary problem went away but there are still some problems with string/byte (and utf??) miss matching. I tried fixing some of them but it's probably better if someone who's got more time to look into the problem deeply have a look instead of me hacking something together.

An instance of such error can look like:

Error detected while processing function <SNR>16_CondaChangeEnv:
line 58:
Traceback (most recente call last):
  File <string>, line 41, in <module>
TypeError: sequence item 0: expected str instance, bytes found

Note that I got this error on a changed vim-conda.vim (modified for python3).

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

I'm thinking that to work on this issue properly will require using both a vim compiled against Python 2, and another vim compiled against Python 3, to make sure that this plugin works in both.

from vim-conda.

hstarmans avatar hstarmans commented on June 3, 2024

I have checked the command:

sitedirs = vim_conda_runpyshell(cmd).split(os.path.pathsep)

should become -->

sitedirs = vim_conda_runpyshell(cmd).split(os.path.pathsep.encode())

An alternative solution is to apply a decode on the results of function of vim_conda_runshell and vim_condarunpyshell. This is my current solution and works better.
I also had to change msg_suppress. Currently, the code works. However, complicated operations like :python3 import numpy as np result in errors.

" vim-conda
" Version: 0.0.1
" Caleb Hattingh
" MIT Licence

" This is currently hard-coded and is therefore bad. I
" need some help figure out how to make it user-defined.
set wildcharm=<Tab>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
python3 << EOF
# Global code for Python
from os.path import join, dirname
from subprocess import check_output, PIPE
import json
import vim

def vim_conda_runshell(cmd):
    return check_output(cmd, shell=True, executable=os.getenv('SHELL'),
        # Needed to avoid "WindowsError: [Error 6] The handle is invalid"
        # When launching gvim.exe from a CMD shell. (gvim from icon seems
        # fine!?)
        # See also: http://bugs.python.org/issue3905
        # stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdin=PIPE, stderr=PIPE).decode()


def vim_conda_runpyshell(cmd):
    return check_output('python3 -c "{}"'.format(cmd), shell=True,
        executable=os.getenv('SHELL'),
        stdin=PIPE, stderr=PIPE).decode()


def get_conda_info_dict():
    """ Example output:
    {
      "channels": [
        "http://repo.continuum.io/pkgs/free/osx-64/",
        "http://repo.continuum.io/pkgs/free/noarch/",
        "http://repo.continuum.io/pkgs/pro/osx-64/",
        "http://repo.continuum.io/pkgs/pro/noarch/"
      ],
      "conda_build_version": "1.1.0",
      "conda_version": "3.9.0",
      "default_prefix": "/Users/calebhattingh/anaconda",
      "envs": [
        "/Users/calebhattingh/anaconda/envs/django3",
        "/Users/calebhattingh/anaconda/envs/falcontest",
        "/Users/calebhattingh/anaconda/envs/misutesting",
        "/Users/calebhattingh/anaconda/envs/partito",
        "/Users/calebhattingh/anaconda/envs/py26",
        "/Users/calebhattingh/anaconda/envs/py27",
        "/Users/calebhattingh/anaconda/envs/py3",
        "/Users/calebhattingh/anaconda/envs/py34"
      ],
      "envs_dirs": [
        "/Users/calebhattingh/anaconda/envs"
      ],
      "is_foreign": false,
      "pkgs_dirs": [
        "/Users/calebhattingh/anaconda/pkgs"
      ],
      "platform": "osx-64",
      "python_version": "2.7.9.final.0",
      "rc_path": null,
      "requests_version": "2.5.1",
      "root_prefix": "/Users/calebhattingh/anaconda",
      "root_writable": true,
      "sys_rc_path": "/Users/calebhattingh/anaconda/.condarc",
      "user_rc_path": "/Users/calebhattingh/.condarc"
    }
    """
    output = vim_conda_runshell('conda info --json')
    return json.loads(output)


def insert_system_py_sitepath():
    """ Add the system $PATH Python's site-packages folders to the
    embedded Python's sys.path. This is for Jedi-vim code completion. """
    cmd = "import site, sys, os; sys.stdout.write(os.path.pathsep.join(site.getsitepackages()))"
    sitedirs = vim_conda_runpyshell(cmd).split(os.path.pathsep)
    # The following causes errors. Jedi vim imports e.g. hashlib
    # from the stdlib, but it we've added a different stdlib to the
    # embedded sys.path, jedi loads the wrong one, causing errs.
    # Looks like we should only load site-packages.
    # if len(sitedirs) > 0:
    #     libdir = os.path.dirname(sitedirs[0])
    #     if libdir not in sys.path:
    #         sys.path.insert(0, libdir)
    for sitedir in sitedirs:
        if sitedir not in sys.path:
            sys.path.insert(0, sitedir)
EOF
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

function! s:SetCondaPlainPath()
python3 << EOF
import os
import vim
import subprocess
import json
import vim
# This is quite deceiving. `os.environ` loads only a single time,
# when the os module is first loaded. With this embedded-vim
# Python, that means only one time. If we want to have an
# up-to-date version of the environment, we'll have to use
# Vim's $VAR variables and rather act on that.
# TODO: Fix use of py getenv
path = os.getenv('PATH')
conda_default_env = os.getenv('CONDA_DEFAULT_ENV')
if not conda_default_env:
    pass
else:
    # We appear to be inside a conda env already. We want the path
    # that we would have WITHOUT being in a conda env, e.g. what
    # we'd get if `deactivate` was run.
    output = subprocess.check_output('conda info --json',
        shell=True, executable=os.getenv('SHELL'),
        # Needed to avoid "WindowsError: [Error 6] The handle is invalid"
        # When launching gvim.exe from a CMD shell. (gvim from icon seems
        # fine!?)
        # See also: http://bugs.python.org/issue3905
        # stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdin=subprocess.PIPE, stderr=subprocess.PIPE)
    d = json.loads(output)
    # We store the path variable we get if we filter out all the paths
    # that match the current conda "default_prefix".
    # TODO Check whether the generator comprehension also works.
    path = os.pathsep.join([x for x in path.split(os.pathsep)
                                if d['default_prefix'] not in x])
vim.command("let l:temppath = '" + path + "'")
EOF
return l:temppath
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


function! s:CondaActivate(envname, envpath, envsroot)
    " Set environment variables $PATH and $CONDA_DEFAULT_ENV
    let $CONDA_DEFAULT_ENV = a:envname
    if has("win32") || has("win64")
        let $PATH = a:envpath . ';' . a:envpath . '\Scripts' .';' . a:envpath . '\Library\bin' .';' . g:conda_plain_path
    elseif has("unix")
        let $PATH = a:envpath . '/bin' .  ':' . g:conda_plain_path
    endif
python3 << EOF
import os
import vim
# It turns out that `os.environ` is loaded only once. Therefore it
# doesn't see the changes we just made above to the vim process env,
# and so we will need to set these
os.environ['CONDA_DEFAULT_ENV'] = vim.eval('a:envname')
os.environ['PATH'] = vim.eval('$PATH')
EOF
endfunction


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! s:CondaDeactivate()
    " Reset $PATH back to what it was at startup, and unset $CONDA_DEFAULT_ENV
    " TODO: Maybe deactivate should really give us `g:conda_plain_path`?
    "       `g:conda_startup_path` would contain env stuff IF vim was started
    "       from inside a conda env..
    let $CONDA_DEFAULT_ENV = g:conda_startup_env
    let $PATH = g:conda_startup_path
python3 << EOF
import os
import vim
# It turns out that `os.environ` is loaded only once. Therefore it
# doesn't see the changes we just made above to the vim process env,
# and so we will need to update the embedded Python's version of
# `os.environ` manually.
if 'CONDA_DEFAULT_ENV' in os.environ:
    del os.environ['CONDA_DEFAULT_ENV']
os.environ['PATH'] = vim.eval('$PATH')
EOF
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


function! Conda_env_input_callback(A,L,P)
    " This is the callback for the `input()` function.
    " g:condaenvs will be assigned values inside `s:CondaChangeEnv()`
    return g:condaenvs
endfunction


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" STARTUP
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" This only runs when the script loads
if !exists("g:conda_startup_path")
    let g:conda_startup_path = $PATH
    " If vim is started from inside a conda path, this variable will
    " contain the path WITHOUT the extra conda env bits. Storing this
    " allows us to change conda envs internally inside vim without
    " carrying around any startup baggage in $PATH, if vim was started
    " from a terminal that already had a conda env activated.
    let g:conda_plain_path = s:SetCondaPlainPath()
    " Load all the required Python stuff at startup. These functions
    " get called from other places.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
python3 << EOF
import vim
import sys
import os
import subprocess
import json
import copy

_conda_py_globals = dict(reset_sys_path=copy.copy(sys.path))  # Mutable global container


def python_input(message = 'input'):
    vim.command('call inputsave()')
    vim.command("let user_input = input('" + message + "', '	', 'custom,Conda_env_input_callback')")
    vim.command('call inputrestore()')
    return vim.eval('user_input')


def obtain_sys_path_from_env(env_path):
    """ Obtain sys.path for the selected python bin folder.
    The given `env_path` should just be the folder, not including
    the python binary. That gets added here.

    :param str env_path: The folder containing a Python.
    :return: The sys.path of the provided python env folder.
    :rtype: list """
    pyexe = os.path.join(env_path, 'python3')
    args = ' -c "import sys, json; sys.stdout.write(json.dumps(sys.path))"'
    cmd = pyexe + args
    syspath_output = subprocess.check_output(cmd, shell=True,
        executable=os.getenv('SHELL'))
    # Use json to convert the fetched sys.path cmdline output to a list
    return json.loads(syspath_output)


def conda_activate(env_name, env_path, envs_root):
    """ This function performs a complete (internal) conda env
    activation. There are two primary actions:

    1. Change environment vars $PATH and $CONDA_DEFAULT_ENV

    2. Change EMBEDDED PYTHON sys.path, for jedi-vim code completion

    :return: None """
    # This calls a vim function that will
    # change the $PATH and $CONDA_DEFAULT_ENV vars
    vim.command("call s:CondaActivate('{}', '{}', '{}')".format(env_name, env_path, envs_root))
    # Obtain sys.path for the selected conda env
    # TODO: Perhaps make this flag a Vim option that users can set?
    ADD_ONLY_SITE_PKGS = True
    if ADD_ONLY_SITE_PKGS:
        new_paths = [os.path.join(env_path, 'lib', 'site-packages')]
    else:
        new_paths = obtain_sys_path_from_env(env_path)
    # Insert the new paths into the EMBEDDED PYTHON sys.path.
    # This is what jedi-vim will use for code completion.
    # TODO: There is another way we could do this: instead of a full reset, we could
    # remember what got added, and the reset process could simply remove those
    # things; this approach would preserve any changes the user makes to
    # sys.path inbetween calls to s:CondaChangeEnv()...
    # TODO: I found out that not only does jedi-vim modify sys.path for
    # handling VIRTUALENV (which is what we do here), but it also looks like
    # there is a bug in that the same venv path can get added multiple times.
    # So it looks like the best policy for now is to continue with the
    # current design.
    sys.path = new_paths + _conda_py_globals['reset_sys_path']   # Modify sys.path for Jedi completion
    msg_suppress = int(vim.eval('exists("g:conda_startup_msg_suppress")'))
    if not msg_suppress:
        print('Activated env: {}'.format(env_name))


def conda_deactivate():
    """ This does the reset. """
    # Resets $PATH and $CONDA_DEFAULT_ENV
    vim.command('call s:CondaDeactivate()')
    # Resets sys.path (embedded Python)
    _conda_py_globals['syspath'] = copy.copy(sys.path)  # Remember the unmodified one
    sys.path = _conda_py_globals['reset_sys_path']   # Modify sys.path for Jedi completion
    # Re-apply the sys.path from the shell Python
    # The system python path may not already be part of
    # the embedded Python's sys.path. This fn will check.
    insert_system_py_sitepath()
    msg_suppress = int(vim.eval('exists("g:conda_startup_msg_suppress")'))
    if not msg_suppress:
        print('Conda env deactivated.')

EOF
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


" Setting global paths - We use these to switch between conda envs.
if exists("$CONDA_DEFAULT_ENV")
    " This is happening at script startup. It looks like a conda env
    " was already activated before launching vim, so we need to make
    " the required changes internally.
    let g:conda_startup_env = $CONDA_DEFAULT_ENV
    " This may get overridden later if the default env was in fact
    " a prefix env.
    let g:conda_startup_was_prefix = 0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
python3 << EOF
import vim
import os
envname = vim.eval('g:conda_startup_env')
msg_suppress = int(vim.eval('exists("g:conda_startup_msg_suppress")'))
if msg_suppress:
    msg_suppress = int(vim.eval('g:conda_startup_msg_suppress'))
# Need to get the root "envs" dir in order to build the
# complete path the to env.
d = get_conda_info_dict()
roots = [os.path.dirname(x) for x in d['envs']
            if envname == os.path.split(x)[-1]]

if len(roots)>1:
    print ('Found more than one matching env, '
           'this should never happen.')
elif len(roots)==0:
    print ('\nCould not find a matching env in the list. '
           '\nThis probably means that you are using a local '
           '\n(prefix) Conda env.'
           '\n '
           '\nThis should be fine, but changing to a named env '
           '\nmay make it difficult to reactivate the prefix env.'
           '\n ')
    vim.command('let g:conda_startup_was_prefix = 1')
else:
    root = roots[0]
    envpath = os.path.join(root, envname)
    # Reset the env paths back to root
    # (This will also modify sys.path to include the site-packages
    # folder of the Python on the system $PATH)
    conda_deactivate()
    # Re-activate.
    conda_activate(envname, envpath, root)
EOF
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
else
    let g:conda_startup_env = ""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
python3 << EOF
insert_system_py_sitepath()
EOF
end
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


function! s:CondaChangeEnv()
python3 << EOF

#FINDME
# Obtain conda information. It's great they provide output in
# json format because it's a short trip to a dict.
import vim
import os


d = get_conda_info_dict()

# We want to display the env names to the user, not the full paths, but
# we need the full paths for things like $PATH modification and others.
# Thus, we make a dict that maps env name to env path.
# Note the juggling with decode and encode. This is being done to strip
# the annoying `u""` unicode prefixes. There is likely a better way to
# do this. Help would be appreciated.
# keys = [os.path.basename(e).decode().encode('ascii') for e in d['envs']]
keys = [os.path.basename(e).encode('utf-8') for e in d['envs']]
# Create the mapping {envname: envdir}
envnames = dict(zip(keys, d['envs']))
# Add the root as an option (so selecting `root` will trigger a deactivation
envnames['root'] = d['root_prefix']
# Detect the currently-selected env. Remove it from the selectable options.
default_prefix = d['default_prefix']
for key, value in envnames.items():
    if value == default_prefix:
        current_env = key
        break
# Don't provide current_env as an option for user
if current_env in envnames:
    del envnames[current_env]

# Provide the selectable options to the `input()` callback function via
# a global var: `g:condaenvs`
# startup_env = vim.eval('g:conda_startup_env')
# prefix_dir = os.path.split(startup_env)[-1]
# prefix_name = '[prefix]' + prefix_dir
# if vim.eval('conda_startup_was_prefix') == 1:
#     extra=[prefix_name]
# else:
#     extra=[]
vim.command('let g:condaenvs = "' + '\n'.join(envnames.keys()) + '"')
# Ask the user to choose a new env
choice = python_input("Change conda env [current: {}]: ".format(current_env))
vim.command('redraw')


if choice == 'root':
    conda_deactivate()
elif choice in envnames:
    conda_activate(choice, envnames[choice], os.path.dirname(envnames[choice]))
elif len(choice) > 0:
    vim.command('echo "Selected env `{}` not found."'.format(choice))
else:
    # Do nothing, i.e. no change or message
    pass
vim.command('redraw')
EOF
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

command! CondaChangeEnv call s:CondaChangeEnv()

" ISSUES
" http://stackoverflow.com/questions/13402899/why-does-my-vim-command-line-path-differ-from-my-shell-path
" THERE ARE OTHER ISSUES..SHELLS MUST MATCH
" https://github.com/gmarik/Vundle.vim/issues/510
" https://github.com/davidhalter/jedi-vim/issues/280
" https://github.com/davidhalter/jedi/issues/385
" https://github.com/davidhalter/jedi-vim/issues/196

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

@hstarmans Thanks for looking at this! Would you be able to submit the changes in a pull request? Also, have you checked that your changes work on both Python 2 and 3?

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

@hstarmans I've added you as a collaborator to this project. I have very little free time available right now and I don't want to prevent any progress by being unavailable.

This plugin code must be 2/3 compatible because a lot of people use vim compiled against one of the two python versions. That matters here because the python code interacts directly with vim.

Regarding compatibility with YouCompleteMe, I think you would have to add a feature in vim-conda to detect whether YouCompleteMe is installed, and then when a new conda env is activated, you'd have to restart either the YCM server or the JediHTTP wrapper that YCM uses. You would probably also have to setup your .vimrc to contain

let g:ycm_python_binary_path = 'python'

so that the modified $PATH (which vim-conda will modify when an env is changed) will allow JediHTTP to detect the new python.

Anyway, you have push rights on this repo now, good luck!

from vim-conda.

hstarmans avatar hstarmans commented on June 3, 2024

@cjrh Thank you for the invitation! I am also pretty busy right now, but will try to fix these minor additions. I will first try to make the code python 2 and 3 compatible and then fix the YouCompleteMe compatibility.

from vim-conda.

cjrh avatar cjrh commented on June 3, 2024

Here I found a specific command for RestartServer, although it may still be easier to just configure the ycm binary path setting to 'python' and just restart JediHTTP. You'll probably have to test out what works better.

Anyway, here is the link to the YCM setting: https://github.com/Valloric/YouCompleteMe#the-restartserver-subcommand

from vim-conda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.