Rewrite as virtual document provider
mre opened this issue ยท 7 comments
VSCode has this fancy feature called "virtual document providers".
With that, vscode-snippet would simply become a provider that gets triggered whenever a certain URL gets requested, e.g. snippet://read+file
.
The cool thing about it would be that we could have "read only" documents instead of the current "untitled" documents that have to be closed manually. We can also set a document title, e.g. the search query and the programming language (i.e. [python] read file
).
On top of that, I assume that this would also reduce the code size quite a bit as a lot gets handled by VSCode itself.
Here is an example on how to implement it.
If anyone wants to give this a go, help would be really appreciated!
This seems interesting, Im unfamiliar with vscode plugins but Ill take a shot at it.
That's great!
If you need any help or have design questions, just post them here and we can brainstorm.
For example, one thing we haven't specified yet is the way we discern the programming languages in the query. It could be something like snippet://python/read+file
. Another thing is pagination. Getting answer number 3 could be encoded as snippet://python/read+file/3
.
I'd lean towards this schema because cht.sh, our underlying service, uses the same syntax. See https://github.com/chubin/cheat.sh/blob/master/README.md#usage
Anyway, happy hacking and thanks for giving it a shot. ๐
Im not sure when ill have time to get around to this, I wanted to dig in but Ive been getting some things ready for JAMStackConf, I dont want to get in the way if anyone else wants to take a stab. Ill check into it later when I have some more free time.
No worries and thanks for the update. JAMStack_conf looks really cool; good luck with the preparation.
I would like to give it a shot.
Sure! Please go ahead. Let us know if you run into problems and we'll try to find a solution together. Happy hacking.
This is done now thanks to @taksuparth. Closing.