moon icon indicating copy to clipboard operation
moon copied to clipboard

Common Editor Support for Syntax

Open jhechtf opened this issue 5 years ago • 5 comments

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.

jhechtf avatar Aug 10 '19 23:08 jhechtf

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.

kbrsh avatar Aug 11 '19 01:08 kbrsh

Will look into it.

As an aside, any plans for TypeScript types?

On Sat, Aug 10, 2019, 18:44 Kabir Shah [email protected] 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 <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.

— 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 .

jhechtf avatar Aug 11 '19 01:08 jhechtf

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.

kbrsh avatar Aug 11 '19 01:08 kbrsh

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 [email protected] 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 .

jhechtf avatar Aug 12 '19 06:08 jhechtf

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.

kbrsh avatar Aug 12 '19 07:08 kbrsh