Skip to content

[WIP] Svelte Language Server integration #277

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

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

snuffyDev
Copy link

@snuffyDev snuffyDev commented Aug 18, 2023

Adds (nearly) full & complete Svelte Language Server + TypeScript/JavaScript language server support for compatible browsers.

Features include:

  • Intellisense for Svelte & TypeScript/JavaScript
    • Import completions/suggestions
    • Cross-module intellisense
    • Hover tooltips (similar to VSCode's hover tooltips, complete with MDN links for CSS, for example)
    • Support for SvelteKit's "Virtual Modules" (export let data should provide correct types, for example)
    • Support for NPM package type intellisense
    • Tooltips for any errors (like in VSCode)
    • ... and much more!

Code changes

Components

webcontainer.ts

@vercel
Copy link

vercel bot commented Aug 18, 2023

Someone is attempting to deploy a commit to a Personal Account owned by @SvelteLab on Vercel.

@SvelteLab first needs to authorize it.

@vercel
Copy link

vercel bot commented Aug 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sveltelab ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 30, 2023 4:56pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
sveltelab-docs ⬜️ Ignored (Inspect) Visit Preview Oct 30, 2023 4:56pm

fixes editor loading
fixes timing issues, module resolution, ts server
cleanup a lil bit
update Editor/LangClientProvider w/ feature detection & optimize for FF
Copy link
Collaborator

@SarcevicAntonio SarcevicAntonio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, thank you so much for all the time and effort you have poured into this project! It's amazing to see all the Language Server features like hover type definitions and import completion in SvelteLab 🚀

I've sent the preview deployment link to subscribers in the Discord. Feel free to also join :)

I've only had a quick peek at the PR for now and left some nitpicky comments for the low-hanging fruit. It'll take me a bit to read it fully and probably more to understand the implementation.

Also, I'm having trouble reliably opening the Editor. It often seems to hang or maybe it just takes a really long time to load??? 🤷

EDIT: ok its not loading i think it boots, installs deps, runs vite but the editor doesn't open, at least with ?t=typescript

EDIT EDIT: now it works?! it's kinda weird? 👀

.eslintignore Outdated
@@ -11,3 +11,5 @@ node_modules
pnpm-lock.yaml
package-lock.json
yarn.lock
/src/lib/language_servers/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like these /src/lib/ stuff is still from before the language server worker was it's own module, right? 👀

.prettierignore Outdated
Comment on lines 14 to 15
/src/lib/lsp/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, could possibily be removed

Comment on lines +51 to +52
"codemirror-languageserver": "^1.11.0",
"events": "^3.3.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these new modules (open-rpc, codemirror-languageserver, events) used anywhere? 👀

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed open-rpc, and events. since they were required when using the language server modules directly rather than using the current NPM package. codemirror-languageserver is used here, though: https://github.com/SvelteLab/SvelteLab/pull/277/files#diff-eb2ab2a29594e8de109dcc59d1e2664eb6b05c0107da708a5119794aef7f030aR275

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you could remove the formatting diff from default_project_files that would be great, as that means the default projects aren't formatted according to the prettier config of the respective projects 🙏

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch -- my bad! I ran prettier globally from the NPM scripts -- would it be a good idea to add ./src/lib/default_project_files/* to .prettierignore

Copy link
Collaborator

@SarcevicAntonio SarcevicAntonio Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! Our bad then, we should add that... Do you mind adding it? 🙈

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably need a jsconfig/tsconfig for every project template, right? 🤔

return walk([''], '', file_tree);
}

function find_first_of_file_ext(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is cool! thx

),
};
}
}
return tree;
}

const IGNORE_LIST = ['.svelte-kit', 'node_modules'];
const IGNORE_LIST = ['.svelte-kit/generated', 'node_modules'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this for debugging purposes, or do we need this? i think it makes the .svelte-kit folder appear in the file tree which we might not want

@SarcevicAntonio SarcevicAntonio self-requested a review October 24, 2023 15:54
Fixes formatting for templates
This reverts commit 455ad40.
@snuffyDev
Copy link
Author

snuffyDev commented Oct 28, 2023

First of all, thank you so much for all the time and effort you have poured into this project! It's amazing to see all the Language Server features like hover type definitions and import completion in SvelteLab 🚀

I've sent the preview deployment link to subscribers in the Discord. Feel free to also join :)

I've only had a quick peek at the PR for now and left some nitpicky comments for the low-hanging fruit. It'll take me a bit to read it fully and probably more to understand the implementation.

Also, I'm having trouble reliably opening the Editor. It often seems to hang or maybe it just takes a really long time to load??? 🤷

EDIT: ok its not loading i think it boots, installs deps, runs vite but the editor doesn't open, at least with ?t=typescript

EDIT EDIT: now it works?! it's kinda weird? 👀

@SarcevicAntonio What browser (and version), along with OS and maybe device/hardware youre running on, is having difficulties?

If you're able to potentially provide me with at minimum browser + version, and some extensions you have installed (if any) I can probably repro and get it fixed before the end of the weekend 🚀

@snuffyDev
Copy link
Author

At the current moment, I don't seem to be having any issues on Edge v118.0.2088.61 with the following extensions:

image
image
image

And no issues with the latest Firefox, no extensions installed 🤔

@@ -62,6 +62,9 @@ export default defineConfig({
define: {
'process.env.NODE_ENV': '"production"',
},
worker: {
format: 'es',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are also using a worker to search the sveltekit documentation and the es worker format is not supported by firefox...i don't think there's a way to have them built in different formats right?

@TKDev7
Copy link

TKDev7 commented Oct 6, 2024

Any updates here boys?

@paoloricciuti
Copy link
Collaborator

Any updates here boys?

I started working on a different version and I almost got it working locally...I need to find a bit of time to continue working on this

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.

4 participants