wasp-lang / wasp

The fastest way to develop full-stack web apps with React & Node.js.
https://wasp-lang.dev
MIT License
13.62k stars 1.18k forks source link

Improve Wasp IDE support for PSL #887

Closed Martinsos closed 3 months ago

Martinsos commented 1 year ago

RIght now, we don't offer proper syntax coloring or error messages for PSL when embedded in Wasp. This is due to us not using whole PSL syntax, but parts of it (no model {,but instead we have entity MyEntity {), so PSL LSP can't recognize those.

One solution might be to put full PSL into PSL tags, with model, another might be to take PSL out into separate files. We are not yet sure how to best do this.

Martinsos commented 1 year ago

Related to https://github.com/wasp-lang/wasp/issues/641 , since it makes a lot of sense to fix both at the same time. Or to put it differently, solution that solves one of these is probalby going to solve the other too.

Martinsos commented 1 year ago

Couple more ideas:

  1. Implement our own LSP functionality for psl powered entities in Wasp.
  2. Implement our own DSL for entities, instead of using PSL, and then implement our own LSP support for that.
  3. Maybe do something with vscode virtual file system.
Martinsos commented 1 year ago

Interesting to check out: Vue has Volar code extension. They have other languages embedded in their language (well they have xml/html which then some of it contains JS, some of it smth else) and what they do to provide proper IDE support for those is construct "fake" ("virtual", temporary) files on disk where they extract those languages -> for example one file containing Javascript -> and then do stuff on those files. Stuff like formatting, hints. Then they collect that info and apply it back to their file.

We could use this for Prisma -> we could construct prisma.schema file, run formatting and possibly even prisma LSP on it, and then apply that info in our file. We would need a bit of source mapping to correctly map it, of course.

So it might be worth checking out how are they doing it with Volar.

Zeko369 commented 1 year ago

In the meantime volar.js became a separate project that can be used for other language extensions (i.e. Astro is using it in the latest version)

Martinsos commented 1 year ago

In the meantime volar.js became a separate project that can be used for other language extensions (i.e. Astro is using it in the latest version)

Wooooooah that is amazing isn't it!? Oh man! This not only could solve our Prisma issues, but also allow us to possibly embed some JS which I always wanted (@sodic don't read this :D)!

Ok this is getting exciting!

Martinsos commented 5 months ago

This is now work in progress! @infomiho is working on this currently (#2002 ), and direction we took is taking PSL out of Wasp file and allowing them to use have their prisma.schema file. We will be parsing that file then so we keep the level of understanding we had so far.

infomiho commented 3 months ago

Completed in #2035