Neovim - Elixir Setup Configuration from Scratch Guide

:astonished: Imagine all the things you could have done with your life instead of typing end!

1 Like

That worked for do end but not fn -> end! :smiley:

I know it sounds so silly, but what happens is that if I type end myself, it triggers autocomplete, which then captures my up arrow keypress. So you have to press escape or something to get out of autocomplete, which also takes you out of insert mode. So then you have to press i again, then up, then tab. Itā€™s many keypresses for something that happens all the time.

Also, if you just leave a block open without the corresponding end, then everything gets colored bright red cuz itā€™s a syntax error. Not only that, but indent just completely stops working.

See screenshot for an example. My cursor (which you canā€™t see because of other neovim related reasons) is on column 1, i.e. autoindent just completely fails.

Ah, dang! You could try regular olā€™ endwise, though I remember when I was trying out NeoVim it didnā€™t work and I had to use the treesitter one. Sorry, Iā€™m going off recent knowledgeā€”I actually gave up on NeoVim and back with regular olā€™ classic Vim (aka, Vim). I just keep up with this thread because itā€™s the closest I get to Vim content 'round here.

Gah, that sounds super frustrating. Sorry I canā€™t be of more help.

If you have a snippet plugin installed, youā€™ll get snippet type options from the autocomplete list. And if I remembered correctly, the elixir-ls provides some builtin snippets for do block and anonymous function.
So you just need to type do or fn and then select the snippet from autocomplete options. It will expand to something like do | end or fn | -> end.
If you want an experience more like auto pairs, you can try nvim-autopairs and roll your own rules.

1 Like

:no_mouth:The neovim ecosystem is moving fast, and this post is kind of outdated already. Iā€™ll update the post later when I get more free time.

1 Like

This is a more tricky problem. LSP client in Neovim needs a project root directory to work. When you open a .ex file from an elixir project, the current working directory will be set to the elixir project root.
Thereā€™s some related discussions and possible solutions here: https://www.reddit.com/r/neovim/comments/16kkeq1/neotree_keeps_switching_working_directory_in_a/ .

1 Like

I only just started using snippets recently after 20+ years ofā€¦ not using snippets. Itā€™s the same feeling I had after not wearing sunglasses until I was 25. What the $#%@ was I thinking this whole time???

1 Like

exactly! this is my personal beef with at least some of pre-packaged Neovim distributions - i feel like maintenance cost on my side and amount of paper cuts is just not worth it.

skipping aside the fact i am losing opportunity to learn bit of Lua and finally have an excuse to poke around Neovimā€™s plugin API (sure, itā€™s a subjective matter, i get it).

:raised_hand: guilty! :slight_smile:

1 Like

Hey there

I am having troubles trying to make the elixir ls understand the root of my project.

I have a single repo with multiple elixir projects. When I enter one of the projects I expect the elixirls to understand that the root should be that subfolder, but it keeps going up to the root of the mono repo.

Any suggestions?

Is it an umbrella? Or is it a directory containing several independent projects in sub-directories?