On Sun, 26 Feb 2023, Bram Moolenaar wrote:
> One way would be to not change 'filetype' directly but set a timer with
> a very short timeout to do it later. This can already be done now, you
> can try it out. Obvious disadvantage is that all the
> indent/syntax/ftplugin files will be sourced twice.
Yeah, this works:
autocmd FileType foo if ... | call timer_start(0, {_ -> execute('set filetype=foo.bar', '')}) | endif
...assuming one can live with the double inclusion, which had tripped me
up the first time I'd tried this. Also attempted were various hacks
in {,after/}ftplugin/foo/, with mixed results.
(Aside: a time of 0 isn't explicitly documented, but seems to work as
expected, i.e. meaning something like "next tick"...)
> A specific way to handle this would be to add a FileTypePre event, which
> would be triggered first and allow for changing 'filetype'. Hmm,
> perhaps we would also need this for the Syntax event?
> This would be a very specific solution, do we really need it?
That'd be cleaner... Whether it's really needed, I'm not sure. I'm
pretty far down the rabbit hole of trying to mix syntaxes in particular --
see other thread on extend causing trouble -- but not far enough to have a
solid grasp on whether there's a better way, or what that would be.
I've found a lot of existing workarounds -- the @htmlPreproc cluster, the
near-copy of HTML in PHP, the dynamic inclusions in Markdown/RST/others --
and having hacked up another, none seem all that satisfying.
-Rob
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/efc5d122-bf33-762f-369b-f3b4e55d312f%40loonybin.net.
Sunday, February 26, 2023
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment