Skip to content

Allow specifying file extension / location requirements for custom commands #4050

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

Open
maximilianruesch opened this issue May 17, 2025 · 5 comments
Labels
enhancement New feature or (non bug related) change to the program.

Comments

@maximilianruesch
Copy link

Currently, using custom commands (or for that matter commands from other packages) that include files and have requirements for non-standard file locations or extensions displays a false positive of the FileNotFound inspection.

E.g. using the package tikzit (.sty available under https://tikzit.github.io/), files are included as
Image
The command \tikzfig then expects the figure <name> under ./figures/<name>.tikz.
The file is also located there, but the TeXiFy plugin does not pick it up.

Is there already a setting which I missed to remove the false positive here? Is this something that can be reasonably added to the settings? Or do you have any other pointers what is appropriate here?

@maximilianruesch maximilianruesch added enhancement New feature or (non bug related) change to the program. untriaged Issue type still needs to be triaged or verified. labels May 17, 2025
@PHPirates
Copy link
Collaborator

Generally we hardcode any such non-standard behaviour for specific packages if it is not possible to auto-detect, which is also what I would do with tikzit if it's just a path prefix.
As a workaround, you can hide the false positive with a magic comment: https://hannah-sten.github.io/TeXiFy-IDEA/inspections.html#suppress-inspections

@PHPirates PHPirates removed the untriaged Issue type still needs to be triaged or verified. label May 17, 2025
@maximilianruesch
Copy link
Author

maximilianruesch commented May 17, 2025

Personally I try to avoid adding supressions from IDEA inspections, as they add "unnecessary" LOC even when nothing is actually wrong with the code. Depending on the view, this is more or less of an issue in LaTeX documents since some processors (like arara) have you add similar statements at the top of the file anyways. Additionally, I am trying to get file not found errors for all other types of files, just not for this false positive.

I guess "indexing" the command to see what it does / where it searches for files is overengineering since that includes a full static analysis. I also try to avoid hardcoding, but if that is standard practice in this plugin, would the package tikzit something you would likely support in this manner?

@PHPirates
Copy link
Collaborator

We do index all LaTeX package files that are installed, but that is regex-based instead of parser-based for performance reasons. Although I see this package is installed manually and not via ctan, so it's a bit different already.

Looking at the command definiton, it looks a bit nontrivial to parse all the If's, I would probably take the easy route and just hardcode it.

\newcommand{\tikzfig}[1]{%
{\tikzstyle{every picture}=[tikzfig]
\IfFileExists{#1.tikz}
  {\input{#1.tikz}}
  {%
    \IfFileExists{./figures/#1.tikz}
      {\input{./figures/#1.tikz}}
      {\tikz[baseline=-0.5em]{\node[draw=red,font=\color{red},fill=red!10!white] {\textit{#1}};}}%
  }}%
}

@pascalgoedeke
Copy link

pascalgoedeke commented May 17, 2025

I was about to open a similar issue, for certain figures, I have to use the
\import{absolute filepath}{filename}
command from the import package.
TeXiFy can't yet put together both paths and always shows an error that the file wasn't found.
It would be great to get support for this too.

@PHPirates
Copy link
Collaborator

@pascalgoedeke The import package should already be supported, see https://hannah-sten.github.io/TeXiFy-IDEA/code-navigation.html#import-package
If something does not work as expected, please open a new issue with an example, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or (non bug related) change to the program.
Projects
None yet
Development

No branches or pull requests

3 participants