Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore self closing tags #100

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ycmjason
Copy link

@ycmjason ycmjason commented Jan 5, 2019

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
Copy link
Author

ycmjason commented Jan 6, 2019

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
Copy link
Owner

othree commented Jan 7, 2019

@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
Copy link
Author

ycmjason commented Jan 7, 2019

@othree that's true.

Any ideas how we can solve this?

@othree
Copy link
Owner

othree commented Jan 8, 2019

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
Copy link
Author

ycmjason commented Jan 8, 2019

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
Copy link
Author

ycmjason commented Jan 8, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants