Erlang LS Does not Identify Nitrogen Elements

Hey everyone, I am just starting with Erlang and I am going through the “Build it with Nitrogen” book. But after installing the framework and generating the project, I noticed that Erlang LS keeps complaning on the Elements that generated HTML, example:

inner_body() -> 
    [
        #h1{ text="Erlingo! WEBSPINNERS" },       `Erlang LS: record h1 undefined`
        #h1{ text="WELCOME!" },                             `Erlang LS: record h1 undefined`
        #h2{ text="Rusty Klophaus" },                        `Erlang LS: record h2 undefined`
        #h2{ text="Jesse Gumm" },                            `Erlang LS: record h2 undefined`
        #p{}, 	                                                        `Erlang LS: record p undefined`
        #button { id=button, text="Click me!", postback=click }.        `Erlang LS: record button undefined`
    ].

Does it require some extra config to find the sources/dependencies? How do I fix this issue?

1 Like

Hi, I had a similar issue while using Nitrogen 2.4 (2.x branch), and I resolved it by creating an erlang_ls.config file in the root directory with the following content:

deps_dirs:
  - "lib/*"

include_dirs:
  - "site/include"
  - "lib"

I’m not entirely sure if this is the correct or recommended approach, but after adding this configuration, all the warnings related to Nitrogen records disappeared.

Assuming you are using rebar3, I solved this by editing erlang_ls.config like this:

deps_dirs:
  - "_build/default/lib/*"
include_dirs:
  - "_build/default/lib/*/include"
  - "_build/default/lib/"
  - "include"

I hope it works!

I have a tweaked version of erlang_ls that I’ve been using for a while that I believe addresses this issue. Give it a shot and let me know if that fixes it for you:

Here is the commit of my change: Add deps to code paths · erlang-ls/erlang_ls@d8649f5 · GitHub

Yep, this worked.
Thank you both @lgmfred and @ricardobocchi