mistricky / codesnap.nvim

📸 Snapshot plugin with rich features that can make pretty code snapshots for Neovim
MIT License
473 stars 15 forks source link

Keybind documentation #84

Closed jacobrreed closed 1 month ago

jacobrreed commented 2 months ago

Can you add your setup for keymaps?

    {
      "<leader>ss",
      function()
        vim.cmd("CodeSnap")
      end,
      desc = "CodeSnap",
      mode = "v",
    },

Currently this doesnt work, I have to manually visually select, then type the command CodeSnap removing the range selectors < and >

If i use the above it will just say "no code selected"

peter-bread commented 2 months ago

@jacobrreed This is the best I've managed so far:

keys = {
    { "<leader>ci", ":CodeSnap<cr>", desc = "CodeSnap", mode = "x" },
},

It works fine but due to using the : you do briefly see that you've entered command mode. If that doesn't bother you then this will suffice.

I'm yet to find a way to do it silently (without seeing the command in command mode) using vim.cmd or <cmd>...<cr> or anything else.

The closest I got was:

vim.keymap.set("x", "<leader>ci", [['<,'>CodeSnap]])

This almost worked but the first time I enter visual mode I get a "Mark not set" error, which is something to do with < and >. I'n not sure why it doesn't register the marks the first time (vim issue, plugin issue, something else???) but if you exit visual mode and then try again it seems to work. But I didn't want it to be temperamental so I've settled for the mapping I put at the top.

jacobrreed commented 2 months ago

ah Ok this works great, x mode was the answer, also to stop the above from bothering you just add silent=true

This is my setup now, works good image

jacobrreed commented 2 months ago

@mistricky Might want to add some documentation on keybind setup, the above seems to work thanks

peter-bread commented 2 months ago

also to stop the above from bothering you just add silent=true

Thank you!

mistricky commented 2 months ago

Hi @jacobrreed, thx for this issue, sorry reply late.

Might want to add some documentation on keybind setup

Add keybind setup to document would be great! I'll document it later

mistricky commented 1 month ago

The Keymappings chapter was updated on README.