completion.scm
1 ;; Subscript with string: os.environ["VAR"] or os.environ['VAR'] 2 (subscript 3 value: (_) @object 4 subscript: (string) 5 ) @completion_target 6 7 ;; os.getenv("VAR") function call 8 (call 9 function: (attribute 10 object: (identifier) @object 11 attribute: (identifier) @func) 12 (#eq? @object "os") 13 (#eq? @func "getenv") 14 ) @completion_target 15 16 ;; environ.get/pop/setdefault("VAR") method calls 17 (call 18 function: (attribute 19 object: (_) @object 20 attribute: (identifier) @func) 21 (#match? @func "^(get|pop|setdefault)$") 22 ) @completion_target 23 24 (attribute 25 object: (attribute) @object 26 ) @completion_target 27 28 ;; Handle incomplete syntax: "env." parses as ERROR 29 ;; Exclude "os" since it's a module that CONTAINS env objects, not one itself 30 (ERROR 31 (identifier) @object 32 (#not-eq? @object "os") 33 ) @completion_target 34 35 (ERROR 36 (attribute) @object 37 ) @completion_target 38 39 ;; Handle incomplete subscript: os.environ[' or os.environ[" 40 ;; Tree-sitter creates ERROR nodes when string is incomplete 41 (ERROR 42 (subscript 43 value: (_) @object) 44 ) @completion_target