on master help sign in
Add QML language support (#4842)

Fixes https://github.com/helix-editor/helix/issues/2771

commit26ec1cf39a3c5f548f199918b0a84d614a5c6be7 authoralois31 <36605164+alois31@users.noreply.github.com> dateWed 23 Nov 2022, 04:49 (4 years ago) parent42e37a5
5 files changed+126
book/src/generated/lang-support.md+1 languages.toml+13 runtime/queries/qml/highlights.scm+90 runtime/queries/qml/indents.scm+6 runtime/queries/qml/injections.scm+16
book/src/generated/lang-support.md+1
@@ -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+13
@@ -1980,3 +1980,16 @@ language-server = { command = "bicep-langserver" }
19801980[[grammar]]
19811981name = "bicep"
19821982source = { 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.scmnew file+90
@@ -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.scmnew file+6
@@ -0,0 +1,6 @@
1+[
2+ (enum_body)
3+ (ui_object_initializer)
4+] @indent
5+
6+"}" @outdent
runtime/queries/qml/injections.scmnew file+16
@@ -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"))