-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Root detection fails when file contains the strings \documentclass[
and \begin{document}
even if they are commented
#2465
Comments
I'm trying to reproduce this. I created these files:
% preamble.tex
\newcommand{\testx}{xx} % main.tex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\input{preamble}
\begin{document}
Hello world.
\end{document} Then I edit I may have misunderstood something, so can you please provide a simple set of example files and the steps you use when you have the issue? |
Thank you for your fast and detailed reply! Your example works the same way in my environment, so I dug deeper. It turns out that the "symbolic link" avenue of thinking was a red herring. (I should have tested that, sorry!) I have found the issue: my preamble file contained the following snippet: (verbatim)
(Specifically, these are commented lines). Looking at This is reproducible in your example. Adding the lines
to So I suppose this is fixed, by changing the regexes to be more careful when looking for However, I still think that it is a good idea to add a directive to allow people to disable VimTeX for any given file. I think the use case of having templates that are not valid as standalone documents is legitimate. Simply put: I think it very ugly when I open a preamble without a main which then causes half my screen to fill with quickfix error messages. On the other hand, I also understand supporting further options adds maintenance work for a legitimate, yet marginal use case. Either way, my issue is resolved for now by removing those lines. Once the regexes are changed, I can add them again and all is good. |
\documentclass[
and \begin{document}
even if they are commented
Great!
Yes, nice catch! Thanks! I'm pushing a fix for this now.
Well, I'm not sure what benefit this would bring. I mean, for such a template file, you could still find many VimTeX features useful (e.g. syntax highlighing, motions, commands, etc). So, what is the problem of loading VimTeX even if the main file is not properly detected? |
Brilliant!
That is very true. Is there a way of turning off auto-compile-on-save for specific files? (To prevent lots of errors being generated). This would be for the case in which VimTeX doesn't find a root, and realises this document is not a standalone TeX file, so it won't try to compile. |
VimTeX does not have auto compile. You toggle with |
Of course you are absolutely correct. My I suppose what I meant, is that when continuous Thanks to your commit e5de00e, my issue is fixed. So I am closing this issue. Thank you for your fast support and fixing the issue! |
:)
I actually agree here. Could you reopen the issue, then I can close it when I've updated accordingly?
I'm glad to hear that! :) |
Sure. I’d be glad to see this improvement! Thank you |
There, I think that should do the trick. |
Edit: The issue is incorrectly described in this post. See below for correct description.
I have a unified preamble that I use for many projects at
$LATEXTEMPLATES/preamble.tex
.I initialise new projects as follows
It is important that
preamble.tex
is a symbolic link here to observe the unwanted behaviour.Obviously
project/project-name.tex
should not be a symbolic link, because the content is different for each project.(I use a symbolic link for
preamble.tex
so that any changes that I make to thepreamble.tex
in any individual project will be observed globally. For my workflow, this makes sense.)At the moment, when I edit
preamble.tex
VimTeX tries to compilepreamble.tex
as a standalone file.The auto-root-detection seems to fail.
I would expect one of two things to happen, when I edit
project/preamble.tex -> $LATEXTEMPLATES/preamble.tex
$LATEXTEMPLATES/main.tex
imports$LATEXTEMPLATES/preamble.tex
so it successfully compiles$LATEXTEMPLATES/main.tex
.project/project-name.tex
importsproject/preamble.tex
so it successfully compilesproject/main.tex
.Since
project/project-name.tex
is different for each project, I cannot add a vimtex-texROOT
directive topreamble.tex
. On the other hand, it seems like kind of a hack to add$LATEXTEMPLATEX/main.tex
as theROOT
in the unified preamble.I think there are two options for fixing this unwanted behaviour:
project/project-name.tex
importsproject/preamble.tex
. I think it is important that VimTeX doesn't follow the symbolic link, because it (imho) be an entirely legal and sensible approach to keep a unified preamble without a correspondingmain.tex
that imports it.VIMTEX_DISABLE
directive, to disable VimTeX for this specific file.I hope this makes sense!
Perhaps I have missed something in the documentation?
The text was updated successfully, but these errors were encountered: