Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

fix: Use language overlay and highlight functions#10

Merged
yehorkardash merged 6 commits into
n8n-io:masterfrom
yehorkardash:language-overlay
Sep 9, 2025
Merged

fix: Use language overlay and highlight functions#10
yehorkardash merged 6 commits into
n8n-io:masterfrom
yehorkardash:language-overlay

Conversation

@yehorkardash

@yehorkardash yehorkardash commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

This PR makes some fixes related to n8n expression parsing and syntax highlighting.
Issues:

  • links in strings are being parsed as sql rather than strings
  • functions are not highlighted in a different color
image

The issue with links is that expressions {{ }} were included in SQL grammar and string parsing got broken. The PR reverts sql grammar to it's original state and adds an overlay language that separates sql from n8n expressions.

The PR also adds a new element Function to allow highlighting them differently than statements such as SELECT. I tried to include the most basic functions, but in reality there are hundreds of functions in each SQL dialect, so it feasible to include them all.

Related to n8n-io/n8n#19291

@yehorkardash yehorkardash changed the title Language overlay fix: Use language overlay and highlight functions Sep 8, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@ivov ivov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏻

Comment thread src/expressions.grammar

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the overall approach, but we're duplicating packages/@n8n/codemirror-lang/src/expressions/expressions.grammar. Should we move this entire repo codemirror-lang-n8n-sql to packages/@8n/codemirror-lang/src/sql?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can do that. Let's merge the PR here and I will move the repo

Comment thread src/sql.grammar

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're reverting to the original, let's refer to the latest?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest changes require updating code mirror dependencies in editor-ui, because some interfaces were changed.
Not particularly a blocker, but I didn't want to increase the scope of the task

Comment thread src/tokens.ts Outdated
for (let kw of keywords.split(" ")) if (kw) result[kw] = Keyword
for (let tp of types.split(" ")) if (tp) result[tp] = Type
for (let kw of (builtin || "").split(" ")) if (kw) result[kw] = Builtin
for (let kw of (functions || "").split(" ")) if (kw) result[kw] = Function

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (let kw of (functions || "").split(" ")) if (kw) result[kw] = Function
for (let fn of (functions || "").split(" ")) if (kw) result[kw] = Function

@ivov ivov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@yehorkardash yehorkardash merged commit 34ce50d into n8n-io:master Sep 9, 2025
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants