On 26/10/09 21:23, Charles Campbell wrote:
>
> Pablo Giménez wrote:
>> Hi all.
>> I am writinga global plugin that, among other things, will override
>> some filetype settings.
>> So basically I have my plugin in the runtime and I want to know what
>> is the more ellegant/best wasy to:
>> - Override some tipe detection. for instance Iwant that files with
>> thesl extension will be threat as RenderMan shading language instead
>> of slang.
>> - Use my own settings for a file type, for example have my own
>> settings for python.
>>
>> I prefer to have a file for fiel type detection and one file per file
>> type settings.
>> I have tested creating my own filetype.vim in my plugin folder but not
>> yet working, however I am afraid to override complitelly the global
>> filetype.vim because Iwant to override it only for some file types,
>> and in case my file type is not detected then fallback to the global
>> filetype.vim.
>> Also if I have my own pytyhon.vim in the ftplugin folder of my plugin,
>> it will override the global one????
>
> Don't modify the global filetype.vim -- next time you upgrade, your
> modification(s) will be overwritten.
>
> Modify/create $HOME/.vim/filetype.vim . An example of a typical entry:
>
> if exists("did_load_myfiletypes")
> finish
> endif
> let did_load_myfiletypes= 1
>
> augroup filetypedetect
>
> au BufNewFile,BufReadPost *.dif,*.diff,ptch setf diff
> augroup END
>
>
> Now, about $HOME/.vim/ftplugin/python.vim -- in the typical loading
> sequence, it will be loaded before the global file(s) (see :echo&rtp
> to get an idea of your loading sequence). So it *won't* override the
> global one. If you want to override global plugins, may I suggest that
> you put it in $HOME/.vim/after/ftplugin/python.vim instead. It will
> then be loaded after global plugins and will have a chance to override.
>
> Regards,
> Chip Campbell
Oh, but it will override the global one, because the global filetype.vim
uses (just as in the above example) the ":setfiletype" command, which
will only set a filetype if it isn't already set.
In an after-plugin, you should use
au BufRead,BufNewFile foobar setlocal filetype=whatever
instead.
Also: ~/.vim (with or without /after) is on Unix-like OSes. On Windows,
use ~/vimfiles instead (again, with or without /after).
Best regards,
Tony.
--
Next Friday will not be your lucky day. As a matter of fact, you don't
have a lucky day this year.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---