How to setup doom emacs elixir yasnippets?

I am trying to have a proper setup for Elixir in doom emacs.
I have code completion with LSP, the next thing I would like to have is the help of yasnippets.
But I have no clue how to set it up, nor can I find any documentation online about it, specifically doom-emacs and elixir-yasnippets.
I do not know how to install it: I have enabled snippets in init.el, and installed elixir-yasnippets with M-x package install.
But when I create a new module, or a new function, I do not know how to invoke the snippets, or do I have to create snippets first, and again I can not find any documentation about it.

Thanks for your help.

1 Like

@eddy147 Generally, you are more likely to find users that can help with Doom Emacs for Elixir in the Doom Discord than Elixir users that also uses Doom Emacs.

To enable snippets in Doom Emacs, you can in your init.el file uncomment the snippets-section.
To add your own yasnippets, there are multiple ways of doing this, but here is one example.
In your config.el, add:

(setq yas-snippet-dirs (append yas-snippet-dirs
                               '("~/.doom.d/snippets"))) ;; replace with your folder for snippets

Sync your configs and you can now create new snippets with M-x yas-new-snippet (keybound to C-c & C-n). Save the snippet with C-c C-c and type: elixir-mode.

Now you will have a new folder with snippets that can be found in the Elixir major mode.
Enabling snippets will give the added benefit of adding all the snippets from Doom-snippets.

For more info I would recommend this page and these two videos:

2 Likes