tecosaur / LaTeX-Utilities

An add-on to LaTeX Workshop that provides some features that go beyond the bare essentials
MIT License
474 stars 28 forks source link

Enable Live Snippets for More Language Mode in Addition to LaTeX #356

Closed MatrixRanger98 closed 5 months ago

MatrixRanger98 commented 2 years ago

Feature Request

Is your feature request related to a problem? Please describe.

I would like to write TeX math in Markdown/RMarkdown/Quarto files as well and the live snippet is really a great feature. It saves so much time. I wonder if we could activate this extension for Markdown/RMarkdown/Quarto as well.

Describe the solution you'd like

"activationEvents": [
 "onLanguage:tex",
 "onLanguage:latex",
 "onLanguage:doctex",
 "onLanguage:markdown",
 "onLanguage:rmd",
 "onLanguage:quarto"
]

Then add a setting that could disable the extension for Markdown/RMarkdown/Quarto.

MatrixRanger98 commented 2 years ago

By the way, I want word count and formatted pastes for Markdown as well. But such features are provided by other extensions already (though I think supporting them here is a cleaner solution). The live snippet is a unique feature that I haven't seen anywhere else and I like it very much.

leoleoasd commented 10 months ago

Most math-related live snippets only works in latex, and due to difficulties in parsing them, they are even not supported in $$. Supporting them in markdown would be fairly difficult. If someone can come up with a solution (PR welcomed!) that can parse and handle inline math formulas like $$, then I think it would be reasonable to support live snippets in markdown.

MatrixRanger98 commented 10 months ago

Yes. But supporting those non-math-related ones is already good enough for daily use. For now I am using a workaround by modifying the local source codes in LaTeX Utilities to let it regard Markdown as LaTeX. But I need to redo the trick after each update. It would be great just to have the option of activating the extension in Markdown. To be honest, most math-related ones are not that useful. My use case is mainly replacing ^{} and _{} by some two-key trigger. This speeds up math writing immensely.

leoleoasd commented 10 months ago

Can you try open a blank .tex file in your markdown project then see if live snippets work in markdown?

MatrixRanger98 commented 10 months ago

No. It doesn't work. If you look at the source code of Latex utilities, even when it is activated, the live snippets only react when the document is LaTeX. There is a judgment step in the code.

leoleoasd commented 10 months ago

Yes, this line image I don't think adding markdown to activationEvents is a good idea because it will make everyone that writes markdown loads a slow extension. Do you think that, add a command that does nothing but loading the extension, and allow setting language ids for live snippets a good approach?

MatrixRanger98 commented 10 months ago

Yeah that is good approach. I would appreciate it if the change can be made.

mayurankv commented 9 months ago

I too would love this!

MatrixRanger98 commented 5 months ago

Just wondering if this could be implemented soon. Thanks! It would help save a lot of time.

leoleoasd commented 5 months ago

I'll see if I can squeeze some time this weekend

leoleoasd commented 5 months ago

image

I'll try to publish it tomorrow....

leoleoasd commented 5 months ago

@MatrixRanger98 This should be fixed now.