This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/erlang
2020-10-30 21:51:07 +01:00
..
img
config.el [erlang] add LSP support through erlang_ls 2020-10-26 23:29:49 +01:00
funcs.el [erlang] add LSP support through erlang_ls 2020-10-26 23:29:49 +01:00
layers.el [erlang] add LSP support through erlang_ls 2020-10-26 23:29:49 +01:00
packages.el [erlang] add LSP support through erlang_ls 2020-10-26 23:29:49 +01:00
README.org documentation formatting: Mon Oct 26 23:33:02 UTC 2020 2020-10-30 21:51:07 +01:00

Erlang layer

/TakeV/spacemacs/media/commit/32ead25c357a69e9e3605b76c765d4e127699e7f/layers/+lang/erlang/img/erlang.png

Description

This layer adds support for Erlang.

Enabling Lsp-mode brings IDE like features following Language Server Protocol, through erlang_ls

Features:

  • Syntax highlighting
  • Syntax checking via Flycheck integration
  • Auto-completion via Company integration
  • Code Completion
  • Go To Definition
  • Go To Implementation for OTP Behaviours
  • Signature Suggestions
  • Compiler Diagnostics
  • Dialyzer Diagnostics
  • Elvis Diagnostics
  • Edoc
  • Navigation for Included Files
  • Find/Peek References
  • Outline
  • Workspace Symbols
  • Code Folding

Install

Layer

To use this configuration layer, add it to your ~/.spacemacs. You will need to add erlang to the existing dotspacemacs-configuration-layers list in this file.

Choosing a backend

company-erlang uses gtags to provide a very basic working environment, it is the default backend.

You can improve the IDE-like experience by choosing the lsp backend, to do so, first add the lsp layer to dotspacemacs-configuration-layers, then, set the layer variable erlang-backend:

  (erlang :variables erlang-backend 'lsp)

Alternatively the lsp backend will be automatically chosen if the layer lsp is used and you did not specify any value for erlang-backend.

Configuration

erlang-mode

To find the manual page for the function under the cursor you can either set erlang-man-root-dir to erlang man root directory path in the layer definition:

  (erlang :variables erlang-man-root-dir "*path_to_folder*/otp_22/lib/erlang/man")

or let erlang-mode download it by executing M-x erlang-man-download-ask.

LSP

The lsp backend uses erlang_ls as its language server implementation.

Clone the project to your system and compile it:

  make

Note: Ensure you have erlang_ls in your PATH

You can install it:

  make install

Key bindings

erlang-mode

Key binding Description
C-c C-a Align arrows ("->")
C-c C-c Comment region
C-c C-d Display function manual at point
C-c C-j Generate a new clause
C-c C-q Indent function
C-c C-u Uncomment region
C-c C-y Insert, at the point, the argument list of the previous clause.
C-c C-z Display the erlang-shell or start a new
C-c M-a Move backward to previous start of clause.
C-c M-e Move to the end of the current clause.
C-c M-h Put mark at end of clause, point at beginning.

LSP

You will find an overview of all the key bindings on the lsp layer description.