Skip to content

Charm's "freeze" CLI as a neovim plugin

License

Notifications You must be signed in to change notification settings

ndom91/freeze.nvim

Repository files navigation

freeze.nvim

Neovim plugin to consume some text, pass it into Charm's freeze CLI to generate a screenshot, and then put it into your clipboard.

⚡️ Requirements

Warning

Run :checkhealth freeze after installation to ensure requirements are satisfied.

📦 Installation

use {
  "ndom91/freeze.nvim",
  requires = { "nvim-lua/plenary.nvim" },
  config = function()
    require('freeze').setup({
      fontSize = 12,
    })
  end
}
{
  "ndom91/freeze.nvim",
  lazy = false,
  keys = {
    {
      "<leader>f",
      function() require("freeze").exec() end,
      mode = { "n", "v" },
      desc = "[F]reeze",
      noremap = true,
    },
  },
  dependencies = {
    "nvim-lua/plenary.nvim",
  },
}

🏗️ Usage

You can call freeze with a keybinding or with the Freeze command. To make sure the Freeze command is always available, make sure to disable lazy loading of the plugin (lazy = false in the Lazy.nvim configuration).

vim.keymap.set("n", "<leader>f", function() freeze.exec() end)

In normal mode, it will pass on the entire current buffer to be screenshotted. However, if you highlight a block of text in visual mode, only that will be used for the screenshot.

Options

All available options are listed below, these are all passed on to Charm's CLI flags.

{
  -- Defaults
  debug = false,
  theme = "dracula",
  windowControls = true,
  showLineNumbers = true,

  -- Rest
  backgroundColor = "#1E1E1E",
  margin = 2,
  padding = 2,
  borderRadius = 8,
  borderWidth = 1,
  borderColor = "#515151",
  shadowBlur = 20,
  shadowX = 0,
  shadowY = 10,
  fontFamily = "monospace",
  fontSize = 16,
  fontLigatures = true
}

👷 Development

With NixOS, you can make use of the devshell in flake.nix.

nix develop

Run tests

Running tests requires [plenary.nvim][plenary] to be checked out in the parent directory of this repository. You can then run:

nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}"

Or if you want to run a single test file:

nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/path_to_file.lua {minimal_init = 'tests/minimal.vim'}"

📝 License

MIT

About

Charm's "freeze" CLI as a neovim plugin

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project