huibosa

huibosa

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

Showing Posts 1 to 2

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?

huibosa

huibosa OP

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()
— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews