Skip to content

Commit 5536fd5

Browse files
[Feat] allow no region selection in CodeSnapHighlight (#152)
* Allow user to continue without selecting a highlight region * Update README
1 parent be6d6b9 commit 5536fd5

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ CodeSnapSaveHighlight # Take code snapshot with highlights code blocks and save
205205
```
206206

207207
#### How to use
208-
For take a code snapshot with highlights code blocks and save it somewhere. First you need to select code which you want to snapshot, then enter the command `CodeSnapSaveHighlight` to open a window show you the selected code which from previous step, now you can select code which you want to highlight, finally press the Enter key, CodeSnap will generate a snapshot with highlight blocks and save it in save_path.
208+
For take a code snapshot with highlights code blocks and save it somewhere. First you need to select code which you want to snapshot, then enter the command `CodeSnapSaveHighlight` to open a window show you the selected code which from previous step, now you can select code which you want to highlight _(if any - you can use these without actually highlighting anything)_, finally press the Enter key, CodeSnap will generate a snapshot with highlight blocks and save it in save_path.
209209

210210
Here is an example video:
211211

lua/codesnap/highlight.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ function highlight_module.create_highlight_selector_window(cb_name, code)
4040
vim.api.nvim_buf_set_option(bufnr, "filetype", vim.bo.filetype)
4141
vim.api.nvim_buf_set_keymap(bufnr, "n", "q", ":q<CR>", {})
4242
vim.api.nvim_buf_set_keymap(bufnr, "", "<ESC>", ":q<CR>", {})
43-
vim.api.nvim_buf_set_keymap(
44-
bufnr,
45-
"v",
43+
vim.keymap.set(
44+
{ "v", "n" },
4645
"<CR>",
4746
":lua require('codesnap.highlight').call_cb_with_parsed_config('"
4847
.. cb_name
4948
.. "', require('codesnap.utils.visual').get_start_line_number(), require('codesnap.utils.visual').get_end_line_number())<CR>",
50-
{ silent = true }
49+
{ silent = true, buffer = bufnr }
5150
)
51+
5252
vim.api.nvim_set_current_win(window_id)
5353
end
5454

0 commit comments

Comments
 (0)