tmsvg / pear-tree

A Vim auto-pair plugin that supports multi-character pairs, intelligent matching, and more
MIT License
392 stars 12 forks source link

Wildcard modifier for HTML standalone tags #56

Open emerdenny opened 3 years ago

emerdenny commented 3 years ago

The wildcard behavior for HTML autocomplete is a great feature. I'm running into the issue however that for standalone tags the autocomplete will run unnecessarily. Also, the wildcard is smart enough already to avoid the attributes in the tag, which is perfect, and makes me think there might already be a way to do this.

Example:

<input> --completes to--> <input></input> (great) <input type='text'> --completes to--> <input type='text'></input> (great) <input type='text' /> --completes to--> <input type='text' /></input> (unnecessary) <input type='text' /> --completion cancelled--> <input type='text' /> (desired behavior)

Any suggestions on a way to detect the trailing / and cancel autocompletion?

emerdenny commented 3 years ago

I found this html.vim and loaded it into /.vim/after/ftplugin/html.vim and it hasn't fixed the issue yet (i.e. the autocomplete in .html files doesn't perform desired behavior above)

Another problem is that the HTML tags are often in .js or .jsx files, so the current filetype detection won't catch this issue.

tmsvg commented 1 week ago

Hm, not able to reproduce this. Can you show the output of echo b:pear_tree_pairs while editing an HTML file?

In the default ftplugin, input tags will not auto-close by default, and for other tags I see that adding / cancels auto-closing

<test> becomes <test></test>
<test type='text'> becomes <test type='text'></test>
<test type='text' /> becomes <test type='text' />