Skip to content

Comments

Add QML syntax to editor#5022

Open
eugenesan wants to merge 1 commit intoMidnightCommander:masterfrom
eugenesan:pr-qml
Open

Add QML syntax to editor#5022
eugenesan wants to merge 1 commit intoMidnightCommander:masterfrom
eugenesan:pr-qml

Conversation

@eugenesan
Copy link

Proposed changes

  • Adds support for QML (Qt declarative meta lang)

Checklist

  • [N/A] I have referenced the issue(s) resolved by this PR (if any)
  • [V] I have signed-off my contribution with git commit --amend -s
  • [N/A] Lint and unit tests pass locally with my changes (make indent && make check)
  • [N/A] I have added tests that prove my fix is effective or that my feature works
  • [N/A ] I have added the necessary documentation (if appropriate)

Discussion

Currently QML was added as a standalone syntax file.
I'd like to hear opinions if instead it should be added to existing JavaScript syntax (js.syntax) as they share ~70% of syntax and QML can contains JavaScript code.

Signed-off-by: Eugene San (eugenesan) <eugenesan@gmail.com>
@github-actions github-actions bot added the needs triage Needs triage by maintainers label Feb 20, 2026
@github-actions github-actions bot added this to the Future Releases milestone Feb 20, 2026
@github-actions github-actions bot added the prio: medium Has the potential to affect progress label Feb 20, 2026
@zyv
Copy link
Member

zyv commented Feb 20, 2026

I'd like to hear opinions if instead it should be added to existing JavaScript syntax (js.syntax) as they share ~70% of syntax and QML can contains JavaScript code.

I don't think that QML should be added to the JavaScript syntax. As far as I understand, QML files can contain JavaScript, but the opposite is not true: QML is not valid JavaScript.

However, I think that you can include other syntax files in your syntax. So if the overlap is extremely high, you might have luck organizing the files in such a way that a common section is included in both, or one is included in another.

@eugenesan
Copy link
Author

eugenesan commented Feb 20, 2026

I don't think that QML should be added to the JavaScript syntax. As far as I understand, QML files can contain JavaScript, but the opposite is not true: QML is not valid JavaScript.

I agree.

However, I think that you can include other syntax files in your syntax. So if the overlap is extremely high, you might have luck organizing the files in such a way that a common section is included in both, or one is included in another.

I tried "concatenation" using double include in Syntax and including from inside .syntax and this approach didn't work (Load syntax file: Error in file .../qml.syntax on line 130). Seems like currently the parser can handle default context only once and only at the beginning of the file.

Seems like unless someone reworks syntax loading in editor we'll have to deal with duplication across syntax files.

@zyv
Copy link
Member

zyv commented Feb 21, 2026

However, I think that you can include other syntax files in your syntax. So if the overlap is extremely high, you might have luck organizing the files in such a way that a common section is included in both, or one is included in another.

I tried "concatenation" using double include in Syntax and including from inside .syntax and this approach didn't work (Load syntax file: Error in file .../qml.syntax on line 130). Seems like currently the parser can handle default context only once and only at the beginning of the file.

Seems like unless someone reworks syntax loading in editor we'll have to deal with duplication across syntax files.

Yes, but can't you split it into 3 files like js.syntax, qml.syntax, and common-js-qml.syntax or something like this even with the current parser?

@ossilator
Copy link
Contributor

preferably, js-common.syntax. there shouldn't be anything qml-specific in it.

more broadly, #2931 seems relevant once again. if only because dedicated highlighter libraries usually come with a sizable collection of syntax definitions.

@eugenesan
Copy link
Author

Unfortunately (unless I am missing something), it won't be possible to use common syntax file unless we want to cram "default context" of JS related languages into common and have them all use it.
Also, I've stopped investigating at "default context" level but other contexts might have the same limitations...

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

Labels

needs triage Needs triage by maintainers prio: medium Has the potential to affect progress

Development

Successfully merging this pull request may close these issues.

3 participants