From 11367488ac512241b61c6896bfd5d5d32e981b14 Mon Sep 17 00:00:00 2001 From: ChrHorn Date: Mon, 1 Aug 2022 23:14:07 +0200 Subject: Improve Python queries, add locals (#3284) --- runtime/queries/python/highlights.scm | 9 ++++++- runtime/queries/python/locals.scm | 44 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 runtime/queries/python/locals.scm (limited to 'runtime/queries') diff --git a/runtime/queries/python/highlights.scm b/runtime/queries/python/highlights.scm index 1c4d62b2..a94d7caf 100644 --- a/runtime/queries/python/highlights.scm +++ b/runtime/queries/python/highlights.scm @@ -1,5 +1,10 @@ +; Imports + (dotted_name (identifier)* @namespace) + +(aliased_import + alias: (identifier) @namespace) ; Builtin functions @@ -55,7 +60,6 @@ (parameters (typed_parameter (identifier) @variable.parameter)) (parameters (default_parameter name: (identifier) @variable.parameter)) (parameters (typed_default_parameter name: (identifier) @variable.parameter)) -(keyword_argument name: (identifier) @variable.parameter) (parameters (list_splat_pattern ; *args @@ -63,6 +67,9 @@ (parameters (dictionary_splat_pattern ; **kwargs (identifier) @variable.parameter)) + +(lambda_parameters + (identifier) @variable.parameter) ; Types diff --git a/runtime/queries/python/locals.scm b/runtime/queries/python/locals.scm new file mode 100644 index 00000000..f7d5937e --- /dev/null +++ b/runtime/queries/python/locals.scm @@ -0,0 +1,44 @@ +;; Scopes + +[ + (module) + (function_definition) + (lambda) +] @local.scope + +;; Definitions + +; Parameters +(parameters + (identifier) @local.definition) +(parameters + (typed_parameter + (identifier) @local.definition)) +(parameters + (default_parameter + name: (identifier) @local.definition)) +(parameters + (typed_default_parameter + name: (identifier) @local.definition)) +(parameters + (list_splat_pattern ; *args + (identifier) @local.definition)) +(parameters + (dictionary_splat_pattern ; **kwargs + (identifier) @local.definition)) + +(lambda_parameters + (identifier) @local.definition) + +; Imports +(import_statement + name: (dotted_name + (identifier) @local.definition)) + +(aliased_import + alias: (identifier) @local.definition) + +;; References + +(identifier) @local.reference + -- cgit v1.2.3-70-g09d2