silicon is a lua plugin for neovim to generate beautiful images of code snippet using silicon
recording.mp4
- beautiful images of source code, saved to preferred place.
- copy to clipboard
- Neovim >= 0.6.0
- silicon
Install the plugin with your preferred package manager:
-- Lua
use {
"narutoxy/silicon.lua",
requires = { "nvim-lua/plenary.nvim" },
config = function()
require('silicon').setup({})
end
}
" Vim Script
Plug 'nvim-lua/plenary.nvim'
Plug 'narutoxy/silicon.lua'
lua require('silicon').setup({})
silicon comes with the following defaults:
{
theme = "auto",
output = "SILICON_${year}-${month}-${date}_${time}.png", -- auto generate file name based on time (absolute or relative to cwd)
bgColor = vim.g.terminal_color_5,
bgImage = "", -- path to image, must be png
roundCorner = true,
windowControls = true,
lineNumber = true,
font = "monospace",
lineOffset = 1, -- from where to start line number
linePad = 2, -- padding between lines
padHoriz = 80, -- Horizontal padding
padVert = 100, -- vertical padding
shadowBlurRadius = 10,
shadowColor = "#555555",
shadowOffsetX = 8,
shadowOffsetY = 8,
gobble = false, -- enable lsautogobble like feature
}
- Select code snippet in visual mode.
- Generate images of selected snippet.
lua require("silicon").visualise_api({})
- Generate images of whole buffer with the selected snippet being highlighted by lighter background.
lua require("silicon").visualise_api({show_buf = true})
- Copy the image of snippet to clipboard.
lua require("silicon").visualise_api({to_clip = true})
NOTE: The default path of image is the current working directory of the editor, but you can change it by
require("silicon").setup({
output = "/home/astro/Pictures/SILICON_$year-$month-$date-$time.png"),
})