Re: Question about indent/, syntax/ and ftplugin/
DervishD wrote: Hi Tony :) * A.J.Mechelynck <[EMAIL PROTECTED]> dixit: [...] ...and, why reinvent the wheel when the source is open? First, for fun. Second, because being the source open I can investigate, learn and do a good job. Third, for the same reason I've written my own window manager, my own sysvinit replacement, my own syslogd replacement, my own system for building software, etc. :just because I like it and I can. I have the urge of doing this kind of things ;)) [...] When are you going to write your own kernel? ;-) _That_ would be something. Best regards, Tony.
Re: Question about indent/, syntax/ and ftplugin/
Hi Tony :) * A.J.Mechelynck <[EMAIL PROTECTED]> dixit: > >DervishD wrote: > >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. > > > > 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. Yes, that's an option, but I prefer to build a new scheme instead of using "/after" and symlinks. It's much easier for me if the entire structure is in my head instead of having to take into account the existing runtime *and* my changes in "/after". > ...and, why reinvent the wheel when the source is open? First, for fun. Second, because being the source open I can investigate, learn and do a good job. Third, for the same reason I've written my own window manager, my own sysvinit replacement, my own syslogd replacement, my own system for building software, etc. :just because I like it and I can. I have the urge of doing this kind of things ;)) > 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). Yes, I know, but I don't mind to take the risk. Moreover, by keeping the runtime simple, the chance for errors is minor. In addition to this, the default runtime has bugs or at least weird behaviours. For example, the keyword "mapclear" in vim scripts is not highlighted properly, and "source"d files are highlighted, so if you do "source perl.vim", the "perl" word is highlighted as a keyword. The problem is that I'm not sure if this is a bug or some strange interaction between my options settings and the runtime syntax file, that's very difficult to spot and difficult to investigate. > 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. That's a good reason to keep things as they are, but while I write my own runtime I will test thoroughly the default one and may spot some bug. I think I'll take the risk and of course I'll try my best not to bother the list with my self-induced problems in doing so O:)) Again, thanks :) Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 | http://www.dervishd.net It's my PC and I'll cry if I want to... RAmen!
Re: Question about indent/, syntax/ and ftplugin/
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
Re: Question about indent/, syntax/ and ftplugin/
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 -- Linux Registered User 88736 | http://www.dervishd.net It's my PC and I'll cry if I want to... RAmen!
Re: Question about indent/, syntax/ and ftplugin/
DervishD wrote: Hi all :) 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? I'm just curious... Raúl Núñez de Arenas Coronado 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: ftplugin/.vim is sourced at the FileType autocommand event for . If filetype detection isn't ON, or if filetype plugins aren't enabled (":filetype plugin on" hasn't been issued), it is not sourced at all. syntax/.vim is sourced at the Syntax autocommand event for . If syntax highlighting is not enabled (":syntax on" hasn't been issued), it is not sourced at all. If filetype detection is off (":filetype on" hasn't been issued), then, even if syntax highlighting is enabled, it is sourced only when 'syntax' is set explicitly (e.g. by hand). indent/.vim is sourced at (IIUC) the FileType event for , but only if filetype-related indenting has been enabled (":filetype indent on" has been issued). Now what should these files contain? ftplugin/.vim contains chiefly ":setlocal" and/or ":map " statements specific to files of the given filetype. syntax/.vim contains ":syntax" and possibly ":highlight default" statements to define how to colour the text in files with the given syntax. indent/.vim contains statements to define how to indent the data in the file: usually either setlocal cindent setlocal cinoptions= or setlocal indentexpr= and possibly a function to be called by the indenting expression. 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. Notice the use of ":setlocal" and ":map " to avoid clobbering settings for other files, and ":highlight default" to avoid errors if a colour scheme has been set. Best regards, Tony.
Question about indent/, syntax/ and ftplugin/
Hi all :) 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? I'm just curious... Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 | http://www.dervishd.net It's my PC and I'll cry if I want to... RAmen!