Skip to content

Commit

Permalink
Add slint-ui support
Browse files Browse the repository at this point in the history
  • Loading branch information
erasin authored and the-mikedavis committed Aug 8, 2022
1 parent 3e11017 commit f09d2bc
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 0 deletions.
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
| scala || || `metals` |
| scheme || | | |
| scss || | | `vscode-css-language-server` |
| slint || || `slint-lsp` |
| solidity || | | `solc` |
| sql || | | |
| sshclientconfig || | | |
Expand Down
14 changes: 14 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1613,3 +1613,17 @@ indent = { tab-width = 4, unit = "\t" }
[[grammar]]
name = "cue"
source = { git = "https://github.com/eonpatapon/tree-sitter-cue", rev = "61843e3beebf19417e4fede4e8be4df1084317ad" }

[[language]]
name = "slint"
scope = "source.slint"
injection-regex = "slint"
file-types = ["slint"]
roots = []
comment-token = "//"
indent = { tab-width = 4, unit = " " }
language-server = { command = "slint-lsp", args = [] }

[[grammar]]
name = "slint"
source = { git = "https://github.com/jrmoulton/tree-sitter-slint", rev = "0d4dda94f96623302dfc234e06be62a5717f47da" }
125 changes: 125 additions & 0 deletions runtime/queries/slint/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@

(user_type_identifier) @type

(var_identifier) @variable

(state_identifier) @variable.other.member

(var_identifier
(post_identifier) @variable)

(function_identifier) @function

(reference_identifier) @keyword.storage.modifier.ref
(visibility_modifier) @keyword.storage.modifier

(comment) @comment

(string) @string
(int_number) @constant.numeric
(unit_type) @type.builtin

[
"struct"
"property"
"callback"
"import"
"from"
"root"
"parent"
"this"
"for"
"in"
"if"
"else if"
"else"
"animate"
"states"
"when"
"in"
"out"
"transitions"
"global"
] @keyword

[
"black"
"transparent"
"blue"
"ease"
"ease_in"
"ease-in"
"ease_in_out"
"ease-in-out"
"ease_out"
"ease-out"
"end"
"green"
"red"
"red"
"start"
"yellow"
"true"
"false"
] @constant.builtin

"@" @keyword

; ; Punctuation
[
","
"."
] @punctuation.delimiter

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

[
"angle"
"bool"
"brush"
; "color" // This causes problems
"duration"
"easing"
"float"
"image"
"int"
"length"
"percent"
"physical-length"
"physical_length"
"string"
] @type.builtin

[
":="
"!"
"-"
"+"
"*"
"/"
"&&"
"||"
">"
"<"
">="
"<="
"="
":"
"+="
"-="
"*="
"/="
"?"

"=>"
] @operator

(ternary_expression [":" "?"] @keyword.control.conditional)
29 changes: 29 additions & 0 deletions runtime/queries/slint/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

; [
; (struct_definition)
; (component_definition)
; ] @indent

[
(field_declaration_list_body)
(list_definition_body)
(struct_field_declaration_list_body)
] @indent

; [
; "{"
; "}"
; "("
; ")"
; (if_statement)
; "else if"
; "else"
; ] @branch

; "{" @indent
"}" @indent_end

(comment) @auto

(string) @auto

3 changes: 3 additions & 0 deletions runtime/queries/slint/locals.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
; locals.scm

(component_definition) @local.scope

0 comments on commit f09d2bc

Please sign in to comment.