Closed nchodosh closed 4 years ago
This feature works, it's even showcased in the GIF on README.md.
Can you provide a minimal example of what fails for you? (Do you use \include
or \input
?)
Sorry for not including an example before.
Suppose I have a directory /home/test-lsp
with files test.tex
, egbib.bib
, foo_instructions.text
.
The top level file is test.tex
and contains:
\documentclass{article}
\begin{document}
This is the top level document with a citation \cite{Chodosh_2020}
\section{How to foo}
\input{foo_instructions}
\bibliography{egbib}
\end{document}
In this file completion for citations works correctly.
But in the file foo_instructions.tex
% !TeX root = /home/test-lsp/test.tex
In this file I want to cite\cite{Chodosh_2020} but I can't get any completions
I don't get any completions.
Ah, I see. You could replace \input
by \include
, or add explicitly the .tex extension, so \input{foo_instructions.tex}
. Then it should work.
I believe there's some funny business about how and when \input
adds a .tex extension automatically, and I wonder if your code works in every TeX distribution. I would like to find out about this before considering a fix for the issue you reported here.
Unfortunately I don't think I can use include statements since I have to work with strict formatting guides and can't have new pages for each section. I just tried adding the .tex extension but still am not getting anything. I tried adding the extension and changing it to the full path but neither worked. Is there a debug mode I can turn on to try to figure out what is happening?
EDIT: To try different things I change the files and then run restart-lsp-workspace to make sure the changes take effect.
Do you get the expected completions in the root file, test.tex? Also, can you check that Emacs opens foo_instructions.tex is in latex-mode
as opposed to plain-tex-mode
?
I tried your example (with minimal changes to the path names), and it works after I add the .tex suffix in the \input
command. Either with or without an absolute file path in the magic comment.
Another thing you might try is to initialize a git repo where test.tex
is, or in some other way make sure lsp-mode
understands what the root directory of your tex project is. Or else see if if works with Eglot (which is what I tried).
Ah! For some reason foo_instructions.tex
was being opened in TeX mode instead of LaTeX, switching to LaTeX mode fixed it. Thanks so much and thanks again for the project!
I am seeing a similar behavior now (just installed today for the first time). For some reason I cannot get autocompletion on anything defined in another file. It seems like digestif is not following this link: % !TeX root = /home/test-lsp/test.tex
how can I check this?
Interestingly, based on this comment I went back to a previous commit. Also, my main.tex
was of the form:
\documentclass{article}
\begin{document}
This is the top level document with a citation \cite{Chodosh_2020}
\section{How to foo}
\input{foo_instructions.tex}
\bibliography{egbib}
\end{document}
Both overleaf and vs-code's extension have no problem with following these paths but it appears to not work in digestif.
If I checkout commit f1b4202928a49e8c20f84ed14deafd0f6b798e2f and remove the extension in either the \input{foo_instructions.tex}
or \include{foo_instructions.tex}
(both give same result):
\documentclass{article}
\begin{document}
This is the top level document with a citation \cite{Chodosh_2020}
\section{How to foo}
\input{foo_instructions}
\bibliography{egbib}
\end{document}
Then the references are correctly resolved. Apologies for the noise, although I would be happy to open another issue if this is not expected.
I am on mac OS in case that is relevant.
how can I check this?
You can e.g. add \def\mytestcommand{}
to the root file and see if you get this as a completion in the child.
If I checkout commit https://github.com/astoff/digestif/commit/f1b4202928a49e8c20f84ed14deafd0f6b798e2f and remove the extension in either the \input{foo_instructions.tex} or \input{foo_instructions.tex}:
I think there are some typos in this sentence. Both of your examples look the same to me.
You are completely right. I edited the previous message.
AFAIK, with \input
you must include the extension and with \include
you must not include the extension. This is what is implemented, barring bugs. This might also be OS dependent; I don't have access to mac os.
Also, it might be more robust to put all files in the same directory and not use absolute names in the magic comment.
Indeed, it could be OS dependent. Fortunately I now found a combination of version + syntax that works!Thanks for your work on digestif!El mar. 11, 2023, a la(s) 8:03 a.m., Augusto Stoffel @.***> escribió: AFAIK, with \input you must include the extension and with \include you must not include the extension. This is what is implemented, barring bugs. This might also be OS dependent; I don't have access to mac os. Also, it might be more robust to put all files in the same directory and not use absolute names in the magic comment.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
Hi astoff, first I'd like to say this is a great project that's really improved my emacs/LaTeX experience!
However, most of my documents are short scientific papers where the usual style is to have a main document with the section headings followed by \include statements for the text of those sections (this makes it way easier to change the format of the paper for different venues). I see in a different issue that you are aware that with this setup completion of citations does not work properly even with
% !TeX root = main.tex
added at the top.Any chance that this functionality will be added soon? The citation completion is one of my favorite parts of this project!