lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.54k stars 390 forks source link

Spell checking not working properly in multifile project #310

Closed guiniol closed 8 years ago

guiniol commented 8 years ago

In a project with two files, with an \input{secondary_file.tex} inside the document environment of the main file, then I have no spellchecking when I open the secondary file. It seems that since there is no \begin{document}, vimtex disables spellchecking (except in comments). If I add a \begin{document} at the top of the secondary file, then there is spellchecking, but then the tex is not valid anymore ^^ Maybe related to #219

EDIT: Forgot to add that in the main file, spellchecking works inside the document environment and only in some environments in the preamble (comments, \title, \author, ...)

EDIT2: I'm pretty sure it used to work before the christmas holidays (but I'm not sure if vimtex was up to date at that time)

Cheers

lervag commented 8 years ago

Strange. It will help if you can create a very specific minimal working example. Please explain all steps needed to reproduce your issue.

Note: Spell checking seems to work fine for me.

guiniol commented 8 years ago

To reproduce, write those two files:

mwa.tex:

\documentclass{article}

\begin{document}

This is correctly spell cheked.

\input{subfile.tex}

\end{document}

subfile.tex:

This ins't
% but coments are

This is what I see:

screenshot from 2016-01-07 14-38-45

If I add a \begin{document} (works with other environments too) then spellchecking works (but not compilation ^^):

screenshot from 2016-01-07 14-39-37

This is the content of my ~/.vim/ftplugin/tex.vim:

setlocal textwidth=80
setlocal colorcolumn=81
setlocal spell
setlocal spelllang=en

let g:vimtex_latexmk_options = '-lualatex -shell-escape -synctex=1 -src-specials -interaction=nonstopmode'
let g:vimtex_view_method = 'mupdf'

" Enable completion with YouCompleteMe
let g:ycm_semantic_triggers = { 'tex' : [
            \ 're!\\[A-Za-z]*(ref|cite)[A-Za-z]*([^]]*])?{([^}]*, ?)*'
            \ ], }

" These options may incur lag. Disable for big projects
let g:vimtex_complete_recursive_bib = 1
let g:vimtex_fold_automatic = 1
Konfekt commented 8 years ago

Might be rather an issue of the built in syntax file by Dr Campbell. Did you update Vim in between?

guiniol commented 8 years ago

So... I'm not 100% sure it worked before, maybe I never noticed because it was working in the comments so I assumed it worked everywhere else. What I can tell you is that currently, I'm using vim 7.4.944 and that it was upgraded from 7.4.884 on 03/12/2015.

Can anyone else reproduce this behaviour with my minimal example?

lervag commented 8 years ago

I think I found a fix for the problem. Please try now.

guiniol commented 8 years ago

Works for me. Thanks a lot! So was it something new, or did I never notice?

lervag commented 8 years ago

No problem! And no, I don't think this has ever worked. In a way, I think this should be part of Dr. Campbells syntax file, but then again perhaps there is a reason why it is not. I don't know. In any case, the problem was solved by adding syntax spell toplevel, which enables spell checking on text that does not have any syntax items associated with it, such as the toplevel text of included files, as in your example.

guiniol commented 8 years ago

Ok. Weird how you can miss things sometimes. I've been working on the same paper for about a month now, and only yesterday did I realise it wasn't working ^^

lervag commented 8 years ago

Yeah, I know. I never noticed this myself, but I use spell checking rarely, and I have probably never used it on included files on the toplevel. Anyway, thanks for noticing and reporting!

guiniol commented 8 years ago

My pleasure! Especially for a plugin which makes working with latex a delight ^^

aviloff commented 3 years ago

I am running into the same issue here again, are there any specific setting I should be checking?

Problem: In included files spell checking does not work unless I put something like \section on the top line.

Or I have to use this fix

lervag commented 3 years ago

I'm sorry, @aviloff, but the issue is more than 5 years old, so it is quite clear this is not the same issue. Please open a new issue and describe it fresh according to the issue template.