microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.2k stars 28.55k forks source link

Allow Snippet Choices to have descriptions #68406

Closed Kroc closed 5 years ago

Kroc commented 5 years ago

There are some instances where you would like the user to make a choice, but the actual value to be placed in the document will differ from the [friendly] choice presented. For example, the fields in a ROM header; the user chooses a "friendly" term, such as "128 K", but the value outputted is the technical value $03.

This is how my current snippet looks:

"rombanks" : {
    "prefix" : ".rombanks",
    "body" : [
        ".ROMBANKS\t${1|$00,$01,$02,$03,$04,$05,$06,$07|}",
        "$0"
    ],
    "description" : ".ROMBANKS: indicator of ROM size (GameBoy)"
}

But I would like some means of explaining what those values mean, or even better, presenting "friendly" names instead, that is:

choice presented value inserted
32 KB $00
64 KB $01
128 KB $02
256 KB $03
512 KB $04
1024 KB $05
2048 KB $06
4096 KB $07

edit: Check this document http://gbdev.gg8.se/wiki/articles/Gameboy_ROM_Header_Info for an example of what I'm dealing with. I'm sure there's plenty of examples of "show one thing, insert another" that exist in less esoteric fields than 8-bit assembly.

jrieken commented 5 years ago

Not a fan because we try to be Textmate compatible and this isn't "official". For scenarios you describe a completion item provider should be implemented.

Kroc commented 5 years ago

The documentation doesn't have a guide for Completion Providers, so this is not obvious to authors. That said, something declarative would always beat having to write (and maintain!) code for the same thing. I'm honestly trying to get as much functionality as I can without having to go down the insane rabbit-hole that is NPM. :)

jrieken commented 5 years ago

The documentation doesn't have a guide for Completion Providers,

https://github.com/Microsoft/vscode-extension-samples/tree/master/completions-sample

Kroc commented 5 years ago

That's not a guide; but yes, that is what I'm looking into ATM.

jrieken commented 5 years ago

Closing because of the compatibility reasoning: https://github.com/Microsoft/vscode/issues/68406#issuecomment-462296964