latex-lsp / texlab

An implementation of the Language Server Protocol for LaTeX
GNU General Public License v3.0
1.55k stars 53 forks source link

Nested input with full path from root directory does not work as expected #571

Closed frederikrosenberg closed 2 years ago

frederikrosenberg commented 2 years ago

Texlab version: 3.3.1 Latexmk version: 4.76

I'm currently not able to use a nested \input{} from within another \input{} if the second input is referencing the other file by the root directory instead of using a relative path.

Steps to reproduce:

Expected behavior: To be able to build from second.tex and have auto-completion.

latexmk is able to build with these inputs.

Current behavior: Not able to build with :TexlabBuild from NeoVim from second.tex. Auto-complete is not able to suggest functions from imported packages.

pfoerster commented 2 years ago

Thanks for the very detailed report!

For this to work, the texlab.rootDirectory setting needs to be set to the directory containing the main.tex file (relative paths like the current working directory . are also possible if your editor sets the cwd of the server correctly). If you use relative paths, then the bug fix 2221dc8 is required.

frederikrosenberg commented 2 years ago

Thanks for the quick answer!

I still have the problem with the new patch, when using nested imports all using the rootDirectory as reference like the issue stated. The rootDirectory is getting set correctly by my editor, even when in second.tex which does not have auto completion.

Folder structure:

main.tex
content/
├─ first.tex
├─ second/
│  ├─ second.tex
frederikrosenberg commented 2 years ago

Actually, turns out that nvim-lspconfig does not set the root directory and just sets its as null.

It works if I manually set the root directory, thanks!