Tuesday, July 31, 2012

Re: vim: who/where/when set my ft?

On 1/08/12 10:07 AM, Ben Schmidt wrote:
>>>> filetype=asciidoc
>>>> Last set from /etc/vim/ftdetect/asciidoc_filetype.vim
>>>>
>>>> what is that /etc/vim/ folder doing here?
>>>>
>>>> runtimepath=~/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim73,/usr/share/vim/vimfiles/after,~/.vim/after
>>>>
>
>> :scriptnames
>> 1: /usr/share/vim/vimrc
>> 2: /usr/share/vim/vim73/syntax/syntax.vim
>> 3: /usr/share/vim/vim73/syntax/synload.vim
>> 4: /usr/share/vim/vim73/syntax/syncolor.vim
>> 5: /usr/share/vim/vim73/filetype.vim
>> 6: /home/ping/.vim/ftdetect/csv.vim
>> 7: /home/ping/.vim/ftdetect/mkd.vim
>> 8: /home/ping/.vim/ftdetect/myft.vim
>> 9: /home/ping/.vim/ftdetect/taskpaper.vim
>> 10: /etc/vim/ftdetect/asciidoc_filetype.vim <-----------
>
>> ***the file right before it:
>> 9: /home/ping/.vim/ftdetect/taskpaper.vim
>
> In this case, we don't want the file just before it, but the one a few
> files back: /usr/share/vim/vim73/filetype.vim has clearly issued
> :runtime! which is sourcing all scripts in the ftdetect subdirectory of
> each directory in runtimepath, as a bunch of unrelated files under
> ftdetect are being sourced.
>
> Indeed the filetype.vim distributed with vim does include the command
> :runtime! ftdetect/*.vim
>
> So, either:
>
> - runtimepath was different when filetype.vim was loaded. You can have a
> good guess about this by giving giving :verbose runtimepath? and
> checking whether it was set by a script before or after filetype.vim
> in the :scriptnames list.
>
> - more likely, one of the directories or subdirectories in your runtime
> path is symlinked (or possibly but probably not hardlinked) to
> something in /etc/vim. It's not /usr/share/vim/vim73, because that is
> appearing in :scriptnames as itself, but there's a good chance that
> /usr/share/vim/vimfiles is symlinked (or hardlinked) to /etc/vim. That
> would fit nicely with some distributions' policies of putting
> user-written/mutable configuration files under /etc but distributed
> static configuration/support files under /usr. (It comes up as the
> real path rather than the path in runtimepath presumably because Vim
> does realpath() on the files so that duplicates are correctly
> identified and script-local scope can work reliably.)

P.S. You can check this by doing ls -ld /usr/share/vim/vimfiles in a
terminal, though you probably know that.

> Hope this helps,
>
> Ben.
>
>
>

--
You received this message from the "vim_use" 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

No comments: