cpeluti

cpeluti

Do we have a LSP that's able to read type annotations?

Guys, I’m fairly new to elixir and I wondering if there’s any LSP that has type inference. I’m trying to define modules that implement a behavior and would like to know if there’s a way to autocomplete when I receive a generic module from a functions parameter

let me give you an example:



defmodule Project.Crawler.Strategy do
  @callback get_page(%Project.Site{}, String.t()) :: page()
end

@spec crawl(Project.Crawler.Strategy) :: boolean()
def crawl(module) do
  module.
end

When I type module. on the crawl/1 I would like to have the intellisense about what options are available for module

Is there anything like that?

Most Liked

LostKobrakai

LostKobrakai

This cannot be supported by LSPs. Typespecs cannot notate “a module, which implements a behaviour”. They can only notate module(), which is any module and just an alias for atom(). You used a literal module name in your example. That also has nothing to do with behaviours. It’s just the name as is, like you could use e.g. :ok in a typespec as well.

The upcoming elixir typesystem might eventually provide a notation for that, but by now that typesystem has no code notation at all.

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
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
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
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
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
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
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement