<commit_before>#+TITLE: Elixir layer

[[file:img/elixir.png]] with [[file:img/alchemist.png]]

* Table of Contents                                         :TOC_4_gh:noexport:
 - [[#description][Description]]
 - [[#install][Install]]
 - [[#configuration][Configuration]]
   - [[#flycheck][Flycheck]]
     - [[#credo][Credo]]
     - [[#mix-compile][mix compile]]
 - [[#key-bindings][Key bindings]]
   - [[#refcard][Refcard]]
   - [[#help][Help]]
   - [[#mix][Mix]]
   - [[#project][Project]]
   - [[#evaluation-in-place][Evaluation in place]]
   - [[#repl-interactions][REPL interactions]]
   - [[#tests][Tests]]
   - [[#compile][Compile]]
   - [[#execute][Execute]]
   - [[#code-definition-jump][Code Definition Jump]]

* Description
This layer adds support for [[http://elixir-lang.org/][Elixir]] .

[[https://github.com/tonini/alchemist.el][Alchemist]] brings the Elixir tooling to Emacs and comes with a bunch of features
like:

- Powerful IEx integration
- Mix integration
- Compile & Execution of Elixir code
- Inline code evaluation
- Documentation lookup
- Definition lookup
- Smart code completion
- Elixir project management
- Integration with [[http://company-mode.github.io/][company-mode]]
- Flycheck support for mix compile
- Flycheck support for [[https://github.com/rrrene/credo][credo]]
- Flycheck support for test results

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

* Configuration
** Flycheck
*Note:* since flycheck checkers are slow, the checks are enabled only at save
time.

*** Credo
You need to install [[https://github.com/rrrene/credo][credo]] into your project. Fort this, add ={:credo, "~> 0.5",
only: [:dev, :test]}= to dependencies of your project (in file =mix.exs=) and
run:

#+BEGIN_SRC shell
$ mix deps.get
#+END_SRC

For more info about mix [[http://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html][see]].

You can tell flycheck-credo to call credo with the '--strict' argument.

#+BEGIN_SRC elisp
(setq flycheck-elixir-credo-strict t)
#+END_SRC

*** mix compile
*Important:*

Elixir compiler is based on macros and can execute arbitrary during compilation.
Therefore Spacemacs disable flycheck compilation checker by default.

To enable flycheck support for compilation errors *globally* the variable
=elixir-enable-compilation-checking= can be set explicitly to =t= in your
dotfile but it is not recommended to do so because of the limitation described
above.

Instead you should use directory local variables in order to enable the flycheck
checker only for certain projects. Directory local variables are stored in a
file named =.dir-local.el= usually at the root of a project. To easily add a
directory local variable use the key binding ~SPC f v d~ then choose the
=elixir-mode= and the variable name =elixir-enable-compilation-checking= with a
value of t. The result is a new file =.dir-local.el= with the following<commit_msg>elixir: reformat documentation and use blocks for code.<commit_after>#+TITLE: Elixir layer

[[file:img/elixir.png]] with [[file:img/alchemist.png]]

* Table of Contents                                         :TOC_4_gh:noexport:
 - [[#description][Description]]
 - [[#install][Install]]
 - [[#configuration][Configuration]]
   - [[#flycheck][Flycheck]]
     - [[#credo][Credo]]
     - [[#dogma][Dogma]]
     - [[#mix-compile][mix compile]]
 - [[#key-bindings][Key bindings]]
   - [[#refcard][Refcard]]
   - [[#help][Help]]
   - [[#mix][Mix]]
   - [[#project][Project]]
   - [[#evaluation-in-place][Evaluation in place]]
   - [[#repl-interactions][REPL interactions]]
   - [[#tests][Tests]]
   - [[#compile][Compile]]
   - [[#execute][Execute]]
   - [[#code-definition-jump][Code Definition Jump]]

* Description
This layer adds support for [[http://elixir-lang.org/][Elixir]] .

[[https://github.com/tonini/alchemist.el][Alchemist]] brings the Elixir tooling to Emacs and comes with a bunch of features
like:

- Powerful IEx integration
- Mix integration
- Compile & Execution of Elixir code
- Inline code evaluation
- Documentation lookup
- Definition lookup
- Smart code completion
- Elixir project management
- Integration with [[http://company-mode.github.io/][company-mode]]
- Flycheck support for mix compile
- Flycheck support for [[https://github.com/rrrene/credo][credo]]
- Flycheck support for test results

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

* Configuration
** Flycheck
*Note:* since flycheck checkers are slow, the checks are enabled only at save
time.

*** Credo
You need to install [[https://github.com/rrrene/credo][credo]] into your project. For this, add the following snippet
to dependencies of your project (in file =mix.exs=):

#+BEGIN_SRC
{:credo, "~> 0.5", only: [:dev, :test]}
#+END_SRC

Then run in your shell:

#+BEGIN_SRC shell
$ mix deps.get
#+END_SRC

For more info about mix [[http://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html][see]].

You can tell flycheck-credo to call credo with the '--strict' argument.

#+BEGIN_SRC elisp
(setq flycheck-elixir-credo-strict t)
#+END_SRC

*** Dogma
In order to lint your code, you also need to install [[https://github.com/lpil/dogma][dogma]] into your project.
For this, add the following snippet to the dependencies in your =mix.exs= file:

#+BEGIN_SRC
{:dogma, "~> 0.1", only: [:dev]}
#+END_SRC

Then run in your shell:

#+BEGIN_SRC shell
$ mix deps.get
#+END_SRC

*** mix compile
*Important:*

Elixir compiler is based on macros and can execute arbitrary during compilation.
Therefore Spacemacs disable flycheck compilation checker by default.

To enable flycheck support for compilation errors *globally* the variable
=elixir-enable-compilation-checking= can be set explicitly to =t= in your
dotfile but it is not recommended to do so because of the limitation described
above.

Instead you should use directory local variables in order to enable the flycheck
checker only for certain projects. Directory local variables are stored in a
file named =.dir-local.el= usually at the root of a project. To easily add a
directory local variable use the key binding ~SPC f v d~ then choose the
=elixir-mode= and the variable name =elixir-enable-compilation-checking= with a
value of t. The result is a new file =.dir-local.el= with the following
{'fraction_non_alphanumeric': 0.12636769918323315, 'fraction_numerical': 0.0012328556017876407, 'mean_word_length': 4.167197452229299, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6487138', 'n_tokens_mistral': 2046, 'n_tokens_neox': 1983, 'n_words': 706}