DervishD wrote:
    Hi Tony :)))

 * A.J.Mechelynck <[EMAIL PROTECTED]> dixit:
DervishD wrote:
   I would like to have configuration data, syntax rules and indent
functions for a filetype together in just one file because this way is
much more easy to maintain for me (long story). Apart from the obvious
disadvantage that having all together in a file makes impossible to
deactivate only syntax, only plugin and only indent for that given
filetype (it becomes an "all or nothing" thing), is there any problem in
not having the files in three separate directories? In fact, is there
any problem in having ALL that data in the corresponding ftplugin?
The scripts in the indent/ syntax/ and ftplugin/ subdirectories of the directories in 'runtimepath' are not run at the same time, therefore it is logical to keep them separate:

    Yes, that I know, and I have no doubt it's better to have all three
things separate, specially if you use the shipped runtime system. The
"default" vim runtime has to be flexible, powerful and general purpose.
What I want in my system is a small, fixed purpose runtime, with only
those bits I actually use. The reason behind this is the same reason
behind my entire system: I enjoy doing things on my own. The least I do
is to build the software myself (I use no package system), but if I have
the chance, I program the software myself. In fact, until I tried Vim
7.0, I was decided to write my own editor, and I have a preliminar
design: most data structures are already written or fully designed.

    This said, what I'm doing now, just for fun, is to write my own
runtime for vim. So far I've replaced 'filetype.vim', and I'm on the way
of writing my own indent.vim. Syntax will be the last part, because it
is the biggest, too. I have nothing against the default runtime, in fact
is VERY good and powerful, but I can't help rewriting some parts just
for fun. It may not be very intelligent, but having fun is important
IMHO ;)))))

    The problem with this is that, in the past, I've faced some problems
when doing the same (e.g. with Lout) because the things I rewrote were
using undocumented dirty tricks, or assuming things hardcoded in the
source code, etc. So I wanted to make sure that, after working a couple
of weeks writing VimL code, I will be able to use the results and I
won't get stuck.

    Your explanation below is very good, because although I knew most of
the things from the documentation, you've made clear what kind of things
should be put in every one of the three files. That kind of help is
invaluable (as most of the help you give in this list, by the way).

Now what should these files contain?
[...]
If you want to keep everything together, you can set autocommands for the Filetype and Syntax events in your vimrc, but as "what you want to do" becomes more involved, you'll find that your vimrc becomes more and more cluttered and that you need to put things into different files just to keep order. Been there done that.

    I don't want such cluttering, either. My idea is to have the
following:

    - A 'vimrc' that just sources 'modules' (right now my vimrc does
little except sourcing 'options.vim', 'mappings.vim' and a couple more
things).

    - The framework for filetypes, ftplugins, syntax highlighting and
indentation.

    - Filetypes. This is the most important part. My idea is having
something like "c_f.vim" "c_s.vim" and "c_i.vim" for the "c" filetype,
containing ftplugin things, syntax things and indentation things,
instead of having "ftplugin/c.vim", "syntax/c.vim" and "indent/c.vim". I
haven't decided if I will put the "c_?.vim" files under /etc/vim or in
a subdir. For me is much more comfortable to manage all this if the
three files are in the same directory and not in three separate subdirs.

    This last part is what was worrying me. I know that the default
runtime needs those three dirs, but I don't know if getting rid of them
and organizating things differently is going to buy me problems in the
future.

    Your message has been inspiring, and I may consider things
differently. Writing my own runtime is, for me, very fun, so I will be
doing it, but how I do it may be different.

    Thanks a lot for your help, as always :)

    Raúl Núñez de Arenas Coronado


What about leaving the files where they are, and also do (in the shell)

        cd ~/.vim/after/ftplugin
        ln -sv ../../c_f.vim c.vim
        cd ../syntax
        ln -sv ../../c_s.vim c.vim
        cd ../indent
        ln -sv ../../c_i.vim c.vim

Then you can edit the files in ~/.vim, and Vim will find them "as if they were" in their respective after-directories.

...and, why reinvent the wheel when the source is open? If I were you, I would study the existing runtime files but not change them in-place. If you try to re-create everything from the ground up, you're bound to introduce bugs (Errare humanum est). OTOH, if by studying the existing scripts you _find_ bugs, then after making sure of your facts you could send a patch to the maintainer.


Best regards,
Tony.

Reply via email to