pragmagic / vscode-nim

An extension for VS Code which provides support for the Nim language.
Other
238 stars 37 forks source link

Getting list of all possible values for an enum #163

Open tobimensch opened 4 years ago

tobimensch commented 4 years ago

Hello,

thanks for your extension.

I tried to get a list of all the values an enum can have, but this doesn't seem to be implemented.

Thanks in advance to whoever makes this work, it'd be very useful in my opinion.

RSDuck commented 4 years ago

what do you mean, by all the value it can take on?

just go to the enums definition (right click go to definition or ctrl+click), and you'll find the values which belong to the enum.

tobimensch commented 4 years ago

@RSDuck Of course one can go to its definition, but why should one have to? You could also tell me to go to a module's source file to know all the procs it provides, yet we have autocompletion, which shows as all the procedures that work for a given type. So why can't autocompletion do the same for an enum instead of forcing me to leave the current source file I'm working on? I want to type enumName.(here a list of all the value-names this enum has should appear), to see what choices I have, I think this would be more intuitive, instead of being forced to leave the current source code I'm working on because I have to something up.

RSDuck commented 4 years ago
  1. the completion is provided by nimsuggest not by the plugin
  2. what you're describing enumName. is not really idomatic Nim code. Enums should only be explicitely qualified in cases where it's necessary. Typically you give your enums a common prefix (example: https://nim-lang.org/docs/macros.html#NimNodeKind).