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

Add QML language support #4842

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
| protobuf | ✓ | | ✓ | |
| purescript | ✓ | | | `purescript-language-server` |
| python | ✓ | ✓ | ✓ | `pylsp` |
| qml | ✓ | | ✓ | `qmlls` |
| r | ✓ | | | `R` |
| racket | | | | `racket` |
| regex | ✓ | | | |
Expand Down
13 changes: 13 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1980,3 +1980,16 @@ language-server = { command = "bicep-langserver" }
[[grammar]]
name = "bicep"
source = { git = "https://github.com/the-mikedavis/tree-sitter-bicep", rev = "d8e097fcfa143854861ef737161163a09cc2916b" }

[[language]]
name = "qml"
scope = "source.qml"
file-types = ["qml"]
roots = []
language-server = { command = "qmlls" }
indent = { tab-width = 4, unit = " " }
grammar = "qmljs"

[[grammar]]
name = "qmljs"
source = { git = "https://github.com/yuja/tree-sitter-qmljs", rev = "0b2b25bcaa7d4925d5f0dda16f6a99c588a437f1" }
90 changes: 90 additions & 0 deletions runtime/queries/qml/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
(comment) @comment

(ui_import
source: _ @namespace
version: _? @constant
alias: _? @namespace)

(ui_pragma
name: (identifier) @attribute
value: (identifier)? @constant)

(ui_annotation
"@" @punctuation
type_name: _ @type)

;;; Declarations

(enum_declaration
name: (identifier) @type)

(enum_assignment
name: (identifier) @constant
value: _ @constant)

(enum_body
name: (identifier) @constant)

(ui_inline_component
name: (identifier) @type)

(ui_object_definition
type_name: _ @type)

(ui_object_definition_binding
type_name: _ @type
name: _ @variable.other.member)

(ui_property
type: _ @type
name: (identifier) @variable.other.member)

(ui_signal
name: (identifier) @function)

(ui_signal_parameter
name: (identifier) @variable.parameter
type: _ @type)

(ui_signal_parameter
type: _ @type
name: (identifier) @variable.parameter);;; Properties and bindings

;;; Bindings

(ui_binding
name: _ @variable.other.member)

;;; Other

[
"("
")"
"{"
"}"
] @punctuation.bracket

(ui_list_property_type [
"<"
">"
] @punctuation.bracket)

[
","
"."
":"
] @punctuation.delimiter

[
"as"
"component"
"default"
"enum"
"import"
"on"
"pragma"
"property"
"readonly"
"required"
"signal"
] @keyword
6 changes: 6 additions & 0 deletions runtime/queries/qml/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
(enum_body)
(ui_object_initializer)
] @indent

"}" @outdent
16 changes: 16 additions & 0 deletions runtime/queries/qml/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
((comment) @injection.content
(#set! injection.language "comment"))

([
(empty_statement)
(expression_statement)
(function_declaration)
(generator_function_declaration)
(statement_block)
(switch_statement)
(try_statement)
(variable_declaration)
(with_statement)
] @injection.content
(#set! injection.include-children)
(#set! injection.language "javascript"))