Coder Social home page Coder Social logo

silicon.nvim's Introduction

silicon.nvim

Render beautiful image of your code in neovim using silicon.

Release License Neovim version

silicon.mp4

Installation

Requirements

  • nvim v0.7
  • [Optional] cargo and rust toolchain

Packer

use {'krivahtoo/silicon.nvim', run = './install.sh'}

Build from source (requires cargo)

use {'krivahtoo/silicon.nvim', run = './install.sh build'}

Vim-Plug

Plug 'krivahtoo/silicon.nvim', { 'do': './install.sh' }

Build from source (requires cargo)

Plug 'krivahtoo/silicon.nvim', { 'do': './install.sh build' }

Configuration

Initialize the plugin.

Lua init file:

require('silicon').setup({
  font = 'FantasqueSansMono Nerd Font=16',
  theme = 'Monokai Extended',
})

Vimscript init file:

lua << EOF
require('silicon').setup({
  font = 'FantasqueSansMono Nerd Font=16',
  theme = 'Monokai Extended',
})
EOF

The setup function accepts the following table:

{
  -- Output configuration for the saved image
  output = {
    -- (string) The full path of the file to save to.
    file = "",
    -- (boolean) Whether to copy the image to clipboard instead of saving to file.
    clipboard = true,
    -- (string) Where to save images, defaults to the current directory.
    --  e.g. /home/user/Pictures
    path = ".",
    -- (string) The filename format to use. Can include placeholders for date and time.
    -- https://time-rs.github.io/book/api/format-description.html#components
    format = "silicon_[year][month][day]_[hour][minute][second].png",
  },

  -- Font and theme configuration for the screenshot.
  font = 'Hack=20', -- (string) The font and font size to use for the screenshot.
  -- (string) The color theme to use for syntax highlighting.
  -- It can be a theme name or path to a .tmTheme file.
  theme = 'Dracula',

  -- Background and shadow configuration for the screenshot
  background = '#eff', -- (string) The background color for the screenshot.
  shadow = {
    blur_radius = 0.0, -- (number) The blur radius for the shadow, set to 0.0 for no shadow.
    offset_x = 0, -- (number) The horizontal offset for the shadow.
    offset_y = 0, -- (number) The vertical offset for the shadow.
    color = '#555' -- (string) The color for the shadow.
  },

  pad_horiz = 100, -- (number) The horizontal padding.
  pad_vert = 80, -- (number) The vertical padding.
  line_number = false, -- (boolean) Whether to show line numbers in the screenshot.
  line_pad = 2, -- (number) The padding between lines.
  line_offset = 1, -- (number) The starting line number for the screenshot.
  tab_width = 4, -- (number) The tab width for the screenshot.
  gobble = false, -- (boolean) Whether to trim extra indentation.
  highlight_selection = false, -- (boolean) Whether to capture the whole file and highlight selected lines.
  round_corner = true,
  window_controls = true, -- (boolean) Whether to show window controls (minimize, maximize, close) in the screenshot.
  window_title = nil, -- (function) A function that returns the window title as a string.

  -- Watermark configuration for the screenshot
  watermark = {
    text = nil, -- (string) The text to use as the watermark, set to nil to disable.
    color = '#222', -- (string) The color for the watermark text.
    -- (string) The style for the watermark text, possible values are:
    -- 'bold', 'italic', 'bolditalic', or anything else defaults to 'regular'.
    style = 'bold',
  },
}

Example

require('silicon').setup {
  font = 'FantasqueSansMono Nerd Font=26',
  background = '#87f',
  theme = 'Monokai Extended',
  line_number = true,
  pad_vert = 80,
  pad_horiz = 50,
  output = {
    path = "/home/krivah/Pictures/Screenshots"
  },
  watermark = {
    text = '๏‚› @krivahtoo',
  },
  window_title = function()
    return vim.fn.fnamemodify(vim.fn.bufname(vim.fn.bufnr()), ':~:.')
  end,
}

image

Usage

Command:

:'<,'>Silicon[!] [file]
# Defaults to clipboard if [file] is not specified.
# With bang file is saved to specified output.file in the
# output.format specified
# Also mapped to 'SS' in Visual mode

silicon.nvim's People

Contributors

crsov avatar github-actions[bot] avatar krivahtoo avatar pricehiller avatar slotos avatar winder avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.