othree / html5.vim

HTML5 omnicomplete and syntax
http://www.vim.org/scripts/script.php?script_id=3236
934 stars 76 forks source link

Ignore self closing tags #100

Closed ycmjason closed 1 month ago

ycmjason commented 5 years ago

Self-closing tags like these: <my-awesome-component /> will be treated as open tags and indent the lines following it.

I have added to the regex to ignore these tags.

ycmjason commented 5 years ago

I think my change will make <input> to be considered as opening tag too and indent the lines after. Not sure if it is my change that introduces the problem tho.

othree commented 5 years ago

@ycmjason Very possible, that's why I still don't fix this issue. There are several tags might be affected by this. Self-closing tag and <p> without closing tag ...etc

ycmjason commented 5 years ago

@othree that's true.

Any ideas how we can solve this?

othree commented 5 years ago

I will try to fix this again. In my memory, last time I want to fix this is trying to use the indent tag list. But I forgot the detail now.

One quick workaround is by setting the variable html_indent_inctags. ex:

let g:html_indent_inctags = 'custom,ele'

Buffer variable also works too.

ycmjason commented 5 years ago

I see. But the custom tags varies in each project and there are probably a lot of different components in a single project. The tag will end up growing indefinitely. I am not a big fan of this solution.

Instead can we assume all tags will indent lines except for void elements? Void elements basically are just <area>, <base>, <br>, <col>, <command>, <embed>, <hr>, <img>, <input>, <keygen>, <link>, <meta>, <param>, <source>, <track>, <wbr>?

ycmjason commented 5 years ago

I don't fully understand how the indent/html.vim works, but it looks like it first check if it is a custom element? Perhaps we should first check if it is void element?