Vim users - Request for feedback on embedded template indentation

Hello fellow Vimmers!

I don’t know how many of you are out there since it’s my impression that this community seems to rally around VSCode (which is totally cool).

I’ve just opened up a PR in vim-elixir which makes some strides in fixing the indentation problem in LiveView and Surface inline templates. I’m looking for folks who would be willing to try it out for the next week or so and report any bugs/requests to me. Code-reviews would be welcome too!

Here’s the PR:

Here is my fork:

Make sure you’re on the autoindent-embedded-views branch if you clone this one.

Thanks!

5 Likes

I just wanted to bump this. This has proven to be quite difficult (no surprises there) but I’ve been using this the past week and seems ok. I’m still wondering if anyone else can try this out and report back to me—it’s very hard to cover the all the edge-cases.

Also, for endwise.vim users, I was able to get a PR merged that fixes the whole inline fn -> end issue. I’m not sure how many people were feeling that pain as there was an issue open for over two years, or something like that, about it.

Ok, thanks!

1 Like

Hey! I was just looking at this PR today. Fantastic work. This is something that’s been hurting me. I’ll be able to have a proper play with it tomorrow and report back. Thanks for doing this.

1 Like

Awesome, thank you! The logic hasn’t gotten quite complex. I can probably simplify it a bit but I’m trying to cover some different known styles I’ve seen. One thing that can’t be supported (and doesn’t appear to be supported in regular html formatting) is self-closing tags without the />. I’m also not bothering with extra weird stuff that I never see that is still valid HTML (like having whitespace between between the opening brace and the tag name (< p>, for example).

I’m trying to support both these styles for eex and Surface:

| represents the cursor after a new line.

<%= live_component @socket,
   Component,
   id: "id",
   foo: "foo" %>
|

<%= live_component @socket,
   Component,
   id: "id",
   foo: "foo"
%>
|

<%= live_component @socket,
   Component,
   id: "id",
   foo: "foo" do %>
  |
<% end %>

<%= live_component @socket,
   Component,
   id: "id",
   foo: "foo" do
%>
  |
<% end %>

<Component
  foo="foo" />
|

<Component
  foo="foo"
/>
|

I’m not sure if anyone does anything else but I’d be interested to know.