Skip to content

Add syntax highlighting for PRQL#3313

Merged
dmaluka merged 7 commits into
micro-editor:masterfrom
vanillajonathan:patch-1
Jul 8, 2025
Merged

Add syntax highlighting for PRQL#3313
dmaluka merged 7 commits into
micro-editor:masterfrom
vanillajonathan:patch-1

Conversation

@vanillajonathan

Copy link
Copy Markdown
Contributor

Adds a syntax highlighting mode for the PRQL query language.

PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement.
https://prql-lang.org/
https://github.com/PRQL/prql

Adds a syntax highlighting mode for the PRQL query language.

PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement.
https://prql-lang.org/
https://github.com/PRQL/prql
@vanillajonathan

Copy link
Copy Markdown
Contributor Author

Hey @zyedidia can you merge this?

@vanillajonathan

Copy link
Copy Markdown
Contributor Author

Hey @dmaluka can you merge this?

@dmaluka

dmaluka commented Jun 30, 2025

Copy link
Copy Markdown
Collaborator

@JoeKar @Andriamanitra could you take care of reviewing this?

@Andriamanitra Andriamanitra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I didn't know PRQL beforehand so I went through some examples from the documentation and it seems to work alright for the most part, but I found a few minor issues.

According to the documentation "String literals can use any matching odd number of either single or double quotes", but this doesn't currently work for something like """ ab "" " cd """. Arbitrary length but matching start/end is impossible to do within the highlighting system in micro but we could hard-code a few of the first cases (eg. """"", """, ", ''''', ''', ').

Comment thread runtime/syntax/prql.yaml Outdated
Comment thread runtime/syntax/prql.yaml
Comment on lines +43 to +45
- constant.number: "\\b0b(_?[01])+\\b" # bin
- constant.number: "\\b0o(_?[0-7])+\\b" # oct
- constant.number: "\\b0x(_?[0-9a-fA-F])+\\b" # hex

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The online playground for PRQL doesn't accept a literal like 0x55_55 but this syntax does, but I'm not sure if it's a bug in this syntax or the playground. Based on the other syntaxes in PRQL Github repo it seems PRQL is supposed to allow underscore separators like this.

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.

Good catch. PRQL does support underscores in numbers but it appears not in hex notation though it arguably should. I would like to leave it in here for future compatibility.

Comment thread runtime/syntax/prql.yaml Outdated
Comment thread runtime/syntax/prql.yaml Outdated
Comment thread runtime/syntax/prql.yaml Outdated
Comment thread runtime/syntax/prql.yaml Outdated
Comment thread runtime/syntax/prql.yaml Outdated
vanillajonathan and others added 5 commits July 1, 2025 16:47
Co-authored-by: Mikko <Andriamanitra@users.noreply.github.com>
Co-authored-by: Mikko <Andriamanitra@users.noreply.github.com>
Co-authored-by: Mikko <Andriamanitra@users.noreply.github.com>
Co-authored-by: Mikko <Andriamanitra@users.noreply.github.com>
@vanillajonathan

Copy link
Copy Markdown
Contributor Author

@Andriamanitra so it basically handles it the same way as Python and the syntax file for Python doesn't put too much effort into handling the various different types of strings and quotations.

@Andriamanitra

Copy link
Copy Markdown
Contributor

@Andriamanitra so it basically handles it the same way as Python and the syntax file for Python doesn't put too much effort into handling the various different types of strings and quotations.

Python does handle triple quoted strings separately (and Python doesn't have syntax for arbitrary numbers of quotes) https://github.com/zyedidia/micro/blob/41b912b5392ff80c1cce7d0ef7668f406977cc00/runtime/syntax/python3.yaml#L34-L40

As another example in Rust which allows arbitrary but matching number of # characters on either side of raw strings we hard-coded cases up to 4: https://github.com/zyedidia/micro/blob/41b912b5392ff80c1cce7d0ef7668f406977cc00/runtime/syntax/rust.yaml#L31-L45

@vanillajonathan

Copy link
Copy Markdown
Contributor Author

But do we need to handle triple quoted strings considering that first quote opens the string, followed by the second quote closes the the string, followed by the third quote which opens the quote?

@Andriamanitra

Copy link
Copy Markdown
Contributor

But do we need to handle triple quoted strings considering that first quote opens the string, followed by the second quote closes the the string, followed by the third quote which opens the quote?

If we don't then having a single quote inside the triple quoted string will mess up highlighting for the rest of the file. I think it's worth it.

@vanillajonathan

Copy link
Copy Markdown
Contributor Author

@dmaluka Okay Andriamanitra has reviewed and approved this.

@dmaluka dmaluka merged commit cf92f77 into micro-editor:master Jul 8, 2025
@vanillajonathan vanillajonathan deleted the patch-1 branch July 8, 2025 13:15
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