Using an Erlang LSP server with Sublime Text 3

Roberto Aloi prof3ta@REDACTED
Sat Jan 18 18:51:54 CET 2020


Hi Torben!

I'm using this language server for Erlang: github.com/erlang-ls/erlang_ls


Nice that you are taking Erlang LS for a spin. We haven't tried the server
with Sublime text yet, so I gave Sublime I try just now (I think I have all
possible editors on my laptop now). Disclaimer: I am not a Sublime user, so
take my response with a grain of salt.

Looking in the console for ST3 I find a complaint about Rebar (the ancient
> one, so I'm ignoring that for now) and a problem wrt reading a config file:
> Unable to open /Users/torben.hoffmann/Library/Application Support/Sublime
> Text 3/Packages/LSP/LSP.sublime-settings
> Which is a bit confusing because that file is at
> Packages/User/LSP.sublime-settings.
>

I wouldn't worry about that. It seems the LSP Package for Sublime uses a
default settings file (the one in [...]/LSP/LSP.sublime-settings)
and one for the user overrides (the one in [...]/User/LSP.sublime-settings).

So, what I did to get the connection to the Erlang LS working:

Preferences -> Package Settings -> LSP -> Settings

Added:

{
    "clients":
    {
        "erlang-ls":
        {
            "command":
            [
                "/path/to/my/erlang_ls", "--transport", "stdio"
            ],
            "enabled": true,
            "languageId": "erlang",
            "scopes":
            [
                "source.erlang"
            ],
            "syntaxes":
            [
                "Packages/Erlang/Erlang.sublime-syntax"
            ]
        }
    }
}

Even if I have `erlang_ls` in my $PATH, I had to use an absolute path. I
guess there's some way to pass the correct $PATH to Sublime, but I haven't
tried that. Some Sublime user may help with that.
That's all it was required to get things working. One thing I noticed is
that, if you open a single .erl file, Sublime will complain about an error
during the error initialization.
Instead, you should open the "project" first (i.e. the directory containing
your Erlang file), then the file. This seems due to a bug in Erlang LS
which always expects a non-null "root path" to be passed during
initialization and in Sublime that happens only if you open a directory
first. Indeed the LSP protocol specifies that the "root path" can be null,
so we will fix that. Fro the time being, please use the workaround.

I will add the above to the Erlang LS README. We should also try to get
Erlang LS included in the Sublime LSP Package to ease installation.
Contributions are always welcome :)

But given the nature of the error messages I don't think that is the issue,
> at least not yet ;-)

Now that you are in Erlang LS land, feel free to use the #language-server
channel in the Erlanger Slack or our github issue tracker at
github.com/erlang-ls/erlang_ls to get in touch!

Best,

Roberto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200118/b2c22ffc/attachment.htm>


More information about the erlang-questions mailing list