vscode-nim icon indicating copy to clipboard operation
vscode-nim copied to clipboard

[To be discussed]Casing conversion

Open RSDuck opened this issue 6 years ago • 8 comments

As stated here it was originally envisioned that Nim users can configure there IDE so that it shows them identifiers in the way they like(Pascal/Camel, Snake case, …).

Yesterday I made this rough POC, which more or less works. E.g. if I prefer Snake-casing for function names, I could tweak nim.typeCasing to snake. vscode-nim will automatically suggest procs, templates, macros and iterators in snake case. a suggest result with everything in snake case a hover result in snake case

The implementation is still a bit rough, e.g. if you hover a call, the types in the proc signature aren't converted.

Some questions which arrive are:

  • Is this even a responsibility of vscode-nim, nimsuggest should handle this?
  • Should the configuration be more precise(more options)?

RSDuck avatar Feb 11 '18 14:02 RSDuck

I guess this functionality should be provided by nimsuggest, because in IDE there are lot of place where will require support case conversion, @Araq what is your opinion?

kosz78 avatar Feb 26 '18 15:02 kosz78

@kosz78 If nimsuggest supports it, how would the VSCode plugin offer this feature to the users?

Araq avatar Feb 26 '18 15:02 Araq

This should be a separate plugin IMO

dom96 avatar Feb 26 '18 15:02 dom96

This should be a separate plugin IMO

this would be rather hard, I don't really know if there is even a way to intercept the suggestion provider of another extension.

RSDuck avatar Feb 26 '18 17:02 RSDuck

I was about to implement this, so (a) glad I checked the open PR's first, and (b) I got this fork working with current code-base, and it's just what I wanted.

I think it doesn't need to have so much fidelity in the options: for me, one global option for which style to use, would be perfectly fine. Possibly 2: one for when the token starts with lower case, and one for when it starts with upper.

Expanded features which could be added:

  • Convert current document to specific style (command)
  • Convert on save (Bool option)
  • Convert on paste (Bool option)

onelivesleft avatar Dec 01 '19 14:12 onelivesleft

I think with NEP, styleCheck:on and nimpretty we got to the point where this original idea of everybody uses the casing she/he prefers is obsolete. The case invariancy of Nim is still useful for C wrappers with cumbersome names and for cases like forEach and foreach which nobody can remember (even with nimsuggest 😄), but that's about it.

RSDuck avatar Dec 01 '19 14:12 RSDuck

Thinking about it, what I'd actually want is:

  • convert on save (keep / camel / snake)
  • convert on load/paste (keep / camel / snake)

Then I can adhere to the w/e standard while still working with preferred legibility.

So, this idea/PR is dead?

onelivesleft avatar Dec 01 '19 15:12 onelivesleft

proper renaming would be a prequisite for casing conversion. Nim suggest doesn't provide functionality for that, though it can list all occurences of an identifier. I did some experiments a few years ago but it turned out to be unreliable.

RSDuck avatar Dec 01 '19 16:12 RSDuck