nix-community / vscode-nix-ide

Nix language support for VSCode editor [maintainer: @jnoortheen]
https://marketplace.visualstudio.com/items?itemName=jnoortheen.nix-ide
MIT License
273 stars 20 forks source link

Improve snippet usability #341

Closed frantisekhanzlikbl closed 1 year ago

frantisekhanzlikbl commented 1 year ago

This may be pretty subjective, but as a long time user of this extension, the built-in snippets for let and with are pretty annoying in that they don't add a space to the end of the expansion and don't move the cursor there.

I believe there are two common use cases for the snippets, both of which are not very pleasant with the current version:

Pretty much the same applies to with.

The proposed fix makes both of these use cases much more pleasant without being too annoying for any other. The only degradation I can think of is for people who like to keep the in/with on separate lines and don't have trailing whitespace trimming on, who would now have to delete the space manually. Still, that is just one extra keypress, so it's probably not too bad.

jnoortheen commented 1 year ago

Currently, it follow the order of assignment, one first writes the name of the variable before assigning it to a value. Lets see if anyone is interested in setting it this way by default.

frantisekhanzlikbl commented 1 year ago

Currently, it follow the order of assignment, one first writes the name of the variable before assigning it to a value. Lets see if anyone is interested in setting it this way by default.

I'm not sure that I understand you correctly. Do you mean that you mean that people first write the part after in and only then the part between let and in? If that's the case, I wouldn't mind switching the $0 and $1 either. The important part for me is that I get to have the cursor in both of those places at some point, and that I don't have to hunt in{ all over my codebase all the time.

frantisekhanzlikbl commented 1 year ago

is there anything else I should change before this can move forward?

jnoortheen commented 1 year ago

LGTM, Thanks @frantisekhanzlikbl !