Page 1 of 2

Snippet Panel context menu

Posted: 16.02.2023 16:48
by Stefan
Wish: direct access to the file that contains the clip I hover over. Like Synwrite does it. I don't need a dialog. A simple "Edit this file" is sufficient.

Posted: 17.02.2023 08:25
by main Alexey
good small idea. wrote it to my to-do (at Github).

Posted: 17.02.2023 10:53
by main Alexey
i just saw the code. not easy to add. reason: folder of snippets can be a) in plugin's dir, b) in data/ dir (all default snippets lay there).
And one or more files can lay in the same folder.
so i cannot easily 'get' the current filename in the code.

Posted: 17.02.2023 15:34
by Stefan
I see what you mean.
For me, it were sufficient to only gain access to \data\clips and it's various subfolders. But I realize, this might confuse other users, when it only works for certain entries and not everywhere.

Guess I will have to consolidate my snippets into one txt-file only, per category/subfolder. Then add \data\clips to all my projects and switch back and forth in the side panels.

Btw, Synwrite also allowed *.synw-snippet files in the side panel. Cuda does not.
It was useful when writing documentations, to insert example snippets, even though they did not belong to txt or md or html. Now I have to open a separate doc with the correct lexer, so I can get to the right snippets menu, then insert from there, cut and paste it over to my documentation tab. No big deal, it's doable. But Synwrite was more flexible in that respect.

Posted: 17.02.2023 20:05
by main Alexey
hm, is it hard to convert old *.synw-snippet files to format of Snippet Panel?
it's documented: https://wiki.lazarus.freepascal.org/Cud ... ppet_Panel

Posted: 17.02.2023 21:25
by Stefan
Not sure I understand. Are you saying, I should be able to read in .cuda-snippet files located in data\clips\MyCategory into the side panel? I was under the impression, that both, .cuda-snippet and .synwrite-snippet only work from the snippets MENU, after I paste them into the \data\snippets_ct\MyLexer\*.json file, but not from the side panel.

Posted: 18.02.2023 07:34
by main Alexey
we have 2 snippets plugins

a. 'Snippets'. uses dir data/snippets_ct. supports *.synw-snippet.
b. 'Snippet Panel'. uses different dir under 'data'. AFAIR it don't support *.synw-snippet.

Posted: 18.02.2023 10:48
by Stefan
Exactly. That's what I meant. I cannot use my .synw-snippet files in the side panel.
main Alexey wrote:hm, is it hard to convert old *.synw-snippet files to format of Snippet Panel?
it's documented: https://wiki.lazarus.freepascal.org/Cud ... ppet_Panel
How would I do that? The documentation says, it only supports the ${sel} macro. All my ${NN:default text} etc does not seem to work from the side panel. I have to insert them one by one into the Snippets Menu and replace the double // by single /. And then they are lexer-bound. I have tried to not assign a lexer, but did not succeed.

Posted: 18.02.2023 14:56
by main Alexey
>all my ${NN:default text} etc does not seem to work from the side panel.
yes. sorry, such tab-stops won't work with the Snippet Panel.

> I have tried to not assign a lexer, but did not succeed.
sounds like a bug in Snippets plugin. snippets must support 'any lexer' when lexer is not set.
give me 1-2 such snippets to test.

Posted: 18.02.2023 15:42
by main Alexey
Confirmed that snippet with empty 'group's lexers' field don't work for ALL lexers. filed as a bug to my github.