Vim YouCompleteMe启用.tex文件类型

时间:2014-02-08 16:00:59

标签: vim vim-plugin

当我用Vim打开* .tex文件时,YCM会将文件类型读作plaintex(由set ft?返回)。 所以我加入了.vimrc:

let g:ycm_filetype_blacklist = {'plaintex' : 1}

但一切都没有改变。

这里我希望文件类型.tex被读作tex类型(set ft=tex)。 如何用YCM选项定义它?

2 个答案:

答案 0 :(得分:1)

YCM是否设置了'filetype'选项?如果您希望将其设置为tex,请检查其设置位置:

:verbose set ft?

我打赌它设置在$VIMRUNTIME/filetype.vim,在这种情况下,这是我的错。幸运的是,我让它可配置。根据{{​​1}},

: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.
你的vimrc文件中的

会让你开心。

答案 1 :(得分:0)

经过研究(来自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'