2015-12-02 14:23:39 +00:00
#+TITLE : Erlang layer
2015-06-10 16:44:30 +00:00
2019-05-07 08:53:56 +00:00
#+TAGS : general|layer|multi-paradigm|programming
2019-05-05 17:26:40 +00:00
2015-06-10 16:44:30 +00:00
[[file:img/erlang.png ]]
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description ][Description ]]
2018-01-11 20:25:14 +00:00
- [[#features ][Features: ]]
2017-05-22 14:16:12 +00:00
- [[#install ][Install ]]
2020-10-07 21:51:33 +00:00
- [[#layer ][Layer ]]
- [[#choosing-a-backend ][Choosing a backend ]]
- [[#configuration ][Configuration ]]
- [[#erlang-mode ][erlang-mode ]]
- [[#lsp ][LSP ]]
- [[#key-bindings ][Key bindings ]]
- [[#erlang-mode-1 ][erlang-mode ]]
- [[#lsp-1 ][LSP ]]
2015-06-10 16:44:30 +00:00
* Description
2020-10-07 21:51:33 +00:00
This layer adds support for [[https://erlang.org/ ][Erlang ]].
Enabling [[https://github.com/emacs-lsp/lsp-mode ][Lsp-mode ]] brings IDE like
features following =Language Server Protocol= , through [[https://erlang-ls.github.io/ ][erlang_ls ]]
2018-01-11 20:25:14 +00:00
** Features:
- Syntax highlighting
- Syntax checking via =Flycheck= integration
- Auto-completion via =Company= integration
2020-10-07 21:51:33 +00:00
- Code Completion
- Go To Definition
- Go To Implementation for OTP Behaviours
- Signature Suggestions
- Compiler Diagnostics
- [[https://erlang.org/doc/man/dialyzer.html ][Dialyzer ]] Diagnostics
- [[https://github.com/inaka/elvis ][Elvis ]] Diagnostics
- [[http://erlang.org/doc/apps/edoc/chapter.html ][Edoc ]]
- Navigation for Included Files
- Find/Peek References
- Outline
- Workspace Symbols
- Code Folding
2015-06-10 16:44:30 +00:00
* Install
2020-10-07 21:51:33 +00:00
** Layer
2016-01-06 05:21:55 +00:00
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.
2020-10-07 21:51:33 +00:00
** 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= :
#+begin_src elisp
(erlang :variables erlang-backend 'lsp)
#+end_src
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:
#+BEGIN_SRC elisp
(erlang :variables erlang-man-root-dir "*path_to_folder* /otp_22/lib/erlang/man")
#+END_SRC
or let =erlang-mode= download it by executing ~M-x erlang-man-download-ask~ .
** LSP
The =lsp= backend uses [[https://erlang-ls.github.io/ ][erlang_ls ]] as its language server implementation.
Clone the project to your system and compile it:
#+BEGIN_SRC bash
make
#+END_SRC
*Note:* Ensure you have =erlang_ls= in your =PATH= ...
You can install it:
#+BEGIN_SRC bash
make install
#+END_SRC
* 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 [[https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Btools/lsp#key-bindings ][lsp layer description ]].