Skip to content

Commit

Permalink
Improve Python queries, add locals (helix-editor#3284)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrHorn authored and GreasySlug committed Aug 2, 2022
1 parent 5b325cc commit ddd0b34
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
9 changes: 8 additions & 1 deletion runtime/queries/python/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
; Imports

(dotted_name
(identifier)* @namespace)

(aliased_import
alias: (identifier) @namespace)

; Builtin functions

Expand Down Expand Up @@ -55,14 +60,16 @@
(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
(identifier) @variable.parameter))
(parameters
(dictionary_splat_pattern ; **kwargs
(identifier) @variable.parameter))

(lambda_parameters
(identifier) @variable.parameter)

; Types

Expand Down
44 changes: 44 additions & 0 deletions runtime/queries/python/locals.scm
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ddd0b34

Please sign in to comment.