From 4eaa314d330880ff63db25e0a90fc042b4a80afc Mon Sep 17 00:00:00 2001 From: Erasin Date: Fri, 9 Sep 2022 15:37:19 +0800 Subject: [PATCH 1/2] Add textobject for gdscript - Add textobjects.scm - Fix class highlight - Fix set default indent to `\t` --- book/src/generated/lang-support.md | 2 +- languages.toml | 2 +- runtime/queries/gdscript/highlights.scm | 5 +++++ runtime/queries/gdscript/textobjects.scm | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 runtime/queries/gdscript/textobjects.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index ca7c12481b4a..a803933aa780 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -29,7 +29,7 @@ | esdl | ✓ | | | | | fish | ✓ | ✓ | ✓ | | | fortran | ✓ | | ✓ | `fortls` | -| gdscript | ✓ | | | | +| gdscript | ✓ | ✓ | | | | git-attributes | ✓ | | | | | git-commit | ✓ | | | | | git-config | ✓ | | | | diff --git a/languages.toml b/languages.toml index 15fbe7fb15ed..2ec392da1d93 100644 --- a/languages.toml +++ b/languages.toml @@ -1327,7 +1327,7 @@ shebangs = [] roots = ["project.godot"] auto-format = true comment-token = "#" -indent = { tab-width = 4, unit = " " } +indent = { tab-width = 4, unit = "\t" } [[grammar]] name = "gdscript" diff --git a/runtime/queries/gdscript/highlights.scm b/runtime/queries/gdscript/highlights.scm index 0849eedb0719..f36f4e35c15f 100644 --- a/runtime/queries/gdscript/highlights.scm +++ b/runtime/queries/gdscript/highlights.scm @@ -3,6 +3,11 @@ ((identifier) @constant (#match? @constant "^[A-Z][A-Z_]*$")) +; class +(class_name_statement (name) @type) +(class_definition (name) @type) + + ; Function calls (attribute_call (identifier) @function) diff --git a/runtime/queries/gdscript/textobjects.scm b/runtime/queries/gdscript/textobjects.scm new file mode 100644 index 000000000000..f5a1cdeb70c0 --- /dev/null +++ b/runtime/queries/gdscript/textobjects.scm @@ -0,0 +1,14 @@ + +(class_definition + (body) @class.inside) @class.around + +(function_definition + (body) @function.inside) @function.around + +(parameters + (typed_parameter + (identifier) @parameter.inside + ) @parameter.around) + +(comment) @comment.inside +(comment)+ @comment.around From 16f276530e5d09b92240e166a8a8076b8e890752 Mon Sep 17 00:00:00 2001 From: Erasin Date: Sat, 10 Sep 2022 11:47:34 +0800 Subject: [PATCH 2/2] cover parameter --- runtime/queries/gdscript/textobjects.scm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/runtime/queries/gdscript/textobjects.scm b/runtime/queries/gdscript/textobjects.scm index f5a1cdeb70c0..089544682978 100644 --- a/runtime/queries/gdscript/textobjects.scm +++ b/runtime/queries/gdscript/textobjects.scm @@ -5,10 +5,13 @@ (function_definition (body) @function.inside) @function.around -(parameters - (typed_parameter - (identifier) @parameter.inside - ) @parameter.around) +(parameters + [ + (identifier) + (typed_parameter) + (default_parameter) + (typed_default_parameter) + ] @parameter.inside @parameter.around) (comment) @comment.inside (comment)+ @comment.around