Snippets are here
Snippets are a convenient way to insert portions of code without having to write them from scratch or to copy them from an external source every single time.
To start using snippets, ensure you have the latest version of Erlang LS. Then, simply start typing snippet. A dropdown with all available snippets will appear, so you can select one.
A few built-in snippets are available, ranging from a try catch
construct to a receive after
statement, from a record
attribute to
edoc
blocks.
Snippets contain placeholders, which can be used for easier
navigation via the TAB
key. They also have the concept of a
variable, which gets expanded automatically when the snippet is
selected. The syntax for snippets is described in detail
here.
Contributing snippets is trivial and does not require coding. Built-in snippets are stored in the Erlang LS priv directory.
It is also possible to add custom snippets by dropping them into:
~/.config/erlang_ls/snippets
This mechanism allows your organization to customize snippets, so they match specific coding styles and conventions. A custom snippet which has the same name as built-in one will take precedence, so the former will override the latter in the snippets dropdown.
Enjoy!