m4xshen/autoclose.nvim

Auto-indent HTML tags

Closed this issue · 2 comments

Hello,

This plugin is so good! It does basically everything I want, with a lot less complexity than the other options. Thanks for making it!

The one thing I'm missing is HTML tag auto-indent. Let's say my cursor | is here:

<div>|</div>

Then when I press return, I would want the auto indent to produce this:

<div>
  |
</div>

How feasible do you think this is?

@lukewiebe Thanks for the feedback! A pretty simple approach would be adding this config:

keys = {
  [">"] = { escape = false, close = false, pair = "><" },
}

This triggers auto-indent when your cursor is between two tags like this: >|<.

Ah, that’s very clever! I’ll definitely add it to my config.

I imagine this is a fairly common need with the popularity of HTML. Would you consider adding it to the default settings or noting it in the readme?