plugin Snippets: now supports snippets from VS Code editor

Plugins for SynWrite and CudaText...
Post Reply
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

plugin Snippets: now supports snippets from VS Code editor

Post 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.
Shovel
Posts: 141
Joined: 31.12.2019 10:16

Post 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?
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post 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.
Shovel
Posts: 141
Joined: 31.12.2019 10:16

Post 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.
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

Nope. but you can modify the Snippets plugin and give me the Pull request.
Shovel
Posts: 141
Joined: 31.12.2019 10:16

Post by Shovel »

Oh, thats cool... I will be dreading that :D I mean will keep in mind
Shovel
Posts: 141
Joined: 31.12.2019 10:16

Post 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"
        ]
    },
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

OlehL suggested to rework this snippet, to fix it
https://github.com/OlehL/cuda_snippets/issues/35
So it's solved?
Shovel
Posts: 141
Joined: 31.12.2019 10:16

Post by Shovel »

Yep, working this way
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post 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).
Attachments
Screenshot from 2021-02-24 18-22-36.png
Post Reply