-
Notifications
You must be signed in to change notification settings - Fork 20
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
[BUG] Every first screenshot fails with "node code selected" #103
Comments
Hi @willdavidow, thx for this issue reporting, that's interesting bug but I can't reproduce on my machine.
The "first attempt" refer to the first screenshot taken after first CodeSnap was installed or the first screenshot taken after opening nvim every time? |
It's every time after closing and reopening |
What version of your Neovim? If you enter command instead of use hotkey, did it works? |
i have the same behaviour upon the couple of first time , when i opend nvim ( LAZYVIM config here) with command line it work like a charm
could be related to Lazy event ?? EDIT: |
I'm running Running the command directly does work just fine. |
I encountered the same issue, but it appears I've found a solution. It seems that the markers To resolve this, I simply adjusted my configuration to exit visual mode before calling CodeSnap. Executing the following command: As this bug arises due to the plugin attempting to retrieve the last selection markers rather than the current selection, it could imply that the snapshot result consistently lags by one. However, that requires further verification. |
Work as expected, but for me it's kinda of a |
I guess the issue I'm having is related. My config (LazyVim): return {
"mistricky/codesnap.nvim",
build = "make",
opts = {
has_breadcrumbs = true,
has_line_number = true,
bg_color = "#212121",
bg_padding = 0,
watermark = "",
mac_window_bar = false,
},
keys = {
{ "<leader>cp", "<cmd>CodeSnap<cr>", mode = "x", desc = "Snap selected code into clipboard" },
{ "<leader>cP", "<cmd>CodeSnapHighlight<cr>", mode = "x", desc = "Snap and highlight code into clipboard" },
},
} When I select some class manually ( However, when I select that class using Basically, it snaps just the line where my cursor was when I executed The same scenario works totally fine when invoking the |
Hi @marcinjahn, Have you tried the workaround I've described? This seems like the lag by one I mentioned. |
My codesnap.lua file return {
"mistricky/codesnap.nvim",
build = "make build_generator",
keys = {
{ "<leader>cc", "<Esc><cmd>CodeSnap<cr>", mode = "x", desc = "Save selected code snapshot into clipboard" },
{ "<leader>cs", "<cmd>CodeSnapSave<cr>", mode = "x", desc = "Save selected code snapshot in ~/Pictures" },
},
opts = {
save_path = "~/Pictures",
has_breadcrumbs = true,
show_workspace = true,
has_line_numbers = true,
bg_theme = "bamboo",
},
} I tried this fix however I continue to get |
it's because u did not override the keymaps from lazyVim, your issue is not related to CodeSnap but with your keysmaps |
start neovim with |
So it looks like it's mapped correctly, however, when I try to use it, I get |
@Rallanvila you might need to set it for if it helps at all, here's my config: return {
"mistricky/codesnap.nvim",
build = "make build_generator",
-- opts = {
-- },
config = function()
require("codesnap").setup {
save_path = "~/Desktop",
file_extension = "png",
has_breadcrumbs = true,
has_line_number = true,
watermark = "",
bg_color = "#535c68",
bg_padding = 0,
code_font_family = "JetBrainsMonoNL Nerd Font",
watermark_font_family = "JetBrainsMonoNL Nerd Font",
-- prefix = "📸 ",
-- default options
-- prefix = "📸 ",
-- prompt = "Enter a name for the snapshot: ",
-- file_path = "~/Desktop/",
-- file_name = nil,
-- file_extension = "png",
-- highlight = "Visual",
-- highlight_group = "Visual",
-- highlight_file = nil,
-- highlight_format = "png",
-- highlight_options = {},
-- silent = false,
-- callback = nil,
}
local wk = require "which-key"
wk.add {
{ "<leader>cc", "<cmd>CodeSnap<cr>", desc = "Save selected code snapshot into clipboard", mode = { "v", "x" } },
{ "<leader>cs", "<cmd>CodeSnapSave<cr>", desc = "Save selected code snapshot to ~/Desktop", mode = { "v", "x" } },
}
end,
} |
@willdavidow, thanks for the config, I don't know what's going on. I c/p'd it in and you can see the commented code above from what I tried to run previously as well. |
@Rallanvila It looks like the key bindings here are not overriding the code lens setting. I don't use LazyVim, just the Lazy package installer - so I'm not sure if there's a special way to override keybindings. It looks to me like the lazily loaded language server key bindings for whatever file you're in are getting set after this plugin so you'd need a way to override that, or an easier approach would be to just pick an unused key binding/combination. |
I mapped it to something else and it worked. I couldn't figure out how to override the mappings for my life. I appreciate you @willdavidow 🙏🏼 |
Just installed the plugin and everything works fine for the most part, but it seems the first attempt always fails when trying to generate screenshots to both the clipboard or the save path.
Steps to reproduce
Open
nvim
and any fileSelect code and attempt to generate screenshot
Result
no code is selected
Expected
Screenshot generated to either clipboard or save path
When I de-select and re-select the exact code, in the exact same way, everything works fine.. it's just that first attempt that doesn't work.
Screen.Recording.2024-05-09.at.9.20.52.AM.mov
The text was updated successfully, but these errors were encountered: