diff options
| author | Amaan Qureshi <amaanq12@gmail.com> | 2023-03-12 06:09:35 -0400 |
|---|---|---|
| committer | Amaan Qureshi <amaanq12@gmail.com> | 2023-03-13 05:24:58 -0400 |
| commit | 3eae9ded42f14636875a89dcd57c719eddbf99c4 (patch) | |
| tree | 6a2578bd9a8d80f604952789934e283e7a9eac64 /queries/thrift | |
| parent | docs: consistent in README (diff) | |
| download | nvim-treesitter-3eae9ded42f14636875a89dcd57c719eddbf99c4.tar nvim-treesitter-3eae9ded42f14636875a89dcd57c719eddbf99c4.tar.gz nvim-treesitter-3eae9ded42f14636875a89dcd57c719eddbf99c4.tar.bz2 nvim-treesitter-3eae9ded42f14636875a89dcd57c719eddbf99c4.tar.lz nvim-treesitter-3eae9ded42f14636875a89dcd57c719eddbf99c4.tar.xz nvim-treesitter-3eae9ded42f14636875a89dcd57c719eddbf99c4.tar.zst nvim-treesitter-3eae9ded42f14636875a89dcd57c719eddbf99c4.zip | |
feat(thrift): update queries based on upstream changes
Diffstat (limited to 'queries/thrift')
| -rw-r--r-- | queries/thrift/folds.scm | 16 | ||||
| -rw-r--r-- | queries/thrift/highlights.scm | 172 | ||||
| -rw-r--r-- | queries/thrift/indents.scm | 11 | ||||
| -rw-r--r-- | queries/thrift/locals.scm | 61 |
4 files changed, 148 insertions, 112 deletions
diff --git a/queries/thrift/folds.scm b/queries/thrift/folds.scm index 0e0a845a8..1361be1f8 100644 --- a/queries/thrift/folds.scm +++ b/queries/thrift/folds.scm @@ -1,12 +1,12 @@ [ - (annotation) - (enum) - (exception) - (function) - (senum) - (service) - (struct) - (union) + (annotation_definition) + (enum_definition) + (exception_definition) + (function_definition) + (senum_definition) + (service_definition) + (struct_definition) + (union_definition) (comment) ] @fold diff --git a/queries/thrift/highlights.scm b/queries/thrift/highlights.scm index adf147d9d..2b4778722 100644 --- a/queries/thrift/highlights.scm +++ b/queries/thrift/highlights.scm @@ -1,6 +1,7 @@ - ; Namespace +; Variables -(namespace_definition) @namespace +((identifier) @variable + (#set! "priority" 95)) ; Includes @@ -9,96 +10,118 @@ "cpp_include" ] @include -(include_path) @string -(package_path) @string +; Function -; Builtins +(function_definition + (identifier) @function) -(primitive) @type.builtin +; Fields -[ - "list" - "map" - "set" - "sink" - "stream" - "void" -] @type.builtin +(field (identifier) @field) -; Function +; Parameters -(function_identifier) @function +(function_definition + (parameters + (parameter (identifier) @parameter))) -; Fields +(throws + (parameters + (parameter (identifier) @parameter))) -(field_identifier) @field +; Types -; Parameters +(typedef_identifier) @type +(struct_definition + "struct" (identifier) @type) -(param_identifier) @parameter -(exception_param_identifier) @parameter +(union_definition + "union" (identifier) @type) -; Variables +(exception_definition + "exception" (identifier) @type) + +(service_definition + "service" (identifier) @type) + +(interaction_definition + "interaction" (identifier) @type) -(identifier) @variable +(type + type: (identifier) @type) + +(definition_type + type: (identifier) @type) + +((identifier) @type + (#lua-match? @type "^[_]*[A-Z]")) ; Constants -(const_identifier) @constant -(enum_member) @constant +(const_definition (identifier) @constant) +((identifier) @constant + (#lua-match? @constant "^[_A-Z][A-Z0-9_]*$")) +(enum_definition "enum" + . (identifier) @type + "{" (identifier) @constant "}") -; Types +; Builtin Types -(enum_identifier) @type -(definition_type) @type -(exception_identifier) @type -(exception_param_type) @type -(field_type) @type -(param_type) @type -(type_identifier) @type +(primitive) @type.builtin + +[ + "list" + "map" + "set" + "sink" + "stream" + "void" +] @type.builtin + +; Namespace + +(namespace_declaration + (namespace_scope) @tag + [(namespace) @namespace (_ (identifier) @namespace)]) ; Attributes -(annotation_identifier) @attribute -(uri_def) @attribute +(annotation_definition + (annotation_identifier (identifier) @attribute)) +(fb_annotation_definition + "@" @attribute (annotation_identifier (identifier) @attribute) + (identifier)? @attribute) +(namespace_uri (string) @attribute) ; Operators [ - "=" - "+" - "-" + "=" + "&" ] @operator ; Exceptions [ - "throws" + "throws" ] @exception ; Keywords [ - "cpp_include" "enum" "exception" "extends" - "include" "interaction" "namespace" - "optional" - "required" "senum" "service" "struct" "typedef" "union" + "uri" ] @keyword -[ - "oneway" -] @keyword.coroutine - ; Deprecated Keywords [ @@ -120,35 +143,41 @@ "xsd_optional" ] @keyword +; Extended Kewords +[ + "package" + "performs" +] @keyword + [ "async" + "oneway" ] @keyword.coroutine -; Extended Keywords +; Qualifiers [ "client" + "const" "idempotent" - "package" - "performs" + "optional" "permanent" "readonly" - "server" + "required" "safe" + "server" "stateful" "transient" -] @keyword +] @type.qualifier ; Literals -[ - (annotation_value) - (string) -] @string +(string) @string (escape_sequence) @string.escape -(uri (string_fragment) @text.uri) @string.special +(namespace_uri + (string) @text.uri @string.special) (number) @number @@ -158,24 +187,12 @@ ; Typedefs -(typedef_definition) @type.definition -(namespace_scope) @type.definition - -; Qualifiers - -[ - "const" - (exception_modifier) - (field_modifier) - (function_modifier) -] @type.qualifier +(typedef_identifier) @type.definition ; Punctuation [ "*" - "&" - "@" ] @punctuation.special ["{" "}"] @punctuation.bracket @@ -187,14 +204,12 @@ ["<" ">"] @punctuation.bracket [ - ";" + "." "," + ";" + ":" ] @punctuation.delimiter -; Errors - -(invalid) @error - ; Comments (comment) @comment @spell @@ -206,3 +221,10 @@ (#lua-match? @comment.documentation "^///[^/]")) ((comment) @comment.documentation (#lua-match? @comment.documentation "^///$")) + +((comment) @preproc + (#lua-match? @preproc "#!.*")) + +; Errors + +(ERROR) @error diff --git a/queries/thrift/indents.scm b/queries/thrift/indents.scm index 9a5e0455d..768ff795d 100644 --- a/queries/thrift/indents.scm +++ b/queries/thrift/indents.scm @@ -1,11 +1,6 @@ (definition) @indent -; (function (function_identifier) @aligned_indent) - -((function_parameters (function_parameter)) @aligned_indent - (#set! "delimiter" "()")) - -((exception_parameters (exception_parameter)) @aligned_indent +((parameters (parameter)) @aligned_indent (#set! "delimiter" "()")) "}" @indent_end @@ -15,6 +10,6 @@ [ "(" ")" ] @branch [ - (ERROR) - (comment) + (ERROR) + (comment) ] @auto diff --git a/queries/thrift/locals.scm b/queries/thrift/locals.scm index 2275ed9b8..d95cc5da1 100644 --- a/queries/thrift/locals.scm +++ b/queries/thrift/locals.scm @@ -1,32 +1,51 @@ -(document) @scope -(definition) @scope +; Scopes [ - (identifier) - (field_type) - (custom_type) -] @reference -(const_value (const_identifier) @reference) + (document) + (definition) +] @scope + +; References + +(identifier) @reference + +; Definitions (annotation_identifier) @definition -(const (const_identifier) @definition.constant) -(enum_member) @definition.constant +(const_definition (identifier) @definition.constant) -(enum_identifier) @definition.enum +(enum_definition "enum" + . (identifier) @definition.enum + "{" (identifier) @definition.constant "}") -(field_identifier) @definition.field +(senum_definition "senum" + . (identifier) @definition.enum) -(function_identifier) @definition.function +(field (identifier) @definition.field) -(namespace_definition) @definition.namespace +(function_definition (identifier) @definition.function) -[ - (param_identifier) - (exception_param_identifier) -] @definition.parameter +(namespace_declaration + "namespace" (namespace_scope) + . (_) @definition.namespace + (namespace_uri)?) -[ - (type_identifier) - (exception_identifier) -] @definition.type +(parameter (identifier) @definition.parameter) + +(struct_definition + "struct" . (identifier) @definition.type) + +(union_definition + "union" . (identifier) @definition.type) + +(exception_definition + "exception" . (identifier) @definition.type) + +(service_definition + "service" . (identifier) @definition.type) + +(interaction_definition + "interaction" . (identifier) @definition.type) + +(typedef_identifier) @definition.type |
