On 2011-06-06, ANDY KENNEDY wrote:
> All,
>
> Buildroot uses Config.in as the Kconfig files. Setting the line:
>
> au BufNewFile,BufRead Kconfig,Kconfig.debug setf kconfig
>
> to:
>
> au BufNewFile,BufRead Kconfig,Kconfig.debug,Config.in setf kconfig
>
> Works for these Kconfig files in Buildroot.
>
> HOWEVER, for some strange reason if there is a comment at the top of
> the file, the file is no longer recognized as a Kconfig file, but as
> a <something> source file. I knew what it was last week, but cannot
> recall at the moment. I want to say it was Python or something. I
> removed lines from filetypes.vim until I found the culprit. The match
> case is looking for # in column 1 of lines 1 and 3. Since I had a
> multi-line comment, it matched. The bummer part is I couldn't figure
> out how to make the Kconfig be higher weight than the one that matched
> it. I attempted to move the au line above to the top of the section,
> but this yielded nothing. Do I need to move the line:
>
> au BufNewFile,BufRead Kconfig.* call s:StarSetf('kconfig')
>
> In stead?
>
> If you know of a fix for this, please pass it along to me.
To start with, never modify any file under $VIMRUNTIME. It may be
overwritten by an update to Vim within the same revision (e.g.,
7.3.x) and will be ignored if you update Vim to a new revision
(e.g., 7.2 to 7.3).
If Vim's decision about the type of a particular file is not what
you want, there are two standard solutions described under
:help new-filetype
sections A and C. Which method you should choose depends on the
number of filetype rules you intend to add or modify. If the number
is small, section A, using a file under ~/.vim/ftdetect is easier.
If the number is large, section C, creating your own
~/.vim/filetype.vim is probably better. For method A, your
~/.vim/ftdetect/kconfig.vim file would look like this:
au BufRead,BufNewFile Config.in set filetype=kconfig
For method C, your ~/.vim/filetype.vim would look like this:
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile Config.in setfiletype kconfig
augroup END
Note that the former uses "set filetype" while the latter uses
"setfiletype". That is because the rules in the files under
~/.vim/ftdetect are processed _after_ those in
$VIMRUNTIME/filetype.vim and must override the decision Vim has
already made, whereas, the rules in ~/.vim/filetype.vim are applied
before those in $VIMRUNTIME/filetype.vim. In a sequence of
"setfiletype" commands, the first one executed "wins". See
:help :setfiletype
HTH,
Gary
--
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