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

.latexmkrc-related file detection failures affecting forward search, diagnostics, cleaning and build #1262

Open
anwaralameddin opened this issue Nov 6, 2024 · 0 comments

Comments

@anwaralameddin
Copy link

Hello,

Thank you for creating this project. Over the past few days, I had a chance to go through some portion of the code and realise how much work went into it.

Recently, I am using latexmk with a .latexmkrc file, mainly to have a relatively tidy project root directory. I have noticed that TexLab has been improving support for .latexmkrc, still I came across a few issues. I am listing a couple of them here as they relate to how .latexmkrcvariables are retrieved, and their fixes might share a commonality.

  • When the variable $jobname is specified in the .latexmkrc file, it changes the base name of the generated files (see the manual, page 41). Then, the methods textDocument/forwardSearch and textDocument/publishDiagnostics fail as they are expecting the wrong filename. Setting texlab.build.filename to the correct PDF filename fixes the issue for textDocument/forwardSearch.

    Related issue:

    GitHub issue/pull request detail

  • The method textDocument/forwardSearch and the commands texlab.cleanArtifacts and texlab.cleanAuxiliary fail when the root document is placed in a subdirectory, say src and the variable $do_cd is set to 1 in .latexmkrc, e.g.,

    # .latexmkrc
    @default_files = ('src/main.tex');
    $do_cd = 1;

    $do_cd = 1 instructs latexmk to change the working directory before processing (see the manual, page 36). The failure is due to TexLab expecting the root document to be in the project root directory instead of src. In this context, the method textDocument/build succeeds when called from the root document and fails if called from a non-root document, e.g. src/section.tex. Examining the logs, the server seems to fail to detect the root document in both cases due to $do_cd = 1 and falls back to the amended file, so it works only when the two coincide.

  • texlab does not take into account the .latexmkrc variable $out2_dir that specifies the final-output directory (see the manual, page 45).

When .latexmkrc is used, all of the variables $aux_dir, $out_dir, $out2_dir, do_cdand $jobname are relevant, if set, and can affect the detected paths of the relevant directories and files used by TexLab. .latexmkrc variables could be reported in a dry run, without the need for a dummy $\TeX$ document, using the -e option, e.g.

latexmk -e 'print \"$aux_dir\0$out_dir\0$out2_dir\0$do_cd\0$jobname\"; exit 0;'

Note that $jobname allows substitutable placeholders that need to be resolved to get the file name. So, for $jobname, it might be better to wait for the implementation of an option that reports the file name, as discussed in this comment.

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

No branches or pull requests

1 participant