niuiic/code-shot.nvim

github github
media
stars 59
issues 0
subscribers 2
forks 2
CREATED

2023-08-18

UPDATED

2 months ago


code-shot.nvim

Take a picture of the code.

Similar features to silicon.nvim, keep simple, keep reliable.

More neovim plugins

Dependencies

Usage

Just call require("code-shot").shot(), work in both n, v and V mode.

  • Shot whole file
  • Shot selection

Config

Default config here.

require("code-shot").setup({
    ---@return string output file path
    output = function()
        local core = require("core")
        local buf_name = vim.api.nvim_buf_get_name(0)
        return core.file.name(buf_name) .. ".png"
    end,
    ---@return string[]
    -- select_area: {start_line: number, end_line: number} | nil
    options = function(select_area)
        if not select_area then
            return {}
        end
        return {
            "--line-offset",
            select_area.start_line,
        }
    end,
})

Add any argument supported by silicon in options. For example, select a theme.

require("code-shot").setup({
    options = function()
        return {
            "--theme",
            "DarkNeon",
        }
    end,
})