Skip to content

nimsuggest: Set a case style preference #16772

@gwennlbh

Description

@gwennlbh

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions