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

Can one use the default map K (vimtex-doc-package) to shows tizkzlibrary #2480

Closed
chenle02 opened this issue Sep 4, 2022 · 6 comments
Closed

Comments

@chenle02
Copy link

chenle02 commented Sep 4, 2022

I have been using the following default map to view the package pdf files:

map <buffer> K <Plug>(vimtex-doc-package)

which is super convenient~!

Here are few lines in the preamble of the tex file:

...
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{hobby}
...

When my cursor is on tikz and after hitting K in normal mode, I can open the package pdf file
for tikz. But when my cursor is on hobby, I would like to use the same mapping K to open the
package document for hobby.

Would it be possible? Thanks a lot~!

@lervag
Copy link
Owner

lervag commented Sep 4, 2022

Hmm, interesting question. The functionality relies on a very simple mapping from package name to documentation url. If we can have a similar simple mapping for tikz packages, then I believe it should be easy.

What's the url for the docs for the hobby package?

@lervag
Copy link
Owner

lervag commented Sep 4, 2022

I've made an initial attempt at this. Please test. Notice that in many cases, the library is part of the core tikz package, in which case we fallback to the tikz package docs.

Let me know if you find edge cases, I'll try to handle them.

@lervag lervag closed this as completed Sep 4, 2022
lervag added a commit that referenced this issue Sep 4, 2022
@chenle02
Copy link
Author

chenle02 commented Sep 4, 2022

Thank you lervag~! It works perfctly well~!

Here is one minor issue that we still can live with. This is the same for the \package{} case. If
there are multiple packages in one command, such as

\usepackage{amsmath,mathools}

Then when the cursor over amsmath, K in the normal mode won't work. It has to be written as one
package per line:

\usepackage{amsmath}
\usepackage{mathools}

The same for \usetikzlibrary{} command, where one has to have one lib per line.

I have transformed my tex document to one lib/package per line in order to check the document easily
whenever I want. This is not a big deal, but I just want to let you know that if this is not too
much to implement, supporting multiple libs/packages per command would be a nice plus.

Thanks a lot for your great work and prompt help~!

@lervag
Copy link
Owner

lervag commented Sep 7, 2022

Thank you lervag~! It works perfctly well~!

Great, I'm glad to hear it!

Here is one minor issue that we still can live with. This is the same for the \package{} case. If there are multiple packages in one command, such as

\usepackage{amsmath,mathools}

Then when the cursor over amsmath, K in the normal mode won't work. It has to be written as one package per line: …

No, that's not correct. Or, at least, this works as expected for me. With

%            cursor
%              |
\usepackage{ams|math,mathtools}

where | indicates the cursor position, then K opens docs for amsmath, whereas with,

%                     cursor
%                       |
\usepackage{amsmath,math|tools}

K opens docs for mathtools. However, it is correct that this is not the case for \usetikzlibrary, so I'll fix that!

Thanks a lot for your great work and prompt help~!

My pleasure :)

lervag added a commit that referenced this issue Sep 7, 2022
@chenle02
Copy link
Author

chenle02 commented Sep 9, 2022

No, that's not correct. Or, at least, this works as expected for me. With

%            cursor
%              |
\usepackage{ams|math,mathtools}

where | indicates the cursor position, then K opens docs for amsmath, whereas with,

%                     cursor
%                       |
\usepackage{amsmath,math|tools}

Thank you lervag, it indeed works~! I can put multiple packages back in one command now. :-)

K opens docs for mathtools. However, it is correct that this is not the case for \usetikzlibrary, so I'll fix that!

Thanks a lot~!

@lervag
Copy link
Owner

lervag commented Sep 9, 2022

Glad to hear it!

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

2 participants