windwp / nvim-ts-autotag

Use treesitter to auto close and auto rename html tag
MIT License
1.62k stars 86 forks source link

feat: Add close tag after inputting / #116

Closed gungun974 closed 1 year ago

gungun974 commented 1 year ago

Introduction.

Hello, I've been using Neovim exclusively for a while now.

One of the features I still miss in my Neovim is the ability, as in WebStorm, to automatically close an HTML tag when an opening tag is already available. (#94)

So, since I had some free time, I thought why not try to implement this feature myself and then share my modifications with you.

Operation.

When you write code like this:

<div>
    hoi
<

And when you add a / at the after normally the start of a close tag, with this Pull Request the tag will automatically close with the correct name:

<div>
    hoi
</div>

Note.

Just a last small detail, since I'm not the most comfortable with treesitter and the source code of this repository, I tried to modify as little as possible to avoid stepping on the work that has already been done.

That's why, apart from the signature of check_close_tag which has slightly changed, all the code I added is independent of the base code.

Also, for the consistency of this feature, I have added additional tests to verify that my modification also works in TSX, Vue, PHP, etc...

Finally, I am open to any changes or suggestions.

windwp commented 1 year ago

Ok thank