-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add command that allows easy adding new snippets #23
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, can you move it to the snippets-directory.kak
file? Also there seems to be some mismatch between snippets-add
and snippets-create
, I'm guessing you renamed those after testing :)
Oi! I've thought that it's bit long to type. Also fuzzy matching allows to only type |
I want to add a hook to reload snippet dir, in a fashion that it will track only snippet buffer. I've used Edit: nevermind, I've fixed the hook. However snippets don't reload for some reason. But hook executes. |
Seems like Also should I use |
I think it would be preferable to setup a hook with
I'm not sure what you mean, the |
Good idea indeed.
I can't use new snippet after hook executed. |
Ah, now I see it. I can't expand snippets after |
Yeah it won't work (yet, see TODO) for existing buffers, but if you create a new buffer with the target filetype the new snippets should be taken into account (though I haven't really tested it...). Don't forget to use |
Current implementation allows only balanced strings as |
Yes please. To reduce the escaping needed, you should move the entire |
I don't see how it helps |
I can wrap this into |
Yeah sed should be fine, especially if you wrap it with Regarding having another command you would still need to double up quotes, but at least you wouldn't have to octuple them (in a context of |
Well this means that there will be 3 check + 3 seds for each variable in case all true, and I'll need to break up single sed command into three, to be able to check those separately, because there's no way to use
I don't double quotes in any way here. It handles those fine by itself.
I've tested it with a bunch of weird strings passed as trigger and description, and it works fine. I suppose this command is already fine. The only thing that I suppose should be simplified, is it accepting 2 arguments instead of 3. This way it can be reused for |
I'm sorry but I don't think I'm being unreasonable when I say that the escaping logic in there is too complex, you have to keep track of which delimiters to double and where. I don't deny that it's possible to make it work like that, but I find it hard to understand (and consequently extend in the future). Here is an alternative approach that only relies on single quotes for escaping and where the complexity won't increase as we add logic in the menu command. It may be that we have to add more arguments to pass to the new command, but it will simply be a matter of quadrupling quotes in them, like with
|
of course! You're the boss here after all, hehe. I'll redo it that way soon. |
Looks good, thanks |
If you don't mind, later I'll add a command that allows edit snippet via trigger only. So user could just type |
Ah right, that makes sense for editing existing snippets, I was thinking that the usecase was mainly creating new ones |
usage:
This command accepts 0 or 2 or 3 parameters. In case of 3 parameters, a new snippet will be created for desired filetype. In case of two parameters, active filetype will be used, and if there's no filetype, snippets will be created in global scope
.*
. If there's no parameters user will see prompt:And If user inputs a trigger, new prompt appears:
In this case filetype isn't asked.