mrlacey / DemoSnippets

A Visual Studio extension for working with code snippets when giving demos.
https://marketplace.visualstudio.com/items?itemName=MattLaceyLtd.DemoSnippets
MIT License
16 stars 2 forks source link

Load from known directory #18

Open mrlacey opened 2 years ago

mrlacey commented 2 years ago

From https://marketplace.visualstudio.com/items?itemName=MattLaceyLtd.DemoSnippets&ssr=false#review-details

This is a really useful extension - I actually use this not just for demos, but as an alternative to code snippets, which are not very implemented within Visual Studio. One suggestion I would make for this scenario would be to optionally be able to load from a known directory when Visual Studio is started, rather than requiring them to be added to every project in order for them to be used.

mcquiggd commented 2 years ago

Basically, as I mention, I am now using this to access my code snippets; I find that using the standard Visual Studio implementation of having to assign shortcuts to snippets can soon get overwhelming in terms of having too many suggestions in Intellisense, or having to remember the shortcuts.

So, what I had started doing was dragging text to the Toolbox, and using that as a way to quickly access snippets. That way, I can do common tasks such as adding Jwt Authentication to a Web Api very quickly, with a click. I can organise them more easily, and search for them quickly.

But, the downside to that approach was that there was no simple way to export and import them; I might be mistaken, but it seems you can only do that in the Toolbox windows when using Windows Forms projects.

So, I have found your extension to be most useful.

The main suggestion is to be able to load the demosnippets from a directory, so I can manage them and share them in their own Git repo, and then have them available in every project automatically.

One other downside of the Toolbox approach was it doesn't support the smart placeholders that can be created in standard snippets, if that was supported, I would be very happy, but it's probably never going to happen. I am not sure if it is possible to trigger the standard snippet behaviour for newly placed text.

mrlacey commented 2 years ago

But, the downside to that approach was that there was no simple way to export and import them; I might be mistaken, but it seems you can only do that in the Toolbox windows when using Windows Forms projects.

Capabilities relating to the toolbox are defined by the project system for each language/project type. Unfortunately, that makes things a bit inconsistent. :(

The main suggestion is to be able to load the demosnippets from a directory, so I can manage them and share them in their own Git repo, and then have them available in every project automatically.

This sounds like a useful enhancement to the capabilities of this extension. :)

One other downside of the Toolbox approach was it doesn't support the smart placeholders that can be created in standard snippets, if that was supported, I would be very happy, but it's probably never going to happen. I am not sure if it is possible to trigger the standard snippet behaviour for newly placed text.

I'm not sure of a way to reuse the existing snippet interaction for moving through placeholders. Recreating it from scratch is a bit beyond me right now. :(

mcquiggd commented 2 years ago

Well, I seem to have hacked something together, following the existing approach, that adds optional support for additionally loading demosnippets files from a file location.

List of demosnippets from both solution and filesystem:

image

Options:

image

I'll try it in anger for a little while, see if there are any issues, tidy it up, and make a PR...