roxma / nvim-completion-manager

:warning: PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
MIT License
917 stars 49 forks source link

NCM uses wrong python version to start clang_complete #129

Closed NoAnyLove closed 7 years ago

NoAnyLove commented 7 years ago

When I tried to use NCM with clang_complete, I got the following error,

[ERROR] Loading libclang failed. Are you sure 'XXXXXXX' contains libclang?

I'm pretty sure I've already set the right path, so I want to find why this happens. I found the string in clang_complete\pythonx\libclang.py, which is in the except statement. I changed the code to print the exception, the exception is,

[ERROR] Loading libclang failed. [Error 193] %1 <b2><bb><ca><c7><d3><d0>Ч<b5><c4> Win32.

Error 193 occurs when 32bits python uses 64bits library, or vice versa. I used procexp and found NVM was running the clang_complete channel with Python 2. As shown in the screenshot,

screenshot

I have a 32bits Python 2.7 and a 64bits Python 3.6 on my Windows system, I have set g:python3_host_prog and g:python_host_prog, and also let g:loaded_python_provider = 1 to disable the Python 2 version.

If I comment out the the g:python_host_prog, the clang_channel will not start at all.

Here is the dump for g:_cm_sources. It shows that clang_complete is using python2 channel, which is not correct.

    'clang_complete': {
        'scopes': ['c', 'cpp'],
        'cm_refresh_patterns': ['(-\>|\.|::)'],
        'early_cache': 0,
        'name': 'clang_complete',
        'priority': 9,
        'enable': v: true,
        'auto_popup': 1,
        'scoping': v: true,
        'sort': 1,
        'channel': {
            'module': 'cm_sources.clang_complete',
            'events': ['BufEnter'],
            'type': 'python2'
        },
        'abbreviation': 'c',
        'cm_refresh_length': 3
    },

I finally found this is because roxma/clang_complete/pythonx/cm_sources/clang_complete.py registering it as python2. I think it is better to register it as python3, as NCM is using Python 3, and clang_complete has already support Python 3.