kbrsh / moon

🌙 The minimal & fast library for functional user interfaces
https://moonjs.org
MIT License
6k stars 200 forks source link

Common Editor Support for Syntax #254

Open jhechtf opened 5 years ago

jhechtf commented 5 years ago

So I went through the tutorial and while a lot of Moon is very JSX / React-like, there are certain things (like the <for> in Moon, which are very different. This can cause some strange issues in code editors that are unaware of the element.

If Moon is a serious development (which it appears to be) then creating some add-ons for syntax support for common editors (Sublime, VSCode, etc.) is likely a good idea. I did a search on the VSCode marketplace and didn't find anything. I've never personally build a syntax highlighter for VSCode yet, but I would be willing to look into how and perhaps start the project off.

kbrsh commented 5 years ago

Yup, this is definitely on the roadmap. If you'd like to build a syntax highlighter then go for it! I'd recommend building one for whichever editor you personally use. Creating a TextMate grammar should extend nicely to most editors. You should be able to build on top of a JSX syntax highlighter. Some differences are:

  1. Moon elements require parenthesis around them.
  2. Property keys can be empty, so you can do <Component="foo"/> and the props would look like { "": "foo" }.
  3. Event handlers use @ as a prefix instead of on.

That's all I can name off of the top of my head, but that's the majority of the difference in regards to syntax.

jhechtf commented 5 years ago

Will look into it.

As an aside, any plans for TypeScript types?

On Sat, Aug 10, 2019, 18:44 Kabir Shah notifications@github.com wrote:

Yup, this is definitely on the roadmap. If you'd like to build a syntax highlighter then go for it! I'd recommend building one for whichever editor you personally use. Creating a TextMate grammar should extend nicely to most editors. You should be able to build on top of a JSX syntax highlighter. Some differences are:

  1. Moon elements require parenthesis around them.
  2. Property keys can be empty, so you can do and the props would look like { "": "foo" }.
  3. Event handlers use @ as a prefix instead of on.

That's all I can name off of the top of my head, but that's the majority of the difference in regards to syntax.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kbrsh/moon/issues/254?email_source=notifications&email_token=AB6GLF2MK66KSPUTSGMIKHDQD5VI3A5CNFSM4IK2SFP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4AYH5Y#issuecomment-520193015, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6GLFZ2SUWHAKNVWQMDVGDQD5VI3ANCNFSM4IK2SFPQ .

kbrsh commented 5 years ago

There are no plans as of now to use TypeScript within Moon itself, and I may write types for the API — it's lower priority though. Right now I'm focusing on some official drivers, specifically the router and HTTP drivers.

jhechtf commented 5 years ago

For TypeScript I was mostly referencing adding in a type definition for people (like me) whose editors (VSCode) use that information automatically. looking into grammars for VSCode. If I get something I'll link it on this and submit a pull request to update the docs (add in a "Working with Moon in your favorite editor" section or something)

On Sat, Aug 10, 2019 at 6:50 PM Kabir Shah notifications@github.com wrote:

There are no plans as of now to use TypeScript within Moon itself, and I may write types for the API — it's lower priority though. Right now I'm focusing on some official drivers, specifically the router and HTTP drivers.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kbrsh/moon/issues/254?email_source=notifications&email_token=AB6GLF3BG7NUSPVTJ4PLIGDQD5V5FA5CNFSM4IK2SFP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4AYKCY#issuecomment-520193291, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6GLFZKUTGAJERC3NFLBZTQD5V5FANCNFSM4IK2SFPQ .

kbrsh commented 5 years ago

Yup, type definitions might be added but aren't top priority for now.

If I get something I'll link it on this and submit a pull request to update the docs

That's awesome! Feel free to add it in the "View" section if you end up adding to the docs. If not, I'll be happy to write them as well.