On Wednesday, October 21, 2015 at 11:51:04 PM UTC+2, Gary Johnson wrote:
> On 2015-10-21, glts wrote:
> > On Wednesday, October 21, 2015 at 8:32:32 PM UTC+2, Gary Johnson wrote:
> > > On 2015-10-21, glts wrote:
> > > > On Tuesday, October 20, 2015 at 8:47:27 PM UTC+2, ZyX wrote:
> > > > > 2015-10-20 21:11 GMT+03:00 glts <[email protected]>:
> > > > > > In a plain Vim installation, if I have a personal ftplugin
> > > > > > ~/.vim/ftplugin/text.vim that contains the line
> > > > > >
> > > > > >         setlocal expandtab
> > > > > 
> > > > > This file is missing `b:undo_ftplugin` variable, see :h undo_ftplugin.
> > > > > Examples are in every or nearly every ftplugin file in default
> > > > > distribution.
> > > > 
> > > > That does mean that the information in the user manual at ":h 43.1" is
> > > > incorrect, though -- or at least incomplete. The example in the user
> > > > manual has just a setting and a mapping, and no undo boilerplate.
> > > > 
> > > > In fact, I get the feeling I'm back to square one regarding personal
> > > > filetype settings -- is there at all a robust way to tweak settings for
> > > > some filetype and have them undone properly after another :setfiletype?
> > > > 
> > > > This belongs in vim_use, but documentation could be more accurate. And
> > > > the original request still stands.
> > > 
> > > I assume that you added the setting of b:undo_ftplugin to your
> > > ~/.vim/ftplugin/text.vim and you are still seeing 'expandtab' set in
> > > help files.
> > > 
> > > The problem is that b:undo_ftplugin is also being set in
> > > $VIMRUNTIME/ftplugin/text.vim and since that file is sourced after
> > > your ~/.vim/ftplugin/text.vim, its setting is overriding yours.
> > > 
> > > The solution is to put your text.vim file into ~/.vim/after/ftplugin
> > > so that it is sourced after $VIMRUNTIME/ftplugin/text.vim and than
> > > add the following to your text.vim:
> > > 
> > >     if exists("b:undo_ftplugin")
> > >         let b:undo_ftplugin .= " | setlocal expandtab<"
> > >     else
> > >         let b:undo_ftplugin = "setlocal expandtab<"
> > >     endif
> > > 
> > > Yes, the documentation should be updated.
> > > 
> > > Regards,
> > > Gary
> > 
> > Yes. I'm re-reading the documentation and it does seem to imply that
> > personal customisations go in ~/.vim/ftplugin, and that "after" plugins
> > are only used in rare circumstances. See ":h after-directory", which
> > says that an "after" directory is 'rarely needed'.
> 
> That seems to me to be an odd statement.  I find myself using the
> after directory far more than ~/.vim/ftplugin.
> 
> > Thanks to ZyX's explanation, I now understand that ftplugins in
> > ~/.vim/ftplugin aren't really meant for personal settings, as in, you
> > can't set any settings there and expect proper tear-down via
> > b:undo_ftplugin to work. In practice, it's really the "after" plugins
> > where you set stuff like 'expandtab'. Please correct me if I'm wrong.
> > 
> > What's unfortunate about this is that you might still need to set config
> > variables for some of the distributed ftplugins (say, g:sh_noisk). So,
> > ultimately I'll need 1) an ftplugin in ~/.vim/ftplugin to set the config
> > variable, and 2) an "after" plugin -- with substantial boilerplate -- to
> > set the tab setting. It's a pity that a more convenient approach doesn't
> > exist.
> 
> Generally speaking--which may be colored by my own experience and
> preferences:
> 
> -  Plugin configuration (such as setting g:sh_noisk) is done in
>    ~/.vimrc.
> 
> -  Complete filetype plugins that may replace existing plugins in
>    $VIMRUNTIME go into ~/.vim/ftplugin/<filetype>.vim.
> 
> -  Your own filetype-dependent settings (tweaks to the default
>    settings) go into ~/.vim/after/ftplugin/<filetype>.vim.
> 
> I don't know what to say about the convenience.  I think it's nice
> that Vim offers so much flexibility in its configuration.  Also,
> when a feature such as filetype plugins is introduced, not all the
> use cases are known or understood.  Boilerplate code is a
> consequence of both of those.

Thanks, Gary, this is some good advice.


-- 
David

-- 
-- 
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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui