Frage

When I open a *.tex file with Vim, filetypes is read as plaintex (returned by set ft?) by YCM. So I added in .vimrc :

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

But nothing had changed.

Here I want that filetype .tex is read as tex type (set ft=tex). How to define it with YCM options?

War es hilfreich?

Lösung

After research (from vim-latex plugin) I found that I have to add following:

" 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'

Andere Tipps

Does YCM set the 'filetype' option? If you want it set to tex, then check where it was set:

:verbose set ft?

I bet it is set in $VIMRUNTIME/filetype.vim, in which case it is my fault. Luckily, I made it configurable. According to :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.

I think that

:let g:tex_flavor = 'latex'

in your vimrc file will make you happy.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top