Page 1 of 1

plugin Snippets: now supports snippets from VS Code editor

Posted: 09.10.2020 20:58
by Alexey
Plugin is updated.
Big rework by @OlehL:
+ new command "Install VSCode snippets..." - to install snippets from VS Code Marketplace
+ new command "Delete snippet markers" - clears all markers in the current editor tab
+ reworked snippets engine to support VS Code snippets
+ now you can insert snippet in another snippet
+ improved work with placeholders ${}, now placeholders can be nested

"Install VSCode snippets" shows new dialog:
Screenshot from 2020-10-09 23-55-50.png
Menu from '=' button allows to change some filter options:
- fuzzy
- whole words search
- search in title or description

After you choose the set by Enter/dbl-click, additional dialog shows to choose CudaText lexer(s) for VSCode lexer:
Screenshot from 2020-10-09 23-57-16.png
VSCode snippets are installed to data/snippets_vs/ dir.

Posted: 12.01.2021 19:03
by Shovel
Am I understanding correctly that the only way to add a new snippet is to edit the json file in the snippet package?

Posted: 12.01.2021 19:34
by uvviewsoft
as I see, I can create new folder in data/snippets_ct/, and make there some files like in Cud distro: data/snippets_ct/std.HTML folder.

Posted: 13.01.2021 09:57
by Shovel
Sorry, Yes, I figured out that I can add custom snippets like that, but I meant is there maybe something "hidden" in CudaText like "Tools > New Snippet..." in SynWrite.

Posted: 13.01.2021 10:18
by uvviewsoft
Nope. but you can modify the Snippets plugin and give me the Pull request.

Posted: 13.01.2021 12:03
by Shovel
Oh, thats cool... I will be dreading that :D I mean will keep in mind

Posted: 19.01.2021 14:21
by Shovel
For me multiline snippets do not respect indentation (first line will appear properly at the caret position, but the other ones will be at the line start). Is it my fault? :)
Multiline snippet example

Code: Select all

    "for": {
        "body": [
            "for(int i = 0; i < ${1}; i++){\n\t\n}"
        ],
        "prefix": [
            "for"
        ]
    },

Posted: 22.01.2021 14:53
by uvviewsoft
OlehL suggested to rework this snippet, to fix it
https://github.com/OlehL/cuda_snippets/issues/35
So it's solved?

Posted: 22.01.2021 17:19
by Shovel
Yep, working this way

Posted: 24.02.2021 15:24
by uvviewsoft
Plugin was improved by @Shovel, added new command "Add/edit snippets"
to show such dialog, it is editor of snippets collections (in new json format).