Skip to content
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

Prune dependency graph of un-linked .tex files? Expose follow_package_links option in dependency graph builder? #1034

Open
sdbuch opened this issue Mar 9, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@sdbuch
Copy link

sdbuch commented Mar 9, 2024

Hi,

I had two feature requests related to how Texlab populates the workspace with documents in the project.

  1. I find quite frequently when editing projects (especially near a deadline) that Texlab is providing me large amounts of warning/error diagnostics (e.g., in Trouble's quickfix menu) for .tex files that are not being used in my active project. For example, this often occurs for me when an 'old' version of a section or appendix is replaced by a new one; the new file gets introduced to the \input{...} statements, and the old file is left around in case text/etc. is needed from it later (or perhaps simply by negligence), although it is no longer \input to the project anywhere. These spurious warnings/errors clutter the diagnostics menu, and they even tend to produce additional such errors when they are no longer used due to things like broken references (which multiply as the rest of the project changes).

    It would be nice if there were a way to filter these -- for example, it seems that it could be possible to prune nodes from the workspace dependency graph built in crates/base-db/src/graph.rs (etc.) that have no connections to "triple octagon" files in the workspace. For my use case, it would also suffice if diagnostics for these disconnected nodes could be suppressed with a new option (not sure if this is possible).
  2. Somewhat related to this, I noticed when inspecting dependency graphs for some of my projects that certain files are 'orphaned' (as above) when they are actually linked elsewhere in my project -- I found that this is because by default, an option follow_package_links in crates/base-db/src/graph.rs is presumably disabled. Could there be a way to expose this option, say via a workspace/executeCommand? Is this expected to hurt performance greatly?

Thanks for your work on Texlab!

@pfoerster pfoerster added the enhancement New feature or request label Mar 16, 2024
@pfoerster
Copy link
Member

for example, it seems that it could be possible to prune nodes from the workspace dependency graph built in crates/base-db/src/graph.rs (etc.)

I would like to prune those nodes as well but at the moment, this would break in scenarios like these:

main1.tex
main2.tex
...
mainN.tex
some_file.tex

If you open some_file.tex in the editor and it does not have \begin{document}, the server will try to search a parent file by walking up the directory tree and loading all TeX files along the way. The server then loads main1.tex to mainN.tex, finds out that none of them reference some_file.tex and unload them right after because they are not open. Effectively, this would happen on every keystroke and severely degrade the performance.

For my use case, it would also suffice if diagnostics for these disconnected nodes could be suppressed with a new option

This would be possible without invasive changes. We could limit the reported diagnostics only to the currently opened projects.

If we want to actively prune unreferenced files, we need to avoid walking up the directory tree for TeX files and instead use something like %!TEX root magic comments.

@pfoerster
Copy link
Member

I found that this is because by default, an option follow_package_links in crates/base-db/src/graph.rs is presumably disabled. Could there be a way to expose this option, say via a workspace/executeCommand?

This flag was introduced in order to avoid having to load the entire TeX distro if you reference a package and are using something like TinyTeX where the distro is part of your home directory.

You can use texlab.experimental.followPackageLinks to enable or disable it:
https://github.com/latex-lsp/texlab/wiki/Configuration#texlabexperimentalfollowpackagelinks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants