To use version v1.0.0, set branch to v1.
Take a picture of the code.
Similar features to silicon.nvim, keep simple, keep reliable.
- Shot whole file
- Shot selection
- types
---@class code-shot.Context
---@field file_path string
---@field file_type string
---@field selected_area omega.Area
---@field selection string
---@class omega.Area
---@field start_lnum number
---@field start_col number
---@field end_lnum number
---@field end_col number
- shot file to clipboard
local function shot_file_to_clipboard()
require("code-shot").shot(function(context)
vim.system(
{
"silicon",
"--to-clipboard",
context.file_path,
},
nil,
function(result)
if result.code == 0 then
vim.notify("Shot code successfully", vim.log.levels.INFO)
else
vim.notify("Shot code failed", vim.log.levels.ERROR)
end
end
)
end)
end
- shot file to file
local function shot_file_to_file()
require("code-shot").shot(function(context)
vim.system(
{
"silicon",
"-o",
string.format("%s.png", os.date("%Y-%m-%d_%H:%M:%S")),
context.file_path,
},
nil,
function(result)
if result.code == 0 then
vim.notify("Shot code successfully", vim.log.levels.INFO)
else
vim.notify("Shot code failed", vim.log.levels.ERROR)
end
end
)
end)
end
- shot selection to clipboard
local function shot_selection_to_clipboard()
require("code-shot").shot(function(context)
vim.system(
{
"silicon",
"--to-clipboard",
context.file_path,
},
nil,
function(result)
if result.code == 0 then
vim.notify("Shot code successfully", vim.log.levels.INFO)
else
vim.notify("Shot code failed", vim.log.levels.ERROR)
end
end
)
end)
end
- shot selection to file
local shot_selection_to_file = function()
require("code-shot").shot(function(context)
require("omega").to_normal_mode()
vim.fn.setreg("+", context.selection)
vim.system(
{
"silicon",
"-o",
string.format("%s.png", os.date("%Y-%m-%d_%H:%M:%S")),
"--from-clipboard",
"--language",
context.file_type,
context.file_path,
},
nil,
function(result)
if result.code == 0 then
vim.notify("Shot code successfully", vim.log.levels.INFO)
else
vim.notify("Shot code failed", vim.log.levels.ERROR)
end
end
)
end)
end