slashmili / alchemist.vim

Elixir Integration Into Vim
https://github.com/slashmili/alchemist.vim/wiki
GNU General Public License v3.0
651 stars 38 forks source link

Autocompletion problems, both python2 and python3 #116

Closed tdejager closed 6 years ago

tdejager commented 6 years ago

If autocomplete/docs or etc doesn't work for you before creating issue please check Debugging page and make sure your basic setup works

https://github.com/slashmili/alchemist.vim/wiki/Debugging

and answer these questions:

  1. Elixir/OTP/Python version

Elixir:

Elixir 1.5.1

OTP:

Erlang/OTP 20

Python: Python 2 and 3 in system Python 3 in vim

  1. Which pluging are you using:

[ ] basic omnifunc [X ] YouCompleteMe [ ] deoplete

  1. Which steps of Debugging passed?

[ ] Elixir Module definition [ ] Elixir Function definition [ ] Elixir Module/Function docs [ ] Your Project Module definition [ ] Your Project Function definition

  1. Do you have a specific setup? Like Docker and etc

I am running Ubuntu 14.04 and vim8, version 2.8.2 does seem to work

====================================================================== Problem description:

First off thanks for all the great work with this plugin. Version 2.8.2 seems to work as a charm, which is why I would really like to see this version working as well :)

Autocomplete does not work. When running the debugging steps, all seem to fail. My vim setup is with python3, because alas in ubuntu 14.04 one is unable to run both versions.

I have tried running the debug steps from the command line with both python versions.

When running the first step command, I have the following output (python2):

 ~/.vim/plugged/alchemist.vim/elixir_sense_client -d./ -c1 -l1 --request=definition < sample.exs
Traceback (most recent call last):
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense_client", line 81, in <module>
    main(sys.argv[1:])
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense_client", line 71, in main
    response = sense.process_command(request, source, line ,column)
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense.py", line 73, in process_command
    rep_py_struct = erl_terms.decode(resp_erl_struct)
  File "/home/tdejager/.vim/plugged/alchemist.vim/erl_terms.py", line 59, in decode
    (obj_size, fn) = __decode_func(binary)

Other commands give similar outputs:

~/.vim/plugged/alchemist.vim/elixir_sense_client -d./ -c6 -l1 --request=definition < sample.exs
Traceback (most recent call last):
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense_client", line 81, in <module>
    main(sys.argv[1:])
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense_client", line 71, in main
    response = sense.process_command(request, source, line ,column)
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense.py", line 73, in process_command
    rep_py_struct = erl_terms.decode(resp_erl_struct)
  File "/home/tdejager/.vim/plugged/alchemist.vim/erl_terms.py", line 59, in decode
    (obj_size, fn) = __decode_func(binary)
  File "/home/tdejager/.vim/plugged/alchemist.vim/erl_terms.py", line 89, in __decode_func
    (obj_size, fn) = __decode_func(tmp_binary)
  File "/home/tdejager/.vim/plugged/alchemist.vim/erl_terms.py", line 99, in __decode_func
    raise NotImplementedError("Unable to unserialize %r" % binary[0])
NotImplementedError: Unable to unserialize 'w'

All other debugging steps give similar outputs.

When running with python3

When running with python3 I have issues similar to those reported by other users

python3 ~/.vim/plugged/alchemist.vim/elixir_sense_client -d./ -c1 -l2 --request=definition < sample.exs
Traceback (most recent call last):
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense_client", line 81, in <module>
    main(sys.argv[1:])
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense_client", line 71, in main
    response = sense.process_command(request, source, line ,column)
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense.py", line 52, in process_command
    req_erl_struct = erl_terms.encode(py_struct)
  File "/home/tdejager/.vim/plugged/alchemist.vim/erl_terms.py", line 201, in encode
    return FORMAT_VERSION + __encoder_func(struct)(struct)
  File "/home/tdejager/.vim/plugged/alchemist.vim/erl_terms.py", line 229, in __encode_map
    for k,v in obj.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'
slashmili commented 6 years ago

