[Feat] allow no region selection in CodeSnapHighlight
This PR simply allows users to continue through the CodeSnapHighlight popup buffer without selecting a visual region.
Why
Personally, I want to use this because I want to bind a single "make a picture of this code" keybind, and may sometimes want to highlight a specific chunk of that code. Otherwise I'd like to just make a picture of the region I initially selected.
CodeSnapHighlight would work perfectly for me, if it could support not highlighting, if desired.
How
The only change I made here was binding the highlight callback to <CR> in both visual and normal mode. The rest of the highlight code handles this appropriately, so it "just works".
Details
I used the higher-level vim.keymap.set API because it allows us to assign the same keybind to multiple modes. This is just a convenience thing, so we don't have to replicate or complicate the :lua stuff that runs.
If there's a reason why we need to use vim.api.nvim_buf_set_keymap, I can modify it to do that instead.
Demo
With visual region selected
Without visual region selected
@sarahsturgeon Awesome work! Can you add to the document?
@sarahsturgeon Awesome work! Can you add to the document?
Sure! Where would you like me to do that?
@sarahsturgeon you can add it to the "Highlight code block" section in README