Vimtex: Neovim: warning message about filetype and syntax

Created on 27 May 2019  路  9Comments  路  Source: lervag/vimtex

Minimal vimrc init.m (the vimrc for Neovim)

set nocompatible
filetype plugin indent on
syntax on
" vim-plug
call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex', {'for': ['tex', 'plaintex', 'bst']}
call plug#end()

There is no &runtimepath in the configuration.

Minimal example test.tex

\documentclass{article}
\begin{document}
test
\end{document}

Expected behaviour

When I open test.tex with nvim test.tex, there should be no warning

vimtex: "syntax on" seems to be applied before "filetype plugin on".
        This is suboptimal, because some syntax features require an initialized state.
        Please see ":help vimtex_syntax_filetype".

Observed behaviour

There is indeed such warning.

.latexmkrc content

$pdf_previewer = "zathura";
$pdflatex = 'xelatex --shell-escape -synctex=1 %O %S';

Output of :VimtexInfo

System info
  OS: Manjaro Linux
  Vim version: NVIM v0.3.5
  Has clientserver: true
  Servername: /tmp/nvim4LBD1t/0

vimtex project: test
  base: test.tex
  root: /home/*****/Documents
  tex: /home/*****/Documents/test.tex
  out: 
  log: 
  aux: 
  fls: 
  compiler: latexmk
    backend: nvim
    output: /tmp/nvim4LBD1t/1
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -pdf
  viewer: General
  qf: LaTeX logfile
    config: 
      fix_paths: 1
      packages: 
        default: 1
      default: 1
  document class: article

All 9 comments

This seems related to #1387. Do you agree?

@lervag I think my problem is more related to the one reported by @voldikss in https://github.com/lervag/vimtex/issues/1354#issuecomment-482032861. It may be specific to Neovim.

One thing I can confirm is that previous version of Vimtex works fine for me, but current version does not work with Neovim independent of the operating system.

Ok, I've tested and I can't reproduce. I'm on Arch Linux with same version of neovim. I've copied your minimal vimrc file, and I open the test file like this: nvim -u minivimrc test.tex. There are no warning messages for me.

Please clarify how to reproduce.

It might help if you provide the output of :scriptnames after you've opened your minimal example that reproduces this issue.

@Edenharder
Just changed this code

Plug 'lervag/vimtex', {'for': ['tex', 'plaintex', 'bst']}

to

Plug 'lervag/vimtex'

Then in my laptop, the issue was gone.

Don't use the on-demand mode, cause it will load the original syntax file (in my laptop: /usr/share/nvim/runtime/syntax/tex.vim) first. Once that syntax file was loaded, the b:current_syntax will be assigned to tex, and then comes the warning.
https://github.com/lervag/vimtex/blob/8b8684da10c17af4ab449e1e7435d3f9c2459bf8/autoload/vimtex.vim#L304-L309

@voldikss is quite right: The "on-demand mode", i.e. the {'for': [...]}, is not necessary and has no real effect. vimtex is a filetype plugin and will not be loaded for other filetypes anyway, and it uses the autoload feature of Vim to ensure that the scripts are not sourced until necessary.

I still can't reproduce, though. Perhaps the issue depends on the version of vim-plug?

@lervag the solution of @voldikss also works for me. Inspired by your last comment, I upgrade the vim-plug and vimtex, then everything works fine even with my initial examples. Thanks for your help guys!

Great, happy to hear things are working!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhuosongz picture zhuosongz  路  5Comments

krissen picture krissen  路  5Comments

sharethewisdom picture sharethewisdom  路  3Comments

itsShnik picture itsShnik  路  5Comments

lervag picture lervag  路  5Comments