Skip to content
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

Can't hover on well known functions #241

Closed
andrepaes opened this issue Sep 26, 2023 · 4 comments
Closed

Can't hover on well known functions #241

andrepaes opened this issue Sep 26, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@andrepaes
Copy link

andrepaes commented Sep 26, 2023

Hey, i'm trying to hover on functions that i'm pretty sure that has docs and the lsp is saying that it doesn't exists. For some functions it works but for others don't, so i think it's not related with my nvim configs.
image
Some functions on Map module works but others don't, the same occurs for Enum module and for custom functions/types.
image
image

Thanks in advance,
André Luiz

@mhanberg
Copy link
Collaborator

Thanks for the report

I think the first thing is because we might not being indexing types yet.

The third screenshot seems to be odd.

would you mind copy pasting that code so i can test it?

also as a quick test, can you see what happens if you format that last snippet like this and hten save and check

expected_payload = Map.take(
  body,
  Map.keys(@bet_payload_keys)
)

if that is the case, it might be related to #184

@andrepaes
Copy link
Author

andrepaes commented Sep 26, 2023

It seems to not be related with the format.
image

defmodule Parsers.Bet do
  @bet_payload_keys %{
    user: &is_binary/1,
    transaction_uuid: &is_binary/1,
    round: &is_binary/1,
    request_uuid: &is_binary/1,
    game_code: &is_binary/1,
    currency: &is_binary/1,
    bet: &is_binary/1,
    amount: &is_integer/1
  }

  @spec parse(map()) :: {:ok, map()} | {:error, :wrong_types}
  def parse(body) do
    expected_payload =
      Map.take(
        body,
        Map.keys(@bet_payload_keys)
      )

    valid_types? =
      Enum.all?(expected_payload, fn {key, value} ->
        validator = @bet_payload_keys[key]

        validator.(value)
      end)

    if valid_types? do
      {:ok, expected_payload}
    else
      {:error, :wrong_types}
    end
  end
end

@mhanberg
Copy link
Collaborator

I was able to replicate, thanks for the report!

@mhanberg mhanberg added the bug Something isn't working label Sep 26, 2023
@mhanberg
Copy link
Collaborator

actually, this might be because you're erlang wasn't built with docs.

the reason why that is apparent for the Map.keys/1 function is because it is inlined by the compiler (there is a bug fix for that on Elixir main), so it would show the erlang docs instead

if you install erlang with asdf or rtx, you can do KERL_BUILD_DOCS=1 asdf install erlang <version> and then it will work

CleanShot 2023-09-26 at 12 07 58@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants