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 dict assignment #7

Open ColinKennedy opened 1 year ago

ColinKennedy commented 1 year ago

Allow for simple foo["bar"] to be mutated. e.g.

foo = {}
foo["bar"]# Cursor goes here

Would expand to

foo = {}
foo["bar"] = # Cursor goes here

But not if followed by further qualifiers such as ,

foo = {}
foo["bar"],# Cursor goes here

Adding a space does not expand here

foo = {}
foo["bar"], =# Cursor goes here

And of course if foo["bar"] is in the middle of an existing expression then do not do assignment. e.g. return foo["bar"] wouldn't want to expand to return foo["bar"] = 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.