On 2021-07-01, [email protected] wrote:
> > See
> >
> > :help :setf
> >
> > and see if the FALLBACK argument does what you want.
> 
> Not quite: the original filetype is set using :setf pascal; I'm trying to
> override this in the same sequence of commands.
> 
> Here is perhaps a clearer picture:
> 
> + vim file.md.pp
> |
> +++ filetype detection autocommands trigger
>   |
>   + $VIMRUNTIME *.pp => :setf pascal (did_filetype() now true)
>   |
>   +++ my plugin *.pp => doautocommand … file.md
>     |
>     + $VIMRUNTIME *.md => :setf markdown
>       but did_filetype() was still true, so this has no effect.
> 
> Perhaps I've misunderstood your comment, though. Changing the distribution's
> setf pascal to setf FALLBACK pascal would work, but that seems like it would
> require more discussion.

You can override or preempt what the distribution does in
$VIMRUNTIME/filetype.vim by creating your own ~/.vim/filetype.vim
file (or ~/vimfiles/filetype.vim on Windows).  That might work
better than trying to reset did_filetype().  You could treat *.md.pp
files specially that way.  Or do your own extended handling of *.pp
files.

This is discussed in the help section starting with

    :help new-filetype

The answer may be as simple as using ":set ft" instead of ":setf" in
your plugin.  You can also do things like put ":runtime
ftplugin/markdown.vim" in your ftplugin to source all the
distribution's ftplugin files for your filetype.  See, for example:

    $VIMRUNTIME/ftplugin/cpp.vim
    $VIMRUNTIME/ftplugin/docbk.vim

I don't have a concrete answer because I don't understand exactly
what you're trying to do.  Also, I'm no expert in Vim's handling of
filetypes.  Generally I've found that Vim has the hooks to do what
you want, but it may take some study and tinkering and rethinking of
your initial solution to get the results you want.

Regards,
Gary

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20210701154426.GD22769%40phoenix.

Raspunde prin e-mail lui