Skip to content

Commit 5632195

Browse files
alois31Shekhinah Memmel
authored andcommitted
Add QML language support (helix-editor#4842)
Fixes helix-editor#2771
1 parent 80327ae commit 5632195

File tree

5 files changed

+126
-0
lines changed

5 files changed

+126
-0
lines changed

book/src/generated/lang-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
| protobuf || || |
9494
| purescript || | | `purescript-language-server` |
9595
| python |||| `pylsp` |
96+
| qml || || `qmlls` |
9697
| r || | | `R` |
9798
| racket | | | | `racket` |
9899
| regex || | | |

languages.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,3 +1980,16 @@ language-server = { command = "bicep-langserver" }
19801980
[[grammar]]
19811981
name = "bicep"
19821982
source = { git = "https://github.com/the-mikedavis/tree-sitter-bicep", rev = "d8e097fcfa143854861ef737161163a09cc2916b" }
1983+
1984+
[[language]]
1985+
name = "qml"
1986+
scope = "source.qml"
1987+
file-types = ["qml"]
1988+
roots = []
1989+
language-server = { command = "qmlls" }
1990+
indent = { tab-width = 4, unit = " " }
1991+
grammar = "qmljs"
1992+
1993+
[[grammar]]
1994+
name = "qmljs"
1995+
source = { git = "https://github.com/yuja/tree-sitter-qmljs", rev = "0b2b25bcaa7d4925d5f0dda16f6a99c588a437f1" }

runtime/queries/qml/highlights.scm

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
(comment) @comment
2+
3+
(ui_import
4+
source: _ @namespace
5+
version: _? @constant
6+
alias: _? @namespace)
7+
8+
(ui_pragma
9+
name: (identifier) @attribute
10+
value: (identifier)? @constant)
11+
12+
(ui_annotation
13+
"@" @punctuation
14+
type_name: _ @type)
15+
16+
;;; Declarations
17+
18+
(enum_declaration
19+
name: (identifier) @type)
20+
21+
(enum_assignment
22+
name: (identifier) @constant
23+
value: _ @constant)
24+
25+
(enum_body
26+
name: (identifier) @constant)
27+
28+
(ui_inline_component
29+
name: (identifier) @type)
30+
31+
(ui_object_definition
32+
type_name: _ @type)
33+
34+
(ui_object_definition_binding
35+
type_name: _ @type
36+
name: _ @variable.other.member)
37+
38+
(ui_property
39+
type: _ @type
40+
name: (identifier) @variable.other.member)
41+
42+
(ui_signal
43+
name: (identifier) @function)
44+
45+
(ui_signal_parameter
46+
name: (identifier) @variable.parameter
47+
type: _ @type)
48+
49+
(ui_signal_parameter
50+
type: _ @type
51+
name: (identifier) @variable.parameter);;; Properties and bindings
52+
53+
;;; Bindings
54+
55+
(ui_binding
56+
name: _ @variable.other.member)
57+
58+
;;; Other
59+
60+
[
61+
"("
62+
")"
63+
"{"
64+
"}"
65+
] @punctuation.bracket
66+
67+
(ui_list_property_type [
68+
"<"
69+
">"
70+
] @punctuation.bracket)
71+
72+
[
73+
","
74+
"."
75+
":"
76+
] @punctuation.delimiter
77+
78+
[
79+
"as"
80+
"component"
81+
"default"
82+
"enum"
83+
"import"
84+
"on"
85+
"pragma"
86+
"property"
87+
"readonly"
88+
"required"
89+
"signal"
90+
] @keyword

runtime/queries/qml/indents.scm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
(enum_body)
3+
(ui_object_initializer)
4+
] @indent
5+
6+
"}" @outdent

runtime/queries/qml/injections.scm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
((comment) @injection.content
2+
(#set! injection.language "comment"))
3+
4+
([
5+
(empty_statement)
6+
(expression_statement)
7+
(function_declaration)
8+
(generator_function_declaration)
9+
(statement_block)
10+
(switch_statement)
11+
(try_statement)
12+
(variable_declaration)
13+
(with_statement)
14+
] @injection.content
15+
(#set! injection.include-children)
16+
(#set! injection.language "javascript"))

0 commit comments

Comments
 (0)