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

[JavaScript] Add SQL embedding #4094

Merged
merged 1 commit into from
Nov 17, 2024
Merged

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Nov 16, 2024

  • My commit messages start with the package name in square brackets, e.g. [XML] .
  • I have included new or enhanced syntax tests to cover the changes.

This is useful for server-side JS.

Especially using one of the following libraries:
https://github.com/felixfbecker/node-sql-template-strings
https://github.com/blakeembrey/sql-template-tag
https://github.com/XeCycle/pg-template-tag

Using version: 1 for the Embedding syntaxes since they need to match the inherited SQL.sublime-syntax.

It does not currently handle interpolation inside SQL strings.


The SQL template is detected but the SQL syntax highlighting is not performed (source.sql.embedded.js is the deepest scope anything within the template string gets).

Edit: If I change extends: Packages/SQL/SQL.sublime-syntax to CSS.sublime-syntax in SQL (JS template).sublime-syntax, it highlights as CSS correctly.

Edit2 It was caused by a differing version.

@jtojnar jtojnar force-pushed the js-sql-embedding branch 3 times, most recently from de64f66 to 9c72659 Compare November 16, 2024 20:44
@jtojnar jtojnar marked this pull request as ready for review November 16, 2024 20:50
@michaelblyons
Copy link
Collaborator

Does the SQL bump to version 2 then require a bunch of other "host" syntaxes to bump, too?

@jtojnar
Copy link
Contributor Author

jtojnar commented Nov 16, 2024

It requires the bump of the Embeddings syntaxes. For example, SQL (for Ruby).sublime-syntax needs to be version: 2, or the SQL example in syntax_test_ruby.rb will not be highlighted.

Curiously, Ruby.sublime-syntax itself does not seem to need to be bumped.

@michaelblyons
Copy link
Collaborator

It turns out my local set-up includes #3046, which also bumps to version 2. Sounds good to me.

@deathaxe
Copy link
Collaborator

Only inherited syntaxes need to be of same version. It is no problem to include or embed a v2 into a v1 or vice versa.

Bumping SQL to v2 and adding support for SQL in tagged template strings however are 2 distinct steps.

The more interesting question is what effect #3046 will have in combination with this one as JS is embedded, extended and used in nearly all template syntaxes. I wonder when we hit context sanity limits again. :D

@deathaxe
Copy link
Collaborator

With regards to #4035, any purley embedded syntax should be named <name> (for TS template).sublime-syntax.

Syntaxes in Embedding are currently not correctly named by accident.

@jtojnar
Copy link
Contributor Author

jtojnar commented Nov 17, 2024

Bumping SQL to v2 and adding support for SQL in tagged template strings however are 2 distinct steps.

Should I move the first commit out into a separate PR?

With regards to #4035, any purley embedded syntax should be named <name> (for TS template).sublime-syntax.

Fixed.

@deathaxe
Copy link
Collaborator

Should I move the first commit out into a separate PR?

I'd say yes. Bumping SQL version is a seperate PR. Actually I don't see any reason for it, at the moment. It would be part of merging #3046.

@jtojnar
Copy link
Contributor Author

jtojnar commented Nov 17, 2024

I'd say yes. Bumping SQL version is a seperate PR. Actually I don't see any reason for it, at the moment. It would be part of merging #3046.

Well, it is a prerequisite for this, since the embedding syntaxes inherit from the SQL one. So unless we want to wait with this PR for #3046 – but it has already been open for years – I have moved the SQL change to #4097.

This is useful for server-side JS.

Especially using one of the following libraries:
https://github.com/felixfbecker/node-sql-template-strings
https://github.com/blakeembrey/sql-template-tag
https://github.com/XeCycle/pg-template-tag

Using `version: 1` for the Embedding syntaxes since they need to match the inherited `SQL.sublime-syntax`.

It does not currently handle interpolation inside SQL strings.
@jtojnar jtojnar mentioned this pull request Nov 17, 2024
2 tasks
@deathaxe deathaxe merged commit 5b342a7 into sublimehq:master Nov 17, 2024
1 check passed
@jtojnar jtojnar deleted the js-sql-embedding branch November 17, 2024 19:38
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.

3 participants