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

feat: Svelte support via Volar #80

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

simonhaenisch
Copy link
Owner

Still work-in-progress, doesn't actually work yet (see failing test).

Would close #39.

@johnsoncodehk
Copy link
Contributor

It seem getScriptSnapshot giving invalid svelte content.

螢幕截圖 2022-10-20 17 30 33

<scriptprettier:content✂="CgkJaW1wb3J0IEZvbyBmcm9tICcuL0Zvby5zdmVsdGUnOwoJCWltcG9ydCBCYXIgZnJvbSAnLi9CYXIuc3ZlbHRlJzsKCQlpbXBvcnQgVW51c2VkIGZyb20gJy4vVW51c2VkLnN2ZWx0ZSc7Cgk=">{}</script>

	<Foo />
	<Bar />

@johnsoncodehk
Copy link
Contributor

If you need to debug, you can add breakpoint at node_modules/@volar/language-core/out/languageContext.js line 139.

@simonhaenisch
Copy link
Owner Author

simonhaenisch commented Nov 9, 2022

It seem getScriptSnapshot giving invalid svelte content.

Actually, what you're seeing there is what Prettier passes to the plugin as code argument, and I'm assuming it comes from prettier-plugin-svelte. That base64 string is the encoded version of the script's actual value. Not very familiar with svelte tooling but I'll try to dig deeper when i find some more time for this.

Edit: this is what's doing this: https://github.com/sveltejs/prettier-plugin-svelte/blob/master/src/lib/snipTagContent.ts. I guess I could manually call that unsnipContent function that's exported there, just wondering whether it's a good approach 🤔

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

Successfully merging this pull request may close these issues.

[Feature request] Add Svelte support
2 participants