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

Add .tikz file completion for \input #2162

Closed
jhossbach opened this issue Sep 7, 2021 · 10 comments
Closed

Add .tikz file completion for \input #2162

jhossbach opened this issue Sep 7, 2021 · 10 comments

Comments

@jhossbach
Copy link

jhossbach commented Sep 7, 2021

As of now, if I am reading

Complete `.tex` files.
correctly, vimtex only searches for .tex files when \input is written. However, I would love to see it searching for .tikz files as well. I believe this is the normal way to include tikz files, e.g.

\begin{figure}
  \centering
  \input{filename.tikz}
  \caption{}
  \label{}
\end{figure}

I would love to see completion for this as well.
Please correct me if this is not the right way to do / there is completion for tikz files, just not for \input.

Regards
Julian Hossbach

@jhossbach
Copy link
Author

jhossbach commented Sep 7, 2021

Also, compilation errors that happen inside this .tikz file seem to not trigger the quickfix window. This might be related, but I don't know for sure
EDIT: This problem seems to occur only sometimes, I haven't been able to pin the exact behaviour down yet

@lervag
Copy link
Owner

lervag commented Sep 7, 2021

As of now, if I am reading [the docs] correctly, vimtex only searches for .tex files when \input is written.

So, simply put: you want completion for \input (and friends) to also complete *.tikz files in addition to *.tex files, right?

Please correct me if this is not the right way to do ...

This is OK, but I would be glad if you could provide a minimal example of this. That is, a main.tex file and a minimal .tikz file.

Also, compilation errors that happen inside this .tikz file seem to not trigger the quickfix window. This might be related, but I don't know for sure

No, this is not related. But I could consider looking into this if you open a new issue for it with a description of how to reproduce it.

@jhossbach
Copy link
Author

So, simply put: you want completion for \input (and friends) to also complete *.tikz files in addition to *.tex files, right?

Exactly.

This is OK, but I would be glad if you could provide a minimal example of this. That is, a main.tex file and a minimal .tikz file.

I tested this with the following files:
My minimal.vim file: (I use vim-plug)

set nocompatible
let &runtimepath  = '~/.vim/plugged/vimtex,' . &runtimepath
let &runtimepath .= ',~/.vim/plugged/vimtex/after'
filetype plugin indent on
syntax enable

My minimal.tex file:

\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\input{minimal.tikz}
\end{document}

My minimal.tikz file:

\begin{tikzpicture}
\node at (0,0) {This is a test node};
\end{tikzpicture}

I want \input{ (and friends) to offer minimal.tikz for file completion, but it only offers .tex files.

lervag added a commit that referenced this issue Sep 9, 2021
@lervag
Copy link
Owner

lervag commented Sep 9, 2021

I think this should work now, please test.

@lervag lervag closed this as completed Sep 9, 2021
@jhossbach
Copy link
Author

It does not provide minimal.tikz for omnicomplete if I use minimal.vim file, but my normal vim now displays .tikz files for omnicomplete, I'll take that. Thanks a lot!

@lervag
Copy link
Owner

lervag commented Sep 9, 2021

It will only work if VimTeX recognizes that you use the tikz package. This restriction could be relaxed, but I am quite confident that it should work well (and it thus avoids a filesystem search for files unless necessary).

@clason
Copy link
Contributor

clason commented Sep 9, 2021

I have the following in my config:

au BufNewFile,BufRead *.tikz setlocal ft=tex nowrap

(Maybe VimTeX could recognize .tikz files out of the box?)

@lervag
Copy link
Owner

lervag commented Sep 9, 2021

Yes, but I believe it may require some more work. I.e., we need to consider how the VimTeX state should be initialized when loading VimTeX for tikz files.

Could you open a new issue about this?

@clason
Copy link
Contributor

clason commented Sep 9, 2021

Ah, VimTeX doesn't provide any ftdetect on its own -- .cls files are also not recognized as ft=tex (unless the first line contains a comment). Would you be open to adding detection logic?

@lervag
Copy link
Owner

lervag commented Sep 9, 2021

Yes, at least open to discuss it. I think this could also be part of the same issue.

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

No branches or pull requests

3 participants