@tdejager I'm sorry that it doesn't work out of the box but believe me, the new one is much better 😬

When you run the elixir_sense_client command it's using env to find your python executable

#!/usr/bin/env python

Did you try to use this fix https://github.com/slashmili/alchemist.vim/issues/110#issuecomment-327713724 to force using python2 ?

tdejager commented 6 years ago

Wow, thanks for the prompt reply! :smile:

And yes, the errors seem to be the same, forcing the python2 version. If I do that the errors keep being along the lines of raise NotImplementedError("Unable to unserialize %r" % binary[0]).

When running the python3 version it is the known iteritems error.

edit: sorry pressed close issue by accident

slashmili commented 6 years ago

I've been trying to ignore this problem for a long time :( We need to support python3 one way or another

Can you give me the full stack trace with python2 in the header?

tdejager commented 6 years ago

As a check this is the output for the python2 env command

$ /usr/bin/env python2

Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Running command:

~/.vim/plugged/alchemist.vim/elixir_sense_client -d./ -c1 -l1 --request=definition < sample.exs

With patched file:

--- a/elixir_sense_client
+++ b/elixir_sense_client
@@ -1,9 +1,9 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 from __future__ import print_function
 import os, sys, getopt
 from elixir_sense import ElixirSenseClient

-debug = False
+debug = True

 read_stdin = vars(__builtins__).get('raw_input',input)

Stacktrace:

Traceback (most recent call last):
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense_client", line 81, in <module>
    main(sys.argv[1:])
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense_client", line 71, in main
    response = sense.process_command(request, source, line ,column)
  File "/home/tdejager/.vim/plugged/alchemist.vim/elixir_sense.py", line 73, in process_command
    rep_py_struct = erl_terms.decode(resp_erl_struct)
  File "/home/tdejager/.vim/plugged/alchemist.vim/erl_terms.py", line 59, in decode
    (obj_size, fn) = __decode_func(binary)
  File "/home/tdejager/.vim/plugged/alchemist.vim/erl_terms.py", line 89, in __decode_func
    (obj_size, fn) = __decode_func(tmp_binary)
  File "/home/tdejager/.vim/plugged/alchemist.vim/erl_terms.py", line 99, in __decode_func
    raise NotImplementedError("Unable to unserialize %r" % binary[0])
NotImplementedError: Unable to unserialize 'w'

Syslog output

Nov  2 10:42:36 tim-linux alchemist_client: project_dir(matched): /home/tdejager/development/rosclient
Nov  2 10:42:36 tim-linux alchemist_client: column: 1
Nov  2 10:42:36 tim-linux alchemist_client: line: 1
Nov  2 10:42:36 tim-linux alchemist_client: source: Enum.map#012CustomModule#012CustomModule.foo
Nov  2 10:42:36 tim-linux alchemist_client: Load server settings from: /tmp/alchemist_server/zS2homezS2tdejagerzS2developmentzS2rosclient
Nov  2 10:42:36 tim-linux alchemist_client: Initializing ElixirSense server for environment "dev" (Elixir version 1.5.1)
Nov  2 10:42:36 tim-linux alchemist_client: Working directory is "/home/tdejager/development/rosclient"
Nov  2 10:42:36 tim-linux alchemist_client: ok:localhost:/tmp/elixir-sense-1509615619985571959.sock
tdejager commented 6 years ago

The binary being returned is somewhere along the lines of, when printing to stdout:

�twerrorwnilwpayloadm]/home/vagrant/2017-08-02_13-04-43/scripts/elixir/deb/elixir_1.5.1-1/lib/elixir/lib/enum.ex:-1w request_ida

slashmili commented 6 years ago

@tdejager are you running the elixir in Vagrant?

If you join #vim-elixir in freenode or #vim in elixir slack we can take a look at your problem together.

tdejager commented 6 years ago

No, I am not actually :). And will do that later thanks!

tdejager commented 6 years ago

Hi, sorry I never did what I said in the last message. But it seems this problem has been fixed on my system. So I think we can close this issue?