huibosa

huibosa

Neovim elixirls failed autocompletion for local module

Begin learning elixir recently, and i was setup the elixirls in neovim following this guide. I could get most of the lsp elixirls feature work, such as doc hover, snippet, autocompletion, and so on, but I found I just can’t get the autocompeletion work for local module in another file. I’ll describe my problem as follows:

I’ve got two files in same directory, person.exs and main.exs:

![file1](/Users/huibosa/Desktop/Screenshot 2023-10-03 at 4.14.18 PM.png)

![file2](/Users/huibosa/Desktop/Screenshot 2023-10-03 at 4.15.35 PM.png)

which can be seen from the pictures that the autocompeletion source for module Person failed in main.exs. However, when I move the statements to person.exs`, I could get the expected autocompeletion:

![file3](/Users/huibosa/Desktop/Screenshot 2023-10-03 at 4.16.36 PM.png)

At first I thought this would be a lack of implementation of something in elixirls, but when I switch to vscode, where I’ve installed the elixirls viscose extension, finding that the autocompeletion works as ecpected:

![file4](/Users/huibosa/Desktop/Screenshot 2023-10-03 at 3.59.40 PM.png)

To give you more information:

  • Neovim version: v0.9.2
  • Elixirs version: v0.16.0
  • OS: mac

Most Liked

TunkShif

TunkShif

Autocompletion for files outside a mix project should only be limited to the current open file. So you can’t get auto completion from “person.exs” in “main.exs”. And I’ve tested it in both Neovim and VSCode.
Can you reupload those broken images if I misunderstood something?

Last Post!

huibosa

huibosa

Thanks for your generous help. Since the forum system tells me that the new user can’t upload a picture, I’ve get the help from the github issue.

Furtherly, for any beginner like me from other languages who wants to get the autocompletion in a “single-file-script”, I recommend just move the code snippets inside the module, like the run() function below:

defmodule People.Person do
  alias People.Person

  defstruct first_name: nil,
            last_name: nil,
            birthday: nil,
            location: "home"

  def full_name(%__MODULE__{first_name: first_name, last_name: nil}) do
    "#{first_name}"
  end

  def full_name(%__MODULE__{first_name: first_name, last_name: last_name}) do
    "#{first_name} #{last_name}"
  end

  def age(%__MODULE__{birthday: birthday}) do
    days = Date.diff(Date.utc_today(), birthday)
    days / 365.25
  end

  def toggle_location(%__MODULE__{location: "home"} = person) do
    person |> set_location("away")
  end

  def toggle_location(%__MODULE__{location: "away"} = person) do
    person |> set_location("home")
  end

  defp set_location(%__MODULE__{} = person, location) do
    %{person | location: location}
  end

  def run() do
    person = %Person{
      first_name: "foo",
      last_name: "bla",
      birthday: ~D{1995-03-19}
    }

    person |> Person.full_name() |> IO.puts()
  end
end

People.Person.run()

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49084 226
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40042 209
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement