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

How to make it work with Latex workshop ? #18

Closed
medwatt opened this issue Jun 23, 2020 · 4 comments
Closed

How to make it work with Latex workshop ? #18

medwatt opened this issue Jun 23, 2020 · 4 comments

Comments

@medwatt
Copy link

medwatt commented Jun 23, 2020

Hello,

I've been playing with this extension and seems to work as described. I created a tex.hsnips file but it doesn't seem to be detected inside a tex document. The all.hsnips gets detected fine. I am using Latex workshop to parse the tex documents. How can I get this extension to work if I don't want to put all the code inside the all.snippets?

@draivin
Copy link
Owner

draivin commented Jun 23, 2020

Hi there, I believe the default language mode for .tex files is latex, so could you try creating a latex.hsnips file and checking if it works?

@medwatt
Copy link
Author

medwatt commented Jun 23, 2020

Hi there, I believe the default language mode for .tex files is latex, so could you try creating a latex.hsnips file and checking if it works?

Thanks for your swift reply. That worked. I have one more question if you don't mind. I'm trying to set up vscode to type my documents. I came across this guy who uses ultsnips. That's how I came across your extension.

Is it possible to do something like the code shown below:

snippet '^.*\)/' "() Fraction" wrA
`!p
stripped = match.string[:-1]
depth = 0
i = len(stripped) - 1
while True:
	if stripped[i] == ')': depth += 1
	if stripped[i] == '(': depth -= 1
	if depth == 0: break;
	i -= 1
snip.rv = stripped[0:i] + "\\frac{" + stripped[i+1:-1] + "}"
`{$1}$0
endsnippet

@draivin
Copy link
Owner

draivin commented Jun 23, 2020

Sure, I believe the equivalent code would be this:

snippet `^.*\)/` "() Fraction" A
``
let stripped = m[0].substring(0, m[0].length - 1);
let depth = 0;
let i = stripped.length - 1;
while (i >= 0) {
	if (stripped[i] == ')') depth += 1;
	if (stripped[i] == '(') depth -= 1
	if (depth == 0) break;
    i -= 1
}
rv = `${stripped.substring(0, i)}\\frac{${stripped.substring(i + 1, stripped.length - 1)}}`;
``{$1}$0
endsnippet

@medwatt
Copy link
Author

medwatt commented Jun 23, 2020

snippet ^.*\)/ "() Fraction" A
let stripped = m[0].substring(0, m[0].length - 1); let depth = 0; let i = stripped.length - 1; while (i >= 0) { if (stripped[i] == ')') depth += 1; if (stripped[i] == '(') depth -= 1 if (depth == 0) break; i -= 1 } rv = `${stripped.substring(0, i)}\\frac{${stripped.substring(i + 1, stripped.length - 1)}}`;{$1}$0
endsnippet

Thanks !!

@draivin draivin closed this as completed Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants