From 67334f80d49512cec149e2477bd448ebb1b76bed Mon Sep 17 00:00:00 2001 From: Erasin Date: Mon, 8 Aug 2022 18:04:18 +0800 Subject: [PATCH 1/2] Add slint-ui support lsp: tree-sitter-slint: --- book/src/generated/lang-support.md | 1 + languages.toml | 14 +++ runtime/queries/slint/highlights.scm | 125 +++++++++++++++++++++++++++ runtime/queries/slint/indents.scm | 29 +++++++ runtime/queries/slint/locals.scm | 3 + 5 files changed, 172 insertions(+) create mode 100644 runtime/queries/slint/highlights.scm create mode 100644 runtime/queries/slint/indents.scm create mode 100644 runtime/queries/slint/locals.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index a33b5acc3324..a79f79f024db 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -90,6 +90,7 @@ | scala | ✓ | | ✓ | `metals` | | scheme | ✓ | | | | | scss | ✓ | | | `vscode-css-language-server` | +| slint | ✓ | | ✓ | `slint-lsp` | | solidity | ✓ | | | `solc` | | sql | ✓ | | | | | sshclientconfig | ✓ | | | | diff --git a/languages.toml b/languages.toml index 7947104bd5f7..287d45348523 100644 --- a/languages.toml +++ b/languages.toml @@ -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" } diff --git a/runtime/queries/slint/highlights.scm b/runtime/queries/slint/highlights.scm new file mode 100644 index 000000000000..c7773913d4ba --- /dev/null +++ b/runtime/queries/slint/highlights.scm @@ -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) \ No newline at end of file diff --git a/runtime/queries/slint/indents.scm b/runtime/queries/slint/indents.scm new file mode 100644 index 000000000000..253b9c489f8f --- /dev/null +++ b/runtime/queries/slint/indents.scm @@ -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 + diff --git a/runtime/queries/slint/locals.scm b/runtime/queries/slint/locals.scm new file mode 100644 index 000000000000..feba5ebb05fc --- /dev/null +++ b/runtime/queries/slint/locals.scm @@ -0,0 +1,3 @@ +; locals.scm + +(component_definition) @local.scope From 4fe8f8b56fb621d0324ddd63143b8ef5e9000bf8 Mon Sep 17 00:00:00 2001 From: Erasin Date: Mon, 8 Aug 2022 18:12:58 +0800 Subject: [PATCH 2/2] slint indents --- runtime/queries/slint/indents.scm | 34 ++++++++----------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/runtime/queries/slint/indents.scm b/runtime/queries/slint/indents.scm index 253b9c489f8f..37bbd5360b85 100644 --- a/runtime/queries/slint/indents.scm +++ b/runtime/queries/slint/indents.scm @@ -1,29 +1,11 @@ - -; [ -; (struct_definition) -; (component_definition) -; ] @indent - [ -(field_declaration_list_body) -(list_definition_body) -(struct_field_declaration_list_body) + (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 - +[ + "}" + "]" + ")" +] @outdent