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

Extra setting for adding supported languages (to allow for snippets being inserted other file types) #2520

Closed
gijswijs opened this issue Feb 9, 2021 · 6 comments
Assignees
Labels
enhancement Issue suggests an enhancement feature request Feature request

Comments

@gijswijs
Copy link

gijswijs commented Feb 9, 2021

I use a setup where I write in Markdown and use Pandoc to either create PDF's directly or create tex-files.

For advanced stuff (like equations) I insert LaTeX directly in my Markdown files. It would be nice if LaTeX-Workshop would allow for the snippets to be inserted in documents that do not have a .tex extension. And the on-the-fly previewing of equations (and/or the Math Preview Panel) to work as well on those snippets.

I took a look at the code, and the snippet insert only works if hasTexId returns true. Currently it does so if the languageId of the current document is one of the following: tex, latex, latex-expl3, doctex, jlweave, rsweave

I am suggesting a new setting that allows for an array of strings where you can add language ids that should also make hasTexId return true.

I would definitely be willing to do this myself if there is support for such a feature.

@gijswijs gijswijs added the feature request Feature request label Feb 9, 2021
@tamuratak
Copy link
Contributor

Out of the scope of the extension.

@gijswijs
Copy link
Author

gijswijs commented Feb 9, 2021

Fair enough.

For those interested, this is the workaround:

  • Set the Language Mode to Tex.
    image
  • Put \documentclass[]{} somewhere in the document.
  • Insert snippets now works. Math Preview Panel works as well
  • Don't forget to change the Language Mode back, and remove \documentclass[]{}.

@jlelong
Copy link
Collaborator

jlelong commented Feb 9, 2021

Hum, we already have some support for LaTeX fenced inside .md files: syntax highlighting and static snippets (those not triggered by \). I will investigate if there is a way to make the other features available to come up with a full support of LaTeX fenced block.

@jlelong jlelong reopened this Feb 9, 2021
@jlelong jlelong self-assigned this Feb 9, 2021
@jlelong jlelong added the enhancement Issue suggests an enhancement label Feb 9, 2021
@tamuratak
Copy link
Contributor

I am against supporting completions for LaTeX fenced block on our side. It should be treated as a language embedded in Markdown language. See:

Markdown language extensions should take control of it. If they forward requests to LaTeX Workshop, our codes will be called appropriately.

@jlelong
Copy link
Collaborator

jlelong commented Feb 9, 2021

I fully agree. My point is precisely to investigate why it does not already work this way. We already provide support for LaTeX embedding in Markdown, but is seems limited and it should not be.

@tamuratak
Copy link
Contributor

tamuratak commented Feb 9, 2021

VS Code won't do anything special for embedded languages and that it's the sole responsibility of the embedder, e.g. html must know that it embeds js and it must handle it.

why it does not already work this way.

Markdown language extensions have to call commands.executeCommand('vscode.executeCompletionItemProvider', ...) for a virtual LaTeX document.

@jlelong jlelong closed this as completed Feb 9, 2021
Repository owner locked as resolved and limited conversation to collaborators Feb 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Issue suggests an enhancement feature request Feature request
Projects
None yet
Development

No branches or pull requests

3 participants