SkillAgentSearch skills...

Codesnap.nvim

๐Ÿ“ธ Snapshot plugin with rich features that can make pretty code snapshots for Neovim

Install / Use

/learn @mistricky/Codesnap.nvim

README

<img width="1819" height="1788" alt="cover" src="https://github.com/user-attachments/assets/25547efa-e1ad-4fb5-a8fa-b5dad8217de1" /> <p align="center"> <img src="https://img.shields.io/badge/For Neovim 0.9+-57A143?logo=neovim&logoColor=fff&style=for-the-badge" alt="Neovim" /> <img src="https://img.shields.io/github/actions/workflow/status/mistricky/codesnap.nvim/release.yml?style=for-the-badge&label=release" alt="release action status" /> <img src="https://img.shields.io/github/actions/workflow/status/mistricky/codesnap.nvim/lint.yml?style=for-the-badge&label=Lint" alt="release action status" /> <a href="https://github.com/mistricky/codesnap.nvim/issues"> <img alt="Issues" src="https://img.shields.io/github/issues/mistricky/codesnap.nvim?style=for-the-badge&logo=github&color=%23ffbd5e"> </a> <a href="https://github.com/mistricky/codesnap.nvim/blob/main/LICENSE"> <img alt="License" src="https://img.shields.io/github/license/mistricky/codesnap.nvim?style=for-the-badge&logo=github&color=%235ef1ff"> </a> <a href="https://github.com/mistricky/codesnap.nvim/stars"> <img alt="stars" src="https://img.shields.io/github/stars/mistricky/codesnap.nvim?style=for-the-badge&logo=github&color=%23bd5eff"> </a> <img src="https://img.shields.io/badge/Made%20With%20Lua-2C2D72?logo=lua&logoColor=fff&style=for-the-badge" alt="made with lua" > <img src="https://img.shields.io/badge/Written%20in%20Rust-DEA584?logo=rust&logoColor=fff&style=for-the-badge" alt="written in rust" > <a href="https://dotfyle.com/plugins/mistricky/codesnap.nvim"> <img src="https://dotfyle.com/plugins/mistricky/codesnap.nvim/shield?style=for-the-badge" /> </a> </p> <h1 align="center">CodeSnap.nvim</h1> <p align="center">๐Ÿ“ธ Snapshot plugin with rich features that can make pretty code snapshots for Neovim</p> <!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->

๐ŸšฃMigration

Upgrade from v0.x to v1

If you have installed v0.x before, this chapter will show you what break changes version v1.x introduced.

  • The CodeSnapPreviewOn command is not supported, if you prefer live-preview, you can pin CodeSnap.nvim version to v0.0.11 to continue using this command.
  • The opacity and preview_title config has been removed from v1.0.0
  • The editor_font_family was renamed to code_font_family

v1.x has a different architecture and better performance than v0.x, and v1.x can generate screenshots directly without an open browser. We recommend you upgrade to v1.x for a better experience.

Upgrade from v1 to v2

CodeSnap.nvim v2 bring a lot of new features and improvements, the most important change is that we rewrote the screenshot generator using CodeSnap, this library makes CodeSnap.nvim faster and more stable than before.

And there is no need to setup Rust environment to compile CodeSnap.nvim anymore, we precompiled the generator shared file for common platforms:

  • x86_64-unknown-linux-gnu
  • aarch64-unknown-linux-gnu
  • x86_64-apple-darwin
  • aarch64-apple-darwin
  • windows-x86_64-msvc

For most cases, you can use CodeSnap.nvim out-of-box without any additional setup. ๐Ÿต

Configuration is completely different between v1 and v2, which is following config.rs in CodeSnap. Which means you can use same configuration in both CodeSnap CLI and CodeSnap.nvim. Click here see what current config looks like.

Windows Support

We are excited to announce that CodeSnap.nvim now supports Windows! ๐ŸŽ‰, but we don't have enough time to test it on Windows, so if you find any issues on Windows, please let us know by creating an issue.

Prerequirements

  • Neovim 0.9.0+

Installation

We recommend using Lazy.nvim to install CodeSnap.nvim, but you can still use another plugin manager you prefer.

Lazy.nvim

{ "mistricky/codesnap.nvim", tag = "v2.0.0" }

Maybe you are CodeSnap.nvim v1 user, you may notice that we remove the build option in v2, because we don't need to compile the Rust code anymore, we precompiled the generator shared file for common platforms, you can find the precompiled files in releases page. So when you first install v2, CodeSnap.nvim will download the precompiled file automatically, it may take a few seconds to download the file, please be patient.

Keymappings

TODO

โœจFeatures

Consume Snapshot

There are two ways to consume the snapshot you took using CodeSnap.nvim:

Copy into clipboard

Copy the snapshot directly into clipboard, then you can paste it anywhere you want.

Run CodeSnap command, CodeSnap.nvim will generate a snapshot of the currently selected code and write it into clipboard.

CodeSnap

Copy into clipboard on Linux Wayland

Copy screenshots directly into the clipboard is cool, however, it doesn't work well on wl-clipboard, because the wl-clipboard can't paste the content which come from exited processes. 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.

If you using CodeSnap.nvim on wl-clipboard, you can refer wl-clip-persist, it reads all the clipboard data into memory and then overwrites the clipboard with the data from our memory to persist copied data.

Save the snapshot

Save the snapshot into a file, you can specify the path where you want to save it

Run CodeSnapSave command, CodeSnap.nvim will generate a snapshot of the currently selected code and save it in the path you specified in config.

CodeSnap.nvim supports saving snapshot in PNG, SVG and HTML format, you can specify the file extension in the path you provided, for example:

CodeSnapSave /path/to/your/snapshot.png
CodeSnapSave /path/to/your/snapshot.svg
CodeSnapSave /path/to/your/snapshot.html

ASCII snapshot

CodeSnap.nvim also supports taking ASCII art snapshot, you can use CodeSnapASCII command to take a snapshot in ASCII format and copy it into clipboard.

This feature is not useful for most cases, but it's FUN and lightweight, if you want to paste your code in somewhere like comment, ASCII snapshot may be a good choice.

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ codesnap.nvim/lua/codesnap/config.lua                          โ”‚
โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚
โ”‚ 24 local code_content = {                                      โ”‚
โ”‚ 25   content = code,                                           โ”‚
โ”‚ 26   start_line_number = start_line_number,                    โ”‚
โ”‚ 27   file_path = get_file_path(static.config.show_workspace),  โ”‚
โ”‚ 28 }                                                           โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

As you can see, the ASCII snapshot is just a plain text, without any background, line number, watermark, etc. But it still has key information like code content, line number and file path, which can be useful if someone want to know where the code is from.

Really hope you like this feature! ๐Ÿค—

Highlight code block

CodeSnap allows you to take code snapshots with highlights code blocks, we provide two commands for this scenario:

CodeSnapHighlight # Take code snapshot with highlights code blocks and copy it into the clipboard
CodeSnapSaveHighlight # Take code snapshot with highlights code blocks and save it somewhere

How to use

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.

Highlight Demo

Breadcrumbs

Breadcrumbs are really useful tool to display the current snapshot file path, you can enable it by setting breadcrumbs.enable to true:

require("codesnap").setup({
	-- ...
	snapshot_config = {
    -- ...
		code_config = {
			breadcrumbs = {
				enable = true,
		
View on GitHub
GitHub Stars924
CategoryDevelopment
Updated2d ago
Forks32

Languages

Lua

Security Score

100/100

Audited on Mar 30, 2026

No findings