chrisgrieser / nvim-scissors

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

Feature Request: Multiple keymaps for same action in edit window #9

Closed garymh closed 9 months ago

garymh commented 9 months ago

Feature Requested

Hi there! Love the plugin! I just have a small request- I have a keybinding vim.keymap.set("<leader>w", vim.cmd.w) that I use to save usually, and that ends up throwing an error in the snippet edit window since I'm not calling :w directly. Is there a way to add additional aliases?

I'm not a plugin author by any means, but maybe there could be a special buffer type here https://github.com/chrisgrieser/nvim-scissors/blob/f7a24fbbb10c1c87f1907e57de5f384cc01baf24/lua/scissors/edit-popup.lua#L161 instead of nofile? Does that work with ftplugin files? (or is that just filetypes)

Relevant Screenshot

No response

Checklist

chrisgrieser commented 9 months ago

That does not work, because the snippet window isn't a real file.

Why you not just set the saveChanges keymap of this plugin to <leader>w?

garymh commented 9 months ago

That does not work, because the snippet window isn't a real file.

Ah, darn

Why you not just set the saveChanges keymap of this plugin to w?

Mostly because I also do :w as well. Just kind of depends how fast I'm typing at the moment 🙃

chrisgrieser commented 9 months ago

So both, <leader>w as well as :w, are covered. What exactly is your issue then?

garymh commented 9 months ago

Sorry - should have clarified, I was trying to teach myself to use <CR> too. But until that muscle memory started working, I figured it might be nice to have multiple options. (I was thinking of a few ways to access jumpBetweenBodyAndPrefix too)

chrisgrieser commented 9 months ago

Ah, so you want to be able to set multiple keymaps?

garymh commented 9 months ago

Yes, that's a better way of putting 😄

chrisgrieser commented 9 months ago

If you set your keymap like this:

vim.keymap.set("n", "<leader>w", ":w<CR>")

Then <leader>w will work to save the snippet, regardless of what you set the saveChanges key to. (It needs to be via : for nvim-scissors overwrite to take effect).

This means that you can use <CR> for saveChanges as well, giving you a total of 3 options for how you can save changes. Adding extra options for multiple keymaps beyond that feels somewhat unnecessary for me.

If there are other people also requesting the multiple keymaps, I'll reconsider, though.