Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nimsuggest: Set a case style preference #16772

Closed
gwennlbh opened this issue Jan 20, 2021 · 3 comments
Closed

nimsuggest: Set a case style preference #16772

gwennlbh opened this issue Jan 20, 2021 · 3 comments

Comments

@gwennlbh
Copy link

gwennlbh commented Jan 20, 2021

Summary

A new flag --case or --case-style that can take one of the following values:

  • snake for lower_underscore_case
  • camel for camelCase
  • pascal for PascalCase
  • lower for lowercasewithnoseparators

A function to convert from any style to the chosen one is ran on all variable/types/functions suggestions nimsuggest makes so that developers can choose their preferred style (which I believe is one of the reasons why Nim is case-insensitive)

Description

Currently, if a library uses a different case style, you have two competing options:

  • taking advantage of nimsuggest and accepting suggestions that will create an inconsistent code style
  • typing out the function's name in its entirety while watching the suggestion just above nag you (which can be a bit irritating)

Both have disadvantages. The proposed feature only keeps the best of both worlds.

Alternatives

Not exactly an alternative, but rather an extension of the configuration that I think might be a bit too extreme: specify different types for different things, like how functions are snake_case while classes are PascalCase in some languages. This requirement could be specified by making --case-style accept a space-separated list of <kind>s:<style> pairs, where <kind> is function, variable, constant, etc. and <style> is a case style to be associated with that kind of "object".

The simpler format and this more advanced one could coexist: if no : appears in --case-style, use the simpler format (just one case style), otherwise, use the more extensive one.

Examples

--case-style snake will autocomplete with snake_case'd functions
--case-style "constants:pascal functions:lower" will autocomplete with PascalCase'd constant names and lowercased function names

@gwennlbh gwennlbh changed the title nimsuggest: Set a case style preference and make all suggestions in that case style nimsuggest: Set a case style preference Jan 20, 2021
@RSDuck
Copy link
Contributor

RSDuck commented Jan 20, 2021

I implemented something like this once, but from the side of the VSC addon: pragmagic/vscode-nim#82

@Akronae
Copy link

Akronae commented Jan 4, 2023

Is there any advancement on this?
Supporting different case types is something that is really bragged on about Nim, but in reality it is impossible to conveniently code using snake_case as nimsuggest/std lib is totally opiniated to camelCase.

How about not having to configure anything at all but just nimSuggest infering your coding style from your input ?
E.g:

I have a module A with a proc myProc
if I type A. nimsuggest will suggest me A.myProc
if I type A.my_ nimsuggest will suggest A.my_proc

A more advanced flavor would be for nimsuggest to look backward and check wether I used snake_case for other identifiers and suggest straight away A.my_proc while still suggesting A.myProc if I type A.myP

Seems simple enough, I'm pretty new to Nim though maybe there is something I'm overlooking.
I would be interested to contribute.

@Araq
Copy link
Member

Araq commented Aug 27, 2023

Not planned. PRs acceptable.

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

No branches or pull requests

4 participants