distortedsignal / erlang_ls

The Erlang Language Server

Home Page:https://erlang-ls.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

erlang_ls

erlang_ls

Build Status Coverage Status

An Erlang server implementing Microsoft's Language Server Protocol 3.15.

Minimum Requirements

  • Erlang OTP 21+
  • rebar3 3.9.1+

Quickstart

Compile the project:

make

Command-line Arguments

These are the command-line arguments that can be provided to the erlang_ls escript:

Usage: Erlang LS [-v] [-t [<transport>]] [-p [<port>]] [-d [<log_dir>]]
                 [-l [<log_level>]] [<port_old>]

  -v, --version    Print the current version of Erlang LS
  -t, --transport  Specifies the transport the server will use for the
                   connection with the client. [default: tcp]
  -p, --port       Used when the transport is tcp. [default: 10000]
  -d, --log-dir    Directory where logs will be written.
                   [default: filename:basedir(user_log, "erlang_ls")]
  -l, --log-level  The log level that should be used. [default: info]

Customization

It is possible to customize the behaviour of the erlang_ls server via a configuration file, named erlang_ls.config. The erlang_ls.config file should be placed in the root directory of a given project to store the configuration for that project.

It is also possible to store a system-wide default configuration in an erlang_ls.config file located in the User Config directory. The exact location of the User Config directory depends on the operating system used and it can be identified by executing the following command on an Erlang shell:

> filename:basedir(user_config, "erlang_ls").

Normally, the location of the User Config directory is:

Operating System User Config Directory
Linux /home/USER/.config/erlang_ls
OS X /Users/USER/Library/Application\ Support/erlang_ls
Windows c:/Users/USER/AppData/Local/erlang_ls

A sample erlang_ls.config file would look like the following:

otp_path: "/path/to/otp/lib/erlang"
deps_dirs:
  - "lib/*"
include_dirs:
  - "include"
  - "_build/default/lib"
macros:
  - name: DEFINED_WITH_VALUE
    value: 42
  - name: DEFINED_WITHOUT_VALUE
code_reload:
  node: node@example

The file format is yaml.

The following customizations are possible:

Parameter Description
otp_path Path to the OTP installation
plt_path Path to the dialyzer PLT file. When none is provided the dialyzer diagnostics will not be available.
deps_dirs List of directories containing dependencies. It supports wildcards.
apps_dirs List of directories containing project applications. It supports wildcards.
include_dirs List of directories provided to the compiler as include dirs. It supports wildcards.
macros List of cusom macros to be passed to the compiler, expressed as a name/value pair. If the value is omitted or is invalid, 'true' is used.
otp_apps_exclude List of OTP applications that will not be indexed (default: megaco, diameter, snmp, wx)
code_reload Whether or not an rpc call should be made to a remote node to compile and reload a module

The code_reload takes the following options:

Parameter Description
node The node to be called for code reloading. Example erlang_ls@hostname

The erlang_ls Database

The erlang_ls language server uses Mnesia to persist information. A new database is created and maintained for each project/OTP pair. Databases are stored in the application cache directory, which varies according to the operating system used.

Generally speaking, the directory should be:

Operating System Database Dir
Linux /home/USER/.cache/erlang_ls
OS X /Users/USER/Library/Caches/erlang_ls
Windows c:/Users/USER/AppData/Local/erlang_ls/Cache

You can also run the following command on an Erlang shell to identify the Database Directory on your system:

> filename:basedir(user_cache, "erlang_ls").

Getting in Touch

If you have any questions about the project, feel free to open a new issue. You can also join the #language-server channel in the Erlanger Slack if you would like to get involved or if you prefer a more informal mean of communication.

All contributions are welcome, be them in the form of a bug report, a question, feedback, or code.

A wiki is also available and I occasionally blog about the project on Medium.

References

https://microsoft.github.io/language-server-protocol/

License

The erlang_ls project is licensed under the Apache License 2.0. Please refer to the LICENSE file for details.

About

The Erlang Language Server

https://erlang-ls.github.io/

License:Apache License 2.0


Languages

Language:Erlang 99.5%Language:Common Lisp 0.4%Language:Makefile 0.0%