chrisgrieser / nvim-scissors

Automagical editing and creation of snippets.
MIT License
377 stars 4 forks source link

Feature Request: Bootstrap vscode snippet folder #2

Closed Rizhiy closed 9 months ago

Rizhiy commented 10 months ago

Feature Requested

After install, if the default snippet directory doesn't exist, the following error is raised:

Snippet directory does not exist: /home/rizhiy/.config/nvim/snippets

Would be great if the default directory is created automatically.

Relevant Screenshot

No response

Checklist

chrisgrieser commented 10 months ago

Unfortunately, this would not help much, since it is not only a snippet directory, but also a package.json and at least one snippet file for vs code snippets to work. And that, in turn, is not something this plugin can easily automate for the user.

Considering your other issues, I'd suggest reading up on the docs how the vs code snippet format works.

Rizhiy commented 10 months ago

One directory and two files are not easy?

chrisgrieser commented 10 months ago

Not easy in the sense that strictly speaking it requires user input. Though I suppose bootstrapping with some default values could probably work

chrisgrieser commented 9 months ago

With all the necessary validation and covering all cases, this "easy" implementation took a total of ~120 lines.

Anyway, the last update now adds bootstrapping capabilities if the snippet directory, the package.json, or a snippet file is missing.

Rizhiy commented 9 months ago

Adding snippets works fine, thank you. If I try to edit snippets without directory/package.json it still errors out, would be great to also create those files on edit snippets call.

Rizhiy commented 9 months ago

Also, might be a good idea to ask the user if they want to create the files if they don't exists. In case someone mistyped the snippetsDir by accident.

chrisgrieser commented 9 months ago

Adding a snippet file when you are trying to edit existing snippets feels a bit unintuitive for me, tbh.

But validating that a package.json exists before you try to edit snippet files is indeed something that is missing and that I'll add in a moment.