ElixirLS - the Elixir Language Server

Hey, @Gazler, is this still working for you?

It seems like lsp-mode has been update since your post. I’ve been struggling trying to make this work.

Thanks!

I haven’t used this since my original post, sorry!

Maybe you’ll need to do something like this? https://github.com/emacs-lsp/lsp-go/commit/d270b7c0bd893fdc73a97763e07706830756cad2#diff-b16254bd1e678f6759f4b90b20c8ccda

1 Like

I already did that, but it didn’t work for me.

Thanks anyway :smiley:

@JakeBecker I just been using this in vs code for past two days, and I must say, it’s jaw dropping. Really the autoformat at save, documentation pop up on hoover, and compilation with error showing on save, it all just works really great. I must say I love it. So far Elixir plug-in for jetbrains IDE’s was my editor of choice, but I now switched to vs code with your plugin :slight_smile:

PS. I tried it just when it was announced it, and there was some trouble with elixir installed with asdf, and now there is none, it just works out of the box, just in case anyone had problems before, I urge you to try it again :smiley:

3 Likes

Does anyone know if anyone is working on support for ElixirLS with Emacs/Spacemacs?

2 Likes

IIRC @Gazler made it work once with an older version of one of the packages, so it should technically be possible. I have tried but with no success.

I just released an update with a few new features contributed by @mattbaker:

  • Find references: Hit Opt + F7 or right-click on a module or function and select “Find references” to find all the places it’s called in your project.
  • Find symbol in file: Hit Cmd + F12 to quickly go to a module or function in the current file.

Big thanks to @mattbaker for the new features!

I’ve also started publishing precompiled release packages which should hopefully make it easier to put together plugins for other editors (cc @edmz @Gazler ). Enjoy!

3 Likes

I…have no clue what Opt and Cmd are… o.O

I tried various combinations of Ctrl/Alt/Menu/Meta to no avail and none of those worked? I’m using it on a function that is defined further down in the same (large) file.

Wrong keyboard maybe :slight_smile:

Ah, yeah I just have Ctrl/Alt/Meta(Super)/Menu/Shift for modifier keys, not a mac, I don’t think I’ve touched a mac in, hmm, since the late 1980’s… >.>

So what would the keys be, I’ve tried them all and it does nothing combined with those F-keys? Or is it really only mac-only commands?

EDIT: Also I’m showing no command of anything like ‘Find References’ in the command palette? Is that what the command title is called?

Maybe it is possible to try ALT for Opt, and Windows Button (If You have it) for Cmd.

But I have no Windows keyboard to test it.

Not windows either, standard XF86 standard, I run linux. :wink:

But still, what is the command actually called? Even if the keys weren’t working I should still be able to call it by name, but no such thing…

image

EDIT: And I do confirm the plugin was updated an hour ago and it received and applied the update.

Ah, those were the Mac hotkeys, I don’t know what they are in other systems but you can find “Find references” in the context menu if you right click in your code on function or module name, and you can find “Go to symbol in file” under the “Go” menu:
54%20PM

35%20PM

1 Like

Re: symbols — I usually hit command-t (or OS equivalent) followed by typing an “@” sign. That will start you fuzzy-searching symbols in the file.

You have a Super key, that’s what most users mean when they say Windows key. Mine is labelled windows as well but works perfectly as super as well.

Besides from looking into the menu there is always C-P (as far as I remember) where you can enter the functions title and look up the shortcut. Similar to Emacs M-x.

I said ‘super’. ^.^

This is in Atom, not emacs or so (in emacs I’m still using whatever spacemacs uses, which isn’t the LS yet I think). And no, Ctrl+p does nothing, maybe you meant Ctrl+Shift+p to open the command palette, which is where I’m searching for the function titles and not finding them.

Is there a spacemacs layer that uses the LS for elixir yet?

I’ve seen option mapped as Hyper on occasion, you might try that modifer. I don’t know if that’s a “standard” modifier or not, I suspect it was just another label for Super.

Somebody pointed this out in another thread the other day, but I haven’t had a chance to try to use it on master yet (develop has been rather unstable for me in the recent past):

Eh I tried them all and none seemed to work in Atom. I didn’t see any keybindings for it configured via the extension either (which if a keybind is listed in the changelog for the ‘server’ then I’d expect it to work in all extensions… ^.^; ).

Likewise, I just run stable now. ^.^;

I’ve just published an update (v0.2.16) with two significant changes:

Smart closing of code blocks. Instead of using a snippet for do, ElixirLS will now close do or fn -> blocks automatically when you hit enter. It’s smart about it, and will never add an end if it would make your code fail to parse. If your code was already failing to parse, it tries to guess whether “end” is neccessary based on indentation.

I made this change largely so I could make another change: Now, by default, you must hit tab instead of enter to accept an autocomplete suggestion.

It make take some getting used to, but I highly recommend leaving editor.acceptSuggestionOnEnter as "off" and using using tab instead of enter for autocomplete. In Elixir, it’s very common to end a line with an identifier (such as :error, for example), and ElixirLS will sometimes try to autocomplete that (into :error_handler or :error_logger, for example). If you’re typing quickly, you may hit enter before even noticing the suggestion and insert it by mistake. ElixirLS tries to prevent this in some cases (such as ending a line with else or end), but the better solution is to get used to using tab to accept suggestions.

More information is in the readme. If you really want, you can change it back in your settings. I won’t mind.

If you updated yesterday, I highly recommend updating again to this version because I had accidentally made autocomplete more annoying. Happy coding!

9 Likes

@JakeBecker I have a really vague question and I’m not even sure you’re the right person to address it to, but I hope you can at least point me in the right direction. I’ve spent this weekend trying to get ElixirLS working in neovim. I know you’re not a vim person, and the author of the LanguageClient_neovim plugin isn’t an Elixir person, and I’m brand new to the whole LanguageServer landscape, so please bear with me.

I have the basics working and I truly love the incremental dialyxir support, which was the the feature that pushed me over the edge of trying my hand at this integration. My problem is with code completion suggestions. Here’s an example of one I can get:

  Enum.map(<`1:enumerable`>, <`2:fun`>)

That special syntax around the parameters looks like some snippet support, and I think it comes from ElixirLS. Firstly, can you confirm that?

Secondly, in vim that’s not a common snippet format. Can you tell me more about it? Is it a standard of Language Servers in general, or perhaps native to Atom? I’d like to try to see if there is a vim plugin somewhere that can support it. But if not, is there some way to turn it off and just get function names in completions?

I have seen some references to a settings.json for ElixirLS, but I’ve not been able to find more about what it can contain. Is it what I think it is and lets me control preferences for how ElixirLS behaves? Can you point me at more information on what the allowed contents are?

Thanks so much for your time and effort on this project!

2 Likes