elixir-editors / vim-elixir

Vim configuration files for Elixir
http://elixir-lang.org/
Other
1.31k stars 154 forks source link

Autoindent not working correctly for <.dot> style HTML tags/components in eelixir #559

Open TheArrowsmith opened 2 years ago

TheArrowsmith commented 2 years ago

The title more or less says it all. When I'm editing a file where filetype=eelixir, e.g. .eex or .heex file, then autoindentation works correctly if, say, I add an if statement:

# I type this line:
<%= if condition do %>

# Still in insert mode, I hit Enter, and two spaces are added, with the cursor ending up at the X:
<%= if condition do %>
  X

But if I try to add a "dot" tag - not sure of the correct terminology, I'm talking about tags that call an Elixir function and start with <. - then the autoindent doesn't work:

# After typing the first line and hitting Return, no new indentation is added and the cursor is at X:
<.form {some_attributes}>
X

Is there a way to fix this?

ghost commented 11 months ago

@TheArrowsmith , couldn't find any tag that resembles such syntax in the EEx documentation: EEx/tags.

Is this from a previous version?

TheArrowsmith commented 11 months ago

No, it's from the current version of HEEx, and was added in LiveView 0.18 I think.

https://hexdocs.pm/phoenix/components.html

https://hexdocs.pm/phoenix_live_view/assigns-eex.html

ghost commented 11 months ago

@TheArrowsmith , thanks for your response.

I'm interested in contributing to the project but I'm still familiarizing myself with the codebase and Elixir itself 😅.

As for now, I can only offer you a hacky work-around, it would involve adding the following to your runtime path in an after directory (i.e. after/ftplugin/heex.vim):

syn region eelixirExpression matchgroup=eelixirDelimiter start="<."  end="/>" contains=@elixirTop  containedin=ALLBUT,@eelixirRegions keepend

Hope it helps, although there's a high possibilty that it may not work as expected, so please let me know 🙂 .

jbodah commented 11 months ago

@samanera Please let me know if I can help you get acquainted at all. I’m on the official Elixir Discord if you’d like to get in touch. I’ve been fairly absent from this project as I haven’t used Elixir in many years, but I have a pretty good understanding of most of the project and would like to support any motivated contributors