lexical-lsp / lexical

Lexical is a next-generation elixir language server
779 stars 77 forks source link

Index `Ecto` schema struct #695

Closed scottming closed 3 weeks ago

scottming commented 2 months ago

For example, when we define a module like:

defmodule User do
  use Ecto.Schema

  schema "users" do
    field :name, :string
    field :age, :integer, default: 0
    field :password, :string, redact: true
    has_many :posts, Post
  end
end

and we can't go to the definition when the cursor at %Use|r{} right now, it is pretty annoying.

scottming commented 2 months ago

Currently, for such structs, we have reverted to using this PR: #707 to retrieve definitions from ElixirSense. This is not a problem easily solved by indexing, and as @zachallaun commented on Discord, we may not want to handle such things specially but instead consider macro expansion.