How to be productive in Phoenix without using a Language Server?

Hi all,

I don’t mean this post to come across as negative, I’m genuinely curious. I absolutely love Phoenix and Elixir so far and I’ll be watching the developments of the new LSP team closely.

But how are people productive in Phoenix at the moment without LSP support?

I’m talking primarily about building frontends, coming from React I can normally build out a page using my components in a few seconds, by auto importing

e.g I type <Button and I automatically import my button, then I can trigger autocomplete to see all the options I can pass to this component

In Phoenix, the LSP support for HeEx seems non existant, maybe its just my setup? But neither NextLs, ElixirLS in Neovim or the VSCode extension seem to provide LSP support in Heex files

It works really well in ex files, but not in the templates.

Am I missing something or are people just generally typing a lot more HTML with Phoenix than they would with other frameworks?

Update: so I am getting some kind of LSP diagnostics when i forgot to add a required parameter to a component using the <.modal> syntax

So there is something working, its just not integrating into my autocomplete

1 Like

I use ElixirLS, and every once in a while I rm -rf .elixir_ls and restart the server. It’s annoying, but it works :slight_smile:

1 Like

I surprisingly never reinstalled an LSP when I got a new computer and have been doing just fine without it (I am a Neovim user). Been a good 2 years since. Not saying it is not helpful but I do enjoy something about not having all the things pop up and distract me. (I also use ctags to be able to jump places)

3 Likes

Interesting, do you get auto complete in heex files? If so I may need to try elixir LS again, I believe I am using NextLS at the moment and I definetly don’t get Heex file support

This is elite level programming, I’m impressed

I actually haven’t checked :joy: I don’t write UI code often.

AFAIK there is currently nothing that works with HEEx.

As far as importing goes, I just import Components in my html_helpers and all my components are available everywhere. With any other type of function I always either import, alias, or fully qualify them so I can quickly see what module they are in, not so I can locate them, but because the module name gives important context. When it comes to HEEx, if I see <.button /> I know right away that button is a component. No system I have worked on has had two components with the same name so the module names dont’t give me any useful information. import and alias also serve to list a module’s dependencies but I also don’t find this useful with components. To me it would be akin to putting a comment at the top of every HTML file that lists every tag it uses.

Auto-completelion for attributes I know is quite helpful for many. Personally I’m with @tomkonidas I can’t stand having things flying in my face as I type (I’ve really tried). I keep trying to get my editor to give me completion on demand but then something goes wrong. I know there is a plugin out there that will probably help me, but I’m so used to not working with an LSP that I currently have it disabled. I’ll figure something out eventually. Reliable jump-to-definition is really nice. ctags work ok but not well enough for me. For me if things don’t work 99% of the time then I don’t want to use them at all.

Apologies if this isn’t totally on topic. Your question is both general and specific!

2 Likes

That’s extremely helpful. Thank you!

That’s basically what I was wanting to know

I suppose I will just carry on without for now, and pray the first version of the official LSP comes with heex support

1 Like

I should really emphasis the AS FAR AS I KNOW in case my saying that nothing currently works for HEEx with regard to auto-import/auto-complete had anything to do with your marking my answer as the solution.