mistricky / codesnap.nvim

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

`CodeSnap` doesn't work whatever i do #50

Closed daUnknownCoder closed 5 months ago

daUnknownCoder commented 6 months ago

Without selecting code, i would like a vim.notify or vim.print instead of WTF type logs log1 -> happens when i first time try CodeSnap without selection:

Error executing Lua callback: .../NeutronVim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:48: Vim:Error executing Lua callback: ...hare/NeutronVim/lazy/codesnap.nvim/lua/codesnap/init.lua:31: Please select code which you want to take snapshot first
stack traceback:
    [C]: in function 'error'
    ...hare/NeutronVim/lazy/codesnap.nvim/lua/codesnap/init.lua:31: in function 'get_config'
    ...hare/NeutronVim/lazy/codesnap.nvim/lua/codesnap/init.lua:49: in function 'copy_into_clipboard'
    .../share/NeutronVim/lazy/codesnap.nvim/plugin/codesnap.lua:4: in function <.../share/NeutronVim/lazy/codesnap.nvim/plugin/codesnap.lua:3>
    [C]: in function 'cmd'
    .../NeutronVim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:48: in function <.../NeutronVim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:16>
stack traceback:
    [C]: in function 'cmd'
    .../NeutronVim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:48: in function <.../NeutronVim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:16>

log2 -> happens after 1st time of no code selection

Error executing Lua callback: ...hare/NeutronVim/lazy/codesnap.nvim/lua/codesnap/init.lua:31: Please select code which you want to take snapshot first
stack traceback:
    [C]: in function 'error'
    ...hare/NeutronVim/lazy/codesnap.nvim/lua/codesnap/init.lua:31: in function 'get_config'
    ...hare/NeutronVim/lazy/codesnap.nvim/lua/codesnap/init.lua:49: in function 'copy_into_clipboard'
    .../share/NeutronVim/lazy/codesnap.nvim/plugin/codesnap.lua:4: in function <.../share/NeutronVim/lazy/codesnap.nvim/plugin/codesnap.lua:3>

sometimes with luck [tho i can't paste this anywhere] i get Save snapshot into clipboard successfully check video:

Kooha-2024-03-17-20-11-04.webm

CodeSnapSave works, but i dont get breadcrumbs in it: idk

And sometimes, neovim crashes, check video:

Kooha-2024-03-17-20-02-00.webm

@mistricky, my config:

  -- Beautiful CodeSnippet Viewing
  {
    "mistricky/codesnap.nvim",
    build = "make",
    version = "^1",
    lazy = true,
    cmd = { "CodeSnap", "CodeSnapSave" },
    config = function()
      require("codesnap").setup({
        has_breadcrumbs = true,
        bg_theme = "summer",
        save_path = "./idk.png",
      })
    end,
  },
tnthi115 commented 6 months ago

I am also not able to get breadcrumbs, and I can't get rid of the mac window bar.

mistricky commented 5 months ago

Thx for using and show interesting in this project, for problems this issues mentioned:

Without selecting code, i would like a vim.notify or vim.print instead of WTF type logs

That's a great idea, for these languages like Rust or Golang, they clearly distinguish between "error" and "panic", the selected empty scenario is expect error, but in lua, there just have one error type which is error(unexpect error like exception in JS or Java), I would use print log instead represent expect error in lua.

sometimes with luck [tho i can't paste this anywhere] i get Save snapshot into clipboard successfully

Okay... it's nothing to do with lucky, looks like the set copy data action failed interact with your clipboard utils. @daUnknownCoder What's your XDG_SESSION_TYPE? If you are using some DE using wayland, this problem may to do with the wl-clipboard, CodeSnap.nvim is based on arboard, that will interact with wl-clipboard if you are using wayland, but the wl-clipboard have a problem:

When we copy something on Wayland (using wl-clipboard) and close the application we copied from, the copied data disappears from the clipboard and we cannot paste it anymore

So if you are using wayland, you can try this util wl-clip-persist that can persist the copy data whatever if the copied source process was exited, it works fine on my machine (x86_64 Arch Linux with wayland session).

and I can't get rid of the mac window bar.

This issue has fix by https://github.com/mistricky/codesnap.nvim/pull/54, it will be released along with the next version. @tnthi115

And the another bug this issue mentioned:

I am also not able to get breadcrumbs

I can't reproduce on my machine, but I will continue observe this bug.

mistricky commented 5 months ago

The CodeSnap was released 1.1.5, can you guys try with v1.1.5 and validate? if this bug still exist, please let me know @tnthi115 @daUnknownCoder

tnthi115 commented 5 months ago

@mistricky Congrats on the new release, and thanks for your work! I've tested on my end again, and both issues I previously mentioned are resolved.

mistricky commented 5 months ago

Okay, seems like this issue can be closed.

daUnknownCoder commented 5 months ago

sorry @mistricky, i was busy these days, i am indeed using wayland (Hyprland) but im using both xclip and wl-clipboard for the clipboard stuff coz some apps are using native wayland and some are using xwayland, and i also have nwg-clipman to update on any copy stuff on both clipboard managers, and my current terminal is on xwayland...

When we copy something on Wayland (using wl-clipboard) and close the application we copied from, the copied data disappears from the clipboard and we cannot paste it anymore

this thing doesnt apply, since i just switch windows, my terminal is open 24x7 i never close it

image this time it saved, but it took me 1 whole minute to generate this, without using the persist thing u mentioned nwg-clipman says this image

and yeah, the No code is selected looks clean, congrats on the release tho 🎉

mistricky commented 5 months ago

Hi @daUnknownCoder, thx for your reply.

this thing doesnt apply, since i just switch windows, my terminal is open 24x7 i never close it

Maybe I expressed wrong before, I mean wl-clipboard cannot read copied data that come from exited processes. In this case, the exited process is a module called generator which used to generate screenshots. When you run CodeSnap command, the generator runs in background and does some work for generating screenshots, and copy the generated screenshots into the clipboard, and then exits. wl-clipboard cannot read the copied screenshot anymore.

I'm also using Arch + Hyprland as my daily platform, as Hyprland document say:

When we copy something on Wayland (using wl-clipboard) and close the application we copied from, the copied data disappears from the clipboard and we cannot paste it anymore. So to fix this problem we can use a program called as wl-clip-persist which will preserve the data in the clipboard after the application is closed. Github

CodeSnap.nvim + wl-clipboard-persist working fine on my machine.

this time it saved, but it took me 1 whole minute to generate this

Cause the CodeSnap.nvim needs few time to draw a screenshot, on my machine it will take about 1s to finish screenshot draw. Maybe on some machines it takes a longer time, but it definitely can be optimized in the future.

daUnknownCoder commented 5 months ago

When we copy something on Wayland (using wl-clipboard) and close the application we copied from, the copied data disappears from the clipboard and we cannot paste it anymore. So to fix this problem we can use a program called as wl-clip-persist which will preserve the data in the clipboard after the application is closed.

This solved a few doubts of mine..., I see it takes time then I guess my PC is slow enough... I have 4gb RAM btw

So the plugin works well, keep updating this i love this plugin..., I'll try this persist thing... But ig I won't need it coz i m using clipman

mistricky commented 5 months ago

Hey @daUnknownCoder Thank u again for showing interesting in this project. Seems like this issue can be closed.