Open martanne opened 9 years ago
With the latest commits it should in principle be possible to define text objects (and motions) as Lua functions.
@TieDyedDevil do you want to give it a try, and implement tag blocks in Lua? You might need to extend the provided Lua API if some required functionality is not available.
I had a basic working version of this in C a couple months back and now that I have a computer again I'm going to finish it. Would you rather it be done in Lua instead?
In general C is fine, some would say even preferable. However if the implementation turns out to be tricky and a Lua/LPeg based solution would be much simpler then doing it that way might be beneficial.
The simple case of "dat" currently works with my code. However I realized that the more complicated cases would require you to keep track of the matching tags. For example, doing "dit" where the arrow is in the following:
<html>
<a> <fake> <another> Text </onceagain> </a>
---------------------------^
</html>
should result in
<html>
<a></a>
</html>
This works in Vim. It would be pretty complicated to do in C, so I think I'm going to give Lua a shot instead.
Yes as you noticed it is not completely trivial. That is the reason why I so far did not implement it and why I suggested doing it in Lua instead. Using LPeg might come in handy. Thus I initially tagged @TieDyedDevil because he contributed a few LPeg based lexers for syntax highlighting.
@pentlander did you make any progress?
The vis-pairs plugin supports XML/HTML tags - https://repo.or.cz/vis-pairs.git It can be used both interactively, and as a pure Lua module (it exports its motions and textobjects, and I vaguely remember that there was a way to tell it not to map any keys.)
See
:help tag-blocks
in vim. Add two new functionstext_object_tag{,_outer}
to text-object.c