aboutsummaryrefslogtreecommitdiffstats
path: root/queries/bitbake
diff options
context:
space:
mode:
authorPham Huy Hoang <hoangtun0810@gmail.com>2024-01-06 15:05:50 +0900
committerChristian Clason <c.clason@uni-graz.at>2024-01-19 16:58:37 +0100
commit57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9 (patch)
tree70bf645539882b88e6fa129cefd30986b89bbac3 /queries/bitbake
parentci: add query lint job (diff)
downloadnvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar
nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.gz
nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.bz2
nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.lz
nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.xz
nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.zst
nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.zip
chore: query formatting
Diffstat (limited to 'queries/bitbake')
-rw-r--r--queries/bitbake/folds.scm5
-rw-r--r--queries/bitbake/highlights.scm190
-rw-r--r--queries/bitbake/indents.scm132
-rw-r--r--queries/bitbake/injections.scm13
-rw-r--r--queries/bitbake/locals.scm80
5 files changed, 273 insertions, 147 deletions
diff --git a/queries/bitbake/folds.scm b/queries/bitbake/folds.scm
index 9fc865e84..85d226348 100644
--- a/queries/bitbake/folds.scm
+++ b/queries/bitbake/folds.scm
@@ -2,28 +2,23 @@
(function_definition)
(anonymous_python_function)
(python_function_definition)
-
(while_statement)
(for_statement)
(if_statement)
(with_statement)
(try_statement)
-
(import_from_statement)
(parameters)
(argument_list)
-
(parenthesized_expression)
(generator_expression)
(list_comprehension)
(set_comprehension)
(dictionary_comprehension)
-
(tuple)
(list)
(set)
(dictionary)
-
(string)
(python_string)
] @fold
diff --git a/queries/bitbake/highlights.scm b/queries/bitbake/highlights.scm
index eafe60b4d..e555e40d7 100644
--- a/queries/bitbake/highlights.scm
+++ b/queries/bitbake/highlights.scm
@@ -1,5 +1,4 @@
; Includes
-
[
"inherit"
"include"
@@ -9,12 +8,10 @@
] @keyword.import
; Keywords
-
[
"unset"
"EXPORT_FUNCTIONS"
"python"
-
"assert"
"exec"
"global"
@@ -34,19 +31,34 @@
"return"
"yield"
] @keyword.return
-(yield "from" @keyword.return)
+
+(yield
+ "from" @keyword.return)
(future_import_statement
"from" @keyword.import
"__future__" @constant.builtin)
-(import_from_statement "from" @keyword.import)
+
+(import_from_statement
+ "from" @keyword.import)
+
"import" @keyword.import
-(aliased_import "as" @keyword.import)
+(aliased_import
+ "as" @keyword.import)
-["if" "elif" "else"] @keyword.conditional
+[
+ "if"
+ "elif"
+ "else"
+] @keyword.conditional
-["for" "while" "break" "continue"] @keyword.repeat
+[
+ "for"
+ "while"
+ "break"
+ "continue"
+] @keyword.repeat
[
"try"
@@ -56,7 +68,8 @@
"finally"
] @keyword.exception
-(raise_statement "from" @keyword.exception)
+(raise_statement
+ "from" @keyword.exception)
(try_statement
(else_clause
@@ -82,7 +95,6 @@
] @type.qualifier
; Variables
-
[
(identifier)
(python_identifier)
@@ -99,14 +111,18 @@
; Reset highlighting in f-string interpolations
(interpolation) @none
-;; Identifier naming conventions
+; Identifier naming conventions
((python_identifier) @type
- (#lua-match? @type "^[A-Z].*[a-z]"))
-([(identifier) (python_identifier)] @constant
- (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @type "^[A-Z].*[a-z]"))
+
+([
+ (identifier)
+ (python_identifier)
+] @constant
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
((python_identifier) @constant.builtin
- (#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
+ (#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
((python_identifier) @constant.builtin
; format-ignore
@@ -117,128 +133,149 @@
((assignment
left: (python_identifier) @type.definition
- (type (python_identifier) @_annotation))
- (#eq? @_annotation "TypeAlias"))
+ (type
+ (python_identifier) @_annotation))
+ (#eq? @_annotation "TypeAlias"))
((assignment
left: (python_identifier) @type.definition
- right: (call
- function: (python_identifier) @_func))
- (#any-of? @_func "TypeVar" "NewType"))
+ right:
+ (call
+ function: (python_identifier) @_func))
+ (#any-of? @_func "TypeVar" "NewType"))
; Fields
-
(flag) @variable.member
((attribute
- attribute: (python_identifier) @variable.member)
- (#lua-match? @variable.member "^[%l_].*$"))
+ attribute: (python_identifier) @variable.member)
+ (#lua-match? @variable.member "^[%l_].*$"))
; Functions
-
(call
function: (python_identifier) @function.call)
(call
- function: (attribute
- attribute: (python_identifier) @function.method.call))
+ function:
+ (attribute
+ attribute: (python_identifier) @function.method.call))
((call
- function: (python_identifier) @constructor)
- (#lua-match? @constructor "^%u"))
+ function: (python_identifier) @constructor)
+ (#lua-match? @constructor "^%u"))
((call
- function: (attribute
- attribute: (python_identifier) @constructor))
- (#lua-match? @constructor "^%u"))
+ function:
+ (attribute
+ attribute: (python_identifier) @constructor))
+ (#lua-match? @constructor "^%u"))
((call
function: (python_identifier) @function.builtin)
- (#any-of? @function.builtin
- "abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" "classmethod"
- "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" "filter" "float" "format"
- "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input" "int" "isinstance" "issubclass"
- "iter" "len" "list" "locals" "map" "max" "memoryview" "min" "next" "object" "oct" "open" "ord" "pow"
- "print" "property" "range" "repr" "reversed" "round" "set" "setattr" "slice" "sorted" "staticmethod" "str"
- "sum" "super" "tuple" "type" "vars" "zip" "__import__"))
+ (#any-of? @function.builtin "abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" "classmethod" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input" "int" "isinstance" "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview" "min" "next" "object" "oct" "open" "ord" "pow" "print" "property" "range" "repr" "reversed" "round" "set" "setattr" "slice" "sorted" "staticmethod" "str" "sum" "super" "tuple" "type" "vars" "zip" "__import__"))
(python_function_definition
name: (python_identifier) @function)
-(type (python_identifier) @type)
+(type
+ (python_identifier) @type)
+
(type
(subscript
(python_identifier) @type)) ; type subscript: Tuple[int]
((call
function: (python_identifier) @_isinstance
- arguments: (argument_list
- (_)
- (python_identifier) @type))
- (#eq? @_isinstance "isinstance"))
+ arguments:
+ (argument_list
+ (_)
+ (python_identifier) @type))
+ (#eq? @_isinstance "isinstance"))
-(anonymous_python_function (identifier) @function)
+(anonymous_python_function
+ (identifier) @function)
-(function_definition (identifier) @function)
+(function_definition
+ (identifier) @function)
-(addtask_statement (identifier) @function)
+(addtask_statement
+ (identifier) @function)
-(deltask_statement (identifier) @function)
+(deltask_statement
+ (identifier) @function)
-(export_functions_statement (identifier) @function)
+(export_functions_statement
+ (identifier) @function)
-(addhandler_statement (identifier) @function)
+(addhandler_statement
+ (identifier) @function)
(python_function_definition
body:
(block
- . (expression_statement (python_string) @string.documentation @spell)))
+ .
+ (expression_statement
+ (python_string) @string.documentation @spell)))
; Namespace
-
(inherit_path) @module
-;; Normal parameters
+; Normal parameters
(parameters
(python_identifier) @variable.parameter)
-;; Lambda parameters
+
+; Lambda parameters
(lambda_parameters
(python_identifier) @variable.parameter)
+
(lambda_parameters
(tuple_pattern
(python_identifier) @variable.parameter))
+
; Default parameters
(keyword_argument
name: (python_identifier) @variable.parameter)
+
; Naming parameters on call-site
(default_parameter
name: (python_identifier) @variable.parameter)
+
(typed_parameter
(python_identifier) @variable.parameter)
+
(typed_default_parameter
(python_identifier) @variable.parameter)
+
; Variadic parameters *args, **kwargs
(parameters
- (list_splat_pattern ; *args
+ (list_splat_pattern
+ ; *args
(python_identifier) @variable.parameter))
+
(parameters
- (dictionary_splat_pattern ; **kwargs
+ (dictionary_splat_pattern
+ ; **kwargs
(python_identifier) @variable.parameter))
-;; Literals
-
+; Literals
(none) @constant.builtin
-[(true) (false)] @boolean
+
+[
+ (true)
+ (false)
+] @boolean
+
((python_identifier) @variable.builtin
- (#eq? @variable.builtin "self"))
+ (#eq? @variable.builtin "self"))
+
((python_identifier) @variable.builtin
- (#eq? @variable.builtin "cls"))
+ (#eq? @variable.builtin "cls"))
(integer) @number
+
(float) @number.float
; Operators
-
[
"?="
"??="
@@ -293,12 +330,10 @@
"or"
"is not"
"not in"
-
"del"
] @keyword.operator
; Literals
-
[
(string)
(python_string)
@@ -313,8 +348,14 @@
] @string.escape
; Punctuation
-
-[ "(" ")" "{" "}" "[" "]" ] @punctuation.bracket
+[
+ "("
+ ")"
+ "{"
+ "}"
+ "["
+ "]"
+] @punctuation.bracket
[
":"
@@ -325,15 +366,28 @@
(ellipsis)
] @punctuation.delimiter
-(variable_expansion [ "${" "}" ] @punctuation.special)
-(inline_python [ "${@" "}" ] @punctuation.special)
+(variable_expansion
+ [
+ "${"
+ "}"
+ ] @punctuation.special)
+
+(inline_python
+ [
+ "${@"
+ "}"
+ ] @punctuation.special)
+
(interpolation
"{" @punctuation.special
"}" @punctuation.special)
(type_conversion) @function.macro
-([(identifier) (python_identifier)] @type.builtin
+([
+ (identifier)
+ (python_identifier)
+] @type.builtin
; format-ignore
(#any-of? @type.builtin
; https://docs.python.org/3/library/exceptions.html
diff --git a/queries/bitbake/indents.scm b/queries/bitbake/indents.scm
index 01d8aeb3c..ee60d0fda 100644
--- a/queries/bitbake/indents.scm
+++ b/queries/bitbake/indents.scm
@@ -1,76 +1,101 @@
[
(import_from_statement)
-
(parenthesized_expression)
(generator_expression)
(list_comprehension)
(set_comprehension)
(dictionary_comprehension)
-
(tuple_pattern)
(list_pattern)
(binary_operator)
-
(lambda)
-
(concatenated_string)
] @indent.begin
((list) @indent.align
- (#set! indent.open_delimiter "[")
- (#set! indent.close_delimiter "]")
-)
+ (#set! indent.open_delimiter "[")
+ (#set! indent.close_delimiter "]"))
+
((dictionary) @indent.align
- (#set! indent.open_delimiter "{")
- (#set! indent.close_delimiter "}")
-)
+ (#set! indent.open_delimiter "{")
+ (#set! indent.close_delimiter "}"))
+
((set) @indent.align
- (#set! indent.open_delimiter "{")
- (#set! indent.close_delimiter "}")
-)
+ (#set! indent.open_delimiter "{")
+ (#set! indent.close_delimiter "}"))
((for_statement) @indent.begin
- (#set! indent.immediate 1))
+ (#set! indent.immediate 1))
+
((if_statement) @indent.begin
- (#set! indent.immediate 1))
+ (#set! indent.immediate 1))
+
((while_statement) @indent.begin
- (#set! indent.immediate 1))
+ (#set! indent.immediate 1))
+
((try_statement) @indent.begin
- (#set! indent.immediate 1))
-(ERROR "try" ":" @indent.begin (#set! indent.immediate 1))
+ (#set! indent.immediate 1))
+
+(ERROR
+ "try"
+ ":" @indent.begin
+ (#set! indent.immediate 1))
+
((python_function_definition) @indent.begin
- (#set! indent.immediate 1))
+ (#set! indent.immediate 1))
+
(function_definition) @indent.begin
+
(anonymous_python_function) @indent.begin
+
((with_statement) @indent.begin
- (#set! indent.immediate 1))
+ (#set! indent.immediate 1))
(if_statement
condition: (parenthesized_expression) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1))
+
(while_statement
condition: (parenthesized_expression) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1))
-(ERROR "(" @indent.align (#set! indent.open_delimiter "(") (#set! indent.close_delimiter ")") . (_))
+(ERROR
+ "(" @indent.align
+ (#set! indent.open_delimiter "(")
+ (#set! indent.close_delimiter ")")
+ .
+ (_))
+
((argument_list) @indent.align
- (#set! indent.open_delimiter "(")
- (#set! indent.close_delimiter ")"))
+ (#set! indent.open_delimiter "(")
+ (#set! indent.close_delimiter ")"))
+
((parameters) @indent.align
- (#set! indent.open_delimiter "(")
- (#set! indent.close_delimiter ")")
- (#set! indent.avoid_last_matching_next 1))
+ (#set! indent.open_delimiter "(")
+ (#set! indent.close_delimiter ")")
+ (#set! indent.avoid_last_matching_next 1))
+
((tuple) @indent.align
- (#set! indent.open_delimiter "(")
- (#set! indent.close_delimiter ")"))
+ (#set! indent.open_delimiter "(")
+ (#set! indent.close_delimiter ")"))
-(ERROR "[" @indent.align (#set! indent.open_delimiter "[") (#set! indent.close_delimiter "]") . (_))
+(ERROR
+ "[" @indent.align
+ (#set! indent.open_delimiter "[")
+ (#set! indent.close_delimiter "]")
+ .
+ (_))
-(ERROR "{" @indent.align (#set! indent.open_delimiter "{") (#set! indent.close_delimiter "}") . (_))
+(ERROR
+ "{" @indent.align
+ (#set! indent.open_delimiter "{")
+ (#set! indent.close_delimiter "}")
+ .
+ (_))
[
(break_statement)
@@ -78,24 +103,43 @@
] @indent.dedent
(ERROR
- (_) @indent.branch ":" .
+ (_) @indent.branch
+ ":"
+ .
(#lua-match? @indent.branch "^else"))
(ERROR
- (_) @indent.branch @indent.dedent ":" .
+ (_) @indent.branch @indent.dedent
+ ":"
+ .
(#lua-match? @indent.branch "^elif"))
-(parenthesized_expression ")" @indent.end)
-(generator_expression ")" @indent.end)
-(list_comprehension "]" @indent.end)
-(set_comprehension "}" @indent.end)
-(dictionary_comprehension "}" @indent.end)
+(parenthesized_expression
+ ")" @indent.end)
+
+(generator_expression
+ ")" @indent.end)
+
+(list_comprehension
+ "]" @indent.end)
+
+(set_comprehension
+ "}" @indent.end)
+
+(dictionary_comprehension
+ "}" @indent.end)
+
+(tuple_pattern
+ ")" @indent.end)
+
+(list_pattern
+ "]" @indent.end)
-(tuple_pattern ")" @indent.end)
-(list_pattern "]" @indent.end)
+(function_definition
+ "}" @indent.end)
-(function_definition "}" @indent.end)
-(anonymous_python_function "}" @indent.end)
+(anonymous_python_function
+ "}" @indent.end)
(return_statement
[
@@ -107,10 +151,12 @@
"}"
"]"
] @indent.end .)
- (attribute
+ (attribute
attribute: (_) @indent.end)
(call
- arguments: (_ ")" @indent.end))
+ arguments:
+ (_
+ ")" @indent.end))
"return" @indent.end
] .)
diff --git a/queries/bitbake/injections.scm b/queries/bitbake/injections.scm
index 819487bc5..39182e838 100644
--- a/queries/bitbake/injections.scm
+++ b/queries/bitbake/injections.scm
@@ -1,8 +1,11 @@
(call
- function: (attribute
- object: (python_identifier) @_re)
- arguments: (argument_list (python_string
- (string_content) @injection.content) @_string)
+ function:
+ (attribute
+ object: (python_identifier) @_re)
+ arguments:
+ (argument_list
+ (python_string
+ (string_content) @injection.content) @_string)
(#eq? @_re "re")
(#lua-match? @_string "^r.*")
(#set! injection.language "regex"))
@@ -11,4 +14,4 @@
(#set! injection.language "bash"))
((comment) @injection.content
- (#set! injection.language "comment"))
+ (#set! injection.language "comment"))
diff --git a/queries/bitbake/locals.scm b/queries/bitbake/locals.scm
index 27e85f02a..0f572584b 100644
--- a/queries/bitbake/locals.scm
+++ b/queries/bitbake/locals.scm
@@ -7,10 +7,16 @@
; Imports
(aliased_import
alias: (python_identifier) @local.definition.import)
+
(import_statement
- name: (dotted_name ((python_identifier) @local.definition.import)))
+ name:
+ (dotted_name
+ ((python_identifier) @local.definition.import)))
+
(import_from_statement
- name: (dotted_name ((python_identifier) @local.definition.import)))
+ name:
+ (dotted_name
+ ((python_identifier) @local.definition.import)))
; Function with parameters, defines parameters
(parameters
@@ -38,58 +44,80 @@
; Function defines function and scope
((python_function_definition
name: (python_identifier) @local.definition.function) @local.scope
- (#set! definition.function.scope "parent"))
+ (#set! definition.function.scope "parent"))
-(function_definition (identifier) @local.definition.function)
+(function_definition
+ (identifier) @local.definition.function)
-(anonymous_python_function (identifier) @local.definition.function)
+(anonymous_python_function
+ (identifier) @local.definition.function)
-;;; Loops
+; Loops
; not a scope!
(for_statement
- left: (pattern_list
- (python_identifier) @local.definition.var))
+ left:
+ (pattern_list
+ (python_identifier) @local.definition.var))
+
(for_statement
- left: (tuple_pattern
- (python_identifier) @local.definition.var))
+ left:
+ (tuple_pattern
+ (python_identifier) @local.definition.var))
+
(for_statement
left: (python_identifier) @local.definition.var)
; not a scope!
;(while_statement) @local.scope
-
; for in list comprehension
(for_in_clause
left: (python_identifier) @local.definition.var)
+
(for_in_clause
- left: (tuple_pattern
- (python_identifier) @local.definition.var))
+ left:
+ (tuple_pattern
+ (python_identifier) @local.definition.var))
+
(for_in_clause
- left: (pattern_list
- (python_identifier) @local.definition.var))
+ left:
+ (pattern_list
+ (python_identifier) @local.definition.var))
(dictionary_comprehension) @local.scope
+
(list_comprehension) @local.scope
-(set_comprehension) @local.scope
-;;; Assignments
+(set_comprehension) @local.scope
+; Assignments
(assignment
- left: (python_identifier) @local.definition.var)
+ left: (python_identifier) @local.definition.var)
(assignment
- left: (pattern_list
- (python_identifier) @local.definition.var))
+ left:
+ (pattern_list
+ (python_identifier) @local.definition.var))
+
(assignment
- left: (tuple_pattern
- (python_identifier) @local.definition.var))
+ left:
+ (tuple_pattern
+ (python_identifier) @local.definition.var))
(assignment
- left: (attribute
- (python_identifier)
- (python_identifier) @local.definition.field))
+ left:
+ (attribute
+ (python_identifier)
+ (python_identifier) @local.definition.field))
-(variable_assignment (identifier) operator: [ "=" "?=" "??=" ":=" ] @local.definition.var)
+(variable_assignment
+ (identifier)
+ operator:
+ [
+ "="
+ "?="
+ "??="
+ ":="
+ ] @local.definition.var)
; Walrus operator x := 1
(named_expression