-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocomplete/hover does not work properly for code aliases via use #193
Comments
Okay, made a little progress on this. It is related to the Elixir versions in play. It is broken if ElixirLS was compiled under 1.7.4 and running as 1.10.0+, but if ElixirLS was compiled under 1.10.0 and running as 1.10.0 it works. Yet another reason that we need #115 |
Although #121 might be a better short-term fix for it since it involves compiling ElixirLS under the same version of Elixir and Erlang that the project runs with. |
Any progress on this? I've got the same problem |
Nothing yet, and help is definitely appreciated. Another workaround would be to have a configuration to use a local install of ElixirLS (which would be based on #104). As a workaround if you know your vscode extension directory you can overwrite the version of the server there with one installed with a higher elixir version (but all your projects will need to have to use the same or higher version of elixir). But you'd use a command like |
To my understanding, the solution to this problem is compiling elixir-ls with erlang/elixir the user have? If so, |
@axelson Can you confirm that the workaround with compiling elixir-ls with the current installed elixir version still works? I'm currently unable to get this workaround to work for me, although I'm using
Installed via |
@JohnnyCrazy Yes this workaround is still applicable. Although I haven't tested on 1.12.0-dev. But also it's important to consider that the current tip of |
EDIT: 1.11 actually works with the PR you mentioned! |
Thanks for the report and especially for testing it with #360. We definitely won't be looking at 1.12.0-dev support since it won't be released until 9 months or so from now. |
I have put together all the steps needed to update the language server inside the extension https://dragoshmocrii.com/fix-vscode-elixirls-intellisense-for-code-imported-with-use/ . I am now finally getting IntelliSense for my Schema files, LiveView modules, and basically everywhere in my Phoenix application that makes use of Update: The problem I was having was with how macros were resolved by the Language Server. By default, the LS extension that ships with the plugin is built with Elixir 1.8 and Erlang 21. Subsequently, if your project is using a later Elixir version, such as Elixir 1.13.1 and Erlang 23, you may not be getting all the functionality that the LS is supposed to provide. |
Thanks everyone and @DragosMocrii for your writeup! In order for this to work, do I have to set my project's Elixir version to the same version as well? I just tried above steps a few times but it seems like thats also required. Pardon me if I'm only stating the obvious. |
@maximumstock I believe that your project's Elixir version needs to be higher or equal to the version that the LS plugin has been built with. However, if the project's Elixir version is too far ahead, then the LS may not work correctly (as was the case I described). If you have multiple Elixir versions (ie if you use asdf), the guide I wrote may not work, or may need to be adjusted in some way. I was using asdf before, but couldn't get the LS plugin to compile, so I had to install Elixir globally (one version). See this comment too #193 (comment) |
@DragosMocrii Alright, thank you very much for replying. I'll keep an eye on it. |
Wouldn't it make sense to provide some information regarding this in the README? I mean, as it's buried here most people might not really get the full functionality elixir-ls provides. I would assume a lot of projects are running OTP > 21 right now. |
I tried compiling Erlang/OTP 22 [erts-10.7] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
Elixir 1.11.2 (compiled with Erlang/OTP 21) But I'm still not getting auto-complete for defmodule CommunityWeb.Schema.ContentTypes do
use Absinthe.Schema.Notation
# object doesnt autocomplete
object :post do
field :name, non_null(:string)
end
end I had to defmodule CommunityWeb.Schema.ContentTypes do
use Absinthe.Schema.Notation
import Absinthe.Schema.Notation
object :post do # object doesnt autocomplete
field :name, non_null(:string)
end
end |
Can you try the following on your machine? Assuming you are running VSCode and the latest 0.8.0 version of the extension. git clone --depth 1 --branch v0.8.0 https://github.com/elixir-lsp/elixir-ls.git
cd elixir-ls
mix deps.get
mix elixir_ls.release -o ~/.vscode/extensions/jakebecker.elixir-ls-0.8.0/elixir-ls-release/ Then check in the output console for ElixirLS that it states the following when opening a mix project. The last line should match your Erlang/OTP and Elixir version.
|
Elixir-LS output Started ElixirLS v0.8.0
Elixir version: "1.11.2 (compiled with Erlang/OTP 21)"
Erlang version: "22"
ElixirLS compiled with Elixir 1.11.2 and erlang 22
MIX_ENV: test My elixir version Erlang/OTP 22 [erts-10.7] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
Elixir 1.11.2 (compiled with Erlang/OTP 21) |
I think the issue is that your elixir version has compiled with OTP 21 and the ElixirLS version has been compiled using OTP 22. ElixirLS does not support elixir versions which have been compiled with a lower OTP version than the ElixirLS has been compiled against (afaik). |
I tried on my mac with OTP 24(both elixir and elixir-ls). But no luck. Still no autocompletion for |
@kasvith can you try following these instructions https://dragoshmocrii.com/fix-vscode-elixirls-intellisense-for-code-imported-with-use/ ? Also, if you installed Elixir/Erlang with asdf, it may not work for you. |
@DragosMocrii thanks for the article, I already tried that(found this in the same thread when I searched before). For some reason I do not get autocomplete for |
It seems with the same setup |
As of 22nd January, 2022, this is still a problem. I'm gonna leave what my inference on the situation is to hopefully help others like me.
|
Yes Absinthe doesn't work well with ElixirLS unless you use |
@kasvith @KaranAhlawat you are hitting a limitation in elixir_sense. It has only a limited understanding of macro generated code. In order to have first class support for Absinthe it would require a dedicated plugin. We already have one for Ecto (https://github.com/elixir-lsp/elixir_sense/tree/master/lib/elixir_sense/plugins) and we are open for contributions. |
Thanks for the info...this problem is kind of a nightmare |
I use asdf and I can confirm it doesn't work. Is there no workaround for asdf for now? |
its not a problem with asdf |
Ahh. 😅😅. I didn't understand what read. This makes me think I probably didn't read the article correctly. I will try again. |
I followed @DragosMocrii instructions, and it resolved the issue for me! Now autocomplete/hover works for code aliased with I have a separate issue though, which I think it related, and just curious what the expected behavior is. Phoenix Controller actions always take But hovering over the The typespec does provide IntelliSense for But in the action body, it seems like It seems like, especially with the Is there some additional configuration that would enable this? Is this supported at all? |
I don't know if specs are considered, but you could pattern match on the
|
@ellismarkf There actually 2 (or more) separate issues you mention. First as @benvp speculated specs from the module/behaviours/protocols are not considered in elixir_sense type inference engine. Currently only assignments or match expressions are used so |
Should this in theory now be fixed by the latest release? @lukaszsamson @DragosMocrii |
Using 0.14.2, I now have auto-completion in Ecto migrations (which does use |
So far only the vscode extension uses Mix.install and there are still issues that need ironing out |
If anyone other VS Code users have upgraded to OTP 26, you'll likely encounter issues with the language server, which (as of today) on |
@vanderhoop elixirLS does not support OTP26 as it has critical IO bugs impacting LSP protocol, see #886. I'll resume work on official support when OTP releases fixes for those problems. |
@vanderhoop I run into this error:
That looks like the error I get in VSCodium when I enable regular ElixirLS for my Phoenix project:
|
This should no longer be an issue. ElixirLS 0.15 (and 0.14 for vscode extension) switched release mode to |
For details see this forum post: https://elixirforum.com/t/problem-with-use-macro-in-vscode-elixirls/30450
Which goes along with this repository: https://github.com/JanKneiphof/autocomplete_problem/
I'm able to reproduce the problem locally but I've been having a hard time reproducing it in tests.
The text was updated successfully, but these errors were encountered: