filNaj / tree-setter

A treesitter-module which will place equals, semicolons, commas and double points automatically for you!
122 stars 6 forks source link

Feature Request: Python - Add index assignment #8

Open ColinKennedy opened 1 year ago

ColinKennedy commented 1 year ago

Allow for simple foo[0] to be assigned. e.g.

foo = ["bar"]
foo[0]# Cursor goes here

Would expand to

foo = ["bar"]
foo[0] = # Cursor goes here

But not if followed by further qualifiers such as ,

foo = ["bar"]
foo[0],# Cursor goes here

Adding a space does not expand here

foo = ["bar"]
foo[0], # Cursor goes here

And of course if foo[0] is in the middle of an existing expression then do not do assignment. e.g. return foo[0] wouldn't want to expand to return foo[0] = accidentally.

filNaj commented 1 year ago

It is now partially fixed. I say partially because for now, the only way I found to resolve this issue is by not adding an = if a comma exists in the line.