tweekmonster / django-plus.vim

:guitar: Improvements to the handling of Django related files in Vim
MIT License
179 stars 15 forks source link

deoplete + django-plus error #1

Closed monkoose closed 8 years ago

monkoose commented 8 years ago

When editing python files in django project(with outside python files all fine) with deoplete autocompletion there is the error appears in insert mode

[deoplete] Traceback (most recent call last):
[deoplete]   File "/home/monkoose/.local/share/nvim/site/dein/.dein/rplugin/python3/deoplete/deoplete.py", line 46, in completion_begin
[deoplete]     complete_position, candidates = self.gather_candidates(context)
[deoplete]   File "/home/monkoose/.local/share/nvim/site/dein/.dein/rplugin/python3/deoplete/deoplete.py", line 72, in gather_candidates
[deoplete]     results = self.gather_results(context)
[deoplete]   File "/home/monkoose/.local/share/nvim/site/dein/.dein/rplugin/python3/deoplete/deoplete.py", line 83, in gather_results
[deoplete]     charpos = source.get_complete_position(cont)
[deoplete]   File "/home/monkoose/.local/share/nvim/site/dein/.dein/rplugin/python3/deoplete/sources/django.py", line 29, in get_complete_position
[deoplete]     return self.vim.call('djangoplus#complete', 1, '')
[deoplete]   File "/usr/lib/python3.5/site-packages/neovim/api/nvim.py", line 213, in call
[deoplete]     return self.request('vim_call_function', name, args, **kwargs)
[deoplete]   File "/usr/lib/python3.5/site-packages/neovim/api/nvim.py", line 129, in request
[deoplete]     res = self._session.request(name, *args, **kwargs)
[deoplete]   File "/usr/lib/python3.5/site-packages/neovim/msgpack_rpc/session.py", line 98, in request
[deoplete]     raise self.error_wrapper(err)
[deoplete] neovim.api.nvim.NvimError: b'Vim(return):E117: Unknown function: pythoncomplete#Complete'
tweekmonster commented 8 years ago

That's strange because that error can't happen if it does exist. pythoncomplete#Complete() is the default completer that's in $VIMRUNTIME/ftplugin/python.vim. This plugin overrides it and defers to it if there's no Django-specific completions. Could you check the omnifunc setting in a non-Django file to see if it's set? If it is, try calling the function with echo pythoncomplete#Complete(1, ''). Also, try performing a completion with <c-x><c-o> to see if you get the same error.

monkoose commented 8 years ago

outside a django project omnifunc=jedi#completions and inside too

maybe i should turn off vim-jedi completiions? I used it(with manual completions) because deoplete-jedi sometimes fails with large libraries.

echo pythoncomplete#Complete(1, '') Error: Required vim compiled with +python Error: Required vim compiled with +python E117: Unknown function: pythoncomplete#Complete E15: Invalid expression: pythoncomplete#Complete(1, '')

And with <c-x><c-o> it calls to vim-jedi not deoplete-jedi with my config without an error.

Update: ok, i shut down vim-jedi completely, but still have the same error. omnifunc now outside project is pythoncomplete#Complete and inside djangoplus#complete as expected, but echo pythoncomplete#Complete(1, '') Error: Required vim compiled with +python Error: Required vim compiled with +python E117: Unknown function: pythoncomplete#Complete E15: Invalid expression: pythoncomplete#Complete(1, '') is the same error

tweekmonster commented 8 years ago

I think I see now. So, it thinks you don't have python 2 installed. What does has('python') show?

monkoose commented 8 years ago

I has. But neovim returns 0 to echo has('python') and 1 to echo has('python3'). I don't know why.

monkoose commented 8 years ago

Ok, i found. I didn't use neovim-python2 i guess. Let me check, now it returns 1 to echo has('python').

tweekmonster commented 8 years ago

Neovim allows you to run both versions, but you don't need to. The built-in Python completer apparently only supports Python 2, however. But, it's still setting the omnifunc option. I can add a check to make sure it doesn't try to use it if Python 2 isn't available.

monkoose commented 8 years ago

Ok, all works now as expected. Thank you for your time and help.