Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

[To be discussed]Casing conversion #82

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

RSDuck
Copy link
Contributor

@RSDuck RSDuck commented Feb 11, 2018

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)?

@kosz78
Copy link
Collaborator

kosz78 commented Feb 26, 2018

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?

@Araq
Copy link

Araq commented Feb 26, 2018

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

@dom96
Copy link

dom96 commented Feb 26, 2018

This should be a separate plugin IMO

@RSDuck
Copy link
Contributor Author

RSDuck commented Feb 26, 2018

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.

@onelivesleft
Copy link
Contributor

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)

@RSDuck
Copy link
Contributor Author

RSDuck commented Dec 1, 2019

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.

@onelivesleft
Copy link
Contributor

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?

@RSDuck
Copy link
Contributor Author

RSDuck commented Dec 1, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants