django-template-textobjects icon indicating copy to clipboard operation
django-template-textobjects copied to clipboard

Make matchit setup optional / append to b:match_words

Open blueyed opened this issue 10 years ago • 8 comments

Currently matchit gets setup unconditionally: https://github.com/mjbrownie/django-template-textobjects/blob/master/after/ftplugin/htmldjango/template_textobjects.vim#L48-L69

It would be nice if that was moved to a syntax file and made optional. Especially b:match_words should probably only get appended to, but not overridden.

blueyed avatar May 22 '14 15:05 blueyed

It shouldn't really be there at all. Earlier versions of the plugin relied on matchit but it was replaced with searchpair calls.

I made the original b:match_words patch for the django.vim script but wasn't happy with his use of a non pathogen friendly packaging layout. http://www.vim.org/scripts/script.php?script_id=1487.

If you can point me to where the repository where htmldjango b:match_words are officially being well maintained, I'll happily remove that block.

mjbrownie avatar May 26 '14 04:05 mjbrownie

If you can point me to where the repository where htmldjango b:match_words are officially being well maintained, I'll happily remove that block.

I could only find the eclim plugin, which has support for Django, but it neither leightweight nor official for Vim: https://github.com/ervandew/eclim/blob/master/org.eclim.pydev/vim/eclim/ftplugin/htmldjango.vim

It seems like the generated match_words from there are more sophisticated with regard to wildcard matching. The matchit help mentions that .\{-} should be used instead of .* (which this plugin does).

blueyed avatar May 26 '14 09:05 blueyed

Cheers.

To be honest though, it suffers from the same problem my version does in that you explicitly need to define keywords when all you really want to do is define something like

{% (firstword) blah blah %}...{% end(firstword) %} .

That way it would work for all of the third party surrounding tags and any future tags written.

See the xml/html version is on this line. (from the html syntax file)

'<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>,'

https://github.com/mjbrownie/django-template-textobjects/blob/master/after/ftplugin/htmldjango/template_textobjects.vim#L56

In vim :he @<=

I never had the time to figure out.

Any how I'm happy to remove the block. I might make it initially optional by surrounding it in a DTTMatchit autocommand.

mjbrownie avatar May 27 '14 00:05 mjbrownie

I've improved the current set/state in #7 while I was at it.. :)

blueyed avatar Sep 05 '14 16:09 blueyed

FWIW, b:match_words might get added to Vim's runtime directly, where apparently also the django.vim vimscript gets used. It should get improved then to be similar to haml.vim.

But I see that for most users it takes a while to get an update of Vim's runtime (e.g. with distros).

blueyed avatar Sep 12 '14 19:09 blueyed

Just for reference: '{% *\%(end\)\@!\(\w\+\)\>.\{-}%}:{% *end\1\>.\{-}%}' appears to work - i.e. the start tag should not start with "end".

blueyed avatar Mar 07 '19 01:03 blueyed

hey thanks that's cool to know.. only took 5 years to figure it out. Should b:matchit_words be defined here still? I haven't kept track of the official filetype code.

On Thu, Mar 7, 2019 at 12:02 PM Daniel Hahler [email protected] wrote:

Just for reference: '{%-? *%(end)@!(\w+)>.{-}%}:{%-? *end\1>.{-}%}' appears to work - i.e. the start tag should not start with "end".

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mjbrownie/django-template-textobjects/issues/4#issuecomment-470340183, or mute the thread https://github.com/notifications/unsubscribe-auth/AADkTvaTvA3uZoy_4quFlxoPPm9nBbZaks5vUGUYgaJpZM4B9Yox .

mjbrownie avatar Mar 11 '19 01:03 mjbrownie

Not sure - just came across it when working on a jinja plugin, and came across this issue again. I think ftplugin is fine.

blueyed avatar Mar 11 '19 03:03 blueyed