Code snapshot from NeoVim

nvim 26-06-2024

The Struggle

Ever wondered how you could create a right-away elegant code snippet to share on your Linkedin post or with a colleague?

The problem arose when I had to write internal tech blogs, documentation, or post mortems.

I’ve always struggled to create nice snippets to show some good or bad pieces of code without the usual code block and copy-paste.

Right-after seeing lots of posts on Linkedin using those kinds of snippets I started digging around and I have found some managed services.

An example is Snappify.com but it was too cumbersome to maintain in the long term, with lots of back and forth to adapt the snippet or make changes.

After a couple of writings using this kind of tool, I gave up and went back to the old code block. approach.

Plot twist

Being relatively new to NeoVim (1 year to date as main editor of choice after several years of fails at using it) I thought that there were no such automation to create snippets from inside NeoVim.

I couldn’t have been more wrong about it, after looking around for a nvim plugin to create “just screenshots” of the code I’ve discovered the perfection.

Codesnap.nvim

With a few minutes, I have installed it on my NeoVim environment and quickly generated a snippet as follows:

Untitled

This snippet has been created in just two steps:

How to install

If you are using Lazy as package manager you just need to add the plugin

  {
    "mistricky/codesnap.nvim", 
    lazy = true,
    build = "make",
    cmd = { "CodeSnapSave", "CodeSnap" },
    config = function () 
      return require("codesnap").setup({
        bg_theme = "bamboo",
        watermark = "",
        save_path = "~/Downloads/"
      })
    end
  },

For a complete example, see my dotfile repository

Worth mentioning feature

Installation step-by-step guide

For a complete guide, I will redirect you to the Github repository that is really well documented and easy to follow.

https://github.com/mistricky/codesnap.nvim Kudos to the maintainer, let’s star the repository :star:

Author's photo

Valerio Pizzichini

See other articles:

undefinedThumbnail

The Estimation Trap: Why Software Projects Keep Missing the Mark

Traditional software project estimations are fundamentally flawed, with 80% of projects failing or missing deadlines and causing various negative effects like rushed solutions, stress, and quality drops. The article suggests alternative approaches like the #NoEstimates methodology and giving time control to engineers, focusing on counting stories rather than estimating them and creating an environment where innovation and quality can thrive.

productivity 30-11-2024

undefinedThumbnail

Maximizing Efficiency with Stacked PRs

Stacked PRs, also known as stacked diffs or commit-based reviews, represent a paradigm shift from traditional pull requests where multiple commits are bundled together. Instead, each commit stands as an individual unit of change, facilitating more granular review and integration.

productivity 22-07-2024