当我使用 Vim 打开 *.tex 文件时,文件类型被 YCM 读取为 plaintex(由 set ft?
返回)。所以我在 .vimrc 中添加了:
let g:ycm_filetype_blacklist = {'plaintex' : 1}
但一切都没有改变。
在这里,我希望文件类型.tex被读取为tex类型(set ft=tex
)。如何使用YCM选项定义它?
经过研究(来自 vim-latex 插件),我发现我必须添加以下内容:
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
YCM 是否设置了'filetype'
选项? 如果您希望将其设置为 tex
,请检查它的设置位置:
:verbose set ft?
我敢打赌它是在$VIMRUNTIME/filetype.vim
设置的,在这种情况下,这是我的错。 幸运的是,我使它可配置。 据:help ft-tex-plugin
,
If the first line of a *.tex file has the form
%&<format>
then this determined the file type: plaintex (for plain TeX), context (for
ConTeXt), or tex (for LaTeX). Otherwise, the file is searched for keywords to
choose context or tex. If no keywords are found, it defaults to plaintex.
You can change the default by defining the variable g:tex_flavor to the format
(not the file type) you use most. Use one of these:
let g:tex_flavor = "plain"
let g:tex_flavor = "context"
let g:tex_flavor = "latex"
Currently no other formats are recognized.
我认为
:let g:tex_flavor = 'latex'
在你的 VIMRC 文件中会让你开心。