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

VSCode extension for Eta #39

Closed
nebrelbug opened this issue Oct 15, 2020 · 13 comments
Closed

VSCode extension for Eta #39

nebrelbug opened this issue Oct 15, 2020 · 13 comments
Assignees

Comments

@nebrelbug
Copy link
Collaborator

A common request from Eta users is VSCode syntax highlighting. We should create a VSCode extension with syntax highlighting for Eta templates! (Bonus: include snippets and/or formatting)

Theoretically, we should be able to fork https://github.com/Digitalbrainstem/ejs-grammar. It has about 200K users and seems to have quite a few features.

We could instead try to create a Language Server, which might be more powerful at the possible cost of being more complex to create. Here's one fairly minimal example: https://github.com/ebebbington/drash-markup-language.

Resources

@shadowtime2000
Copy link
Collaborator

I am in the process of creating a VSCode extension.

@shadowtime2000
Copy link
Collaborator

I kind of finished the syntax highlighting, still yet to publish the extension on the market place repo

@nebrelbug
Copy link
Collaborator Author

@shadowtime2000 sweet! It looks good!

One thing to remember is that we should include the white space trimming control characters, - and _, right after the opening tags and after the closing tags. Also that ~ can be used instead of =, and they can have white space in front of them 👍

@shadowtime2000
Copy link
Collaborator

@nebrelbug Done! Do you think its ready for publishing?

@nebrelbug
Copy link
Collaborator Author

@shadowtime2000 fantastic work!

One potential problem is that it doesn't handle strings and multiline comments (or tags that are commented out).

It's possible to create a regular expression that matches complete Eta tags. Do you know if it's possible to use a regular expression to match embeds which should be highlighted, rather than using "beginning" and "end"?

@shadowtime2000
Copy link
Collaborator

@nebrelbug Using some old TextMate guides I fixed the Javascript syntax highlighting and allowed you to do something like this:

<% console.log("%>"); %>

@nebrelbug
Copy link
Collaborator Author

@shadowtime2000 unfortunately the above code doesn't seem to be working for me while testing the extension:

image

@shadowtime2000
Copy link
Collaborator

It seems to be working for me.
image

@nebrelbug
Copy link
Collaborator Author

@shadowtime2000 oops, looks like I had another extension enabled that was messing things up 😂

Having opening delimiters inside embedded blocks still seems to be broken:

image

@shadowtime2000
Copy link
Collaborator

@nebrelbug Should be working now
image

@shadowtime2000 shadowtime2000 self-assigned this Oct 21, 2020
@shadowtime2000
Copy link
Collaborator

Just for organization, I assigned myself.

@nebrelbug
Copy link
Collaborator Author

@shadowtime2000 this is fantastic! I think this extension really highlights some of the ways (better string parsing, multi-line comments) that Eta improves over alternatives like EJS.

My one suggestion would be to change autoClosingPairs from "<% ", " %>" back to "<%", "%>" (without the spaces). Having the spaces means that the tags don't auto-close if you type <%=, for example.

I think the extension is definitely ready to publish! It's super helpful and the syntax highlighting is beautiful. The only thing it needs is an explanatory README!

@shadowtime2000
Copy link
Collaborator

eta-vscode has been published so I am going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants