1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
return {
"michaelrommel/nvim-silicon",
lazy = true,
cmd = "Silicon",
main = "nvim-silicon",
opts = {
-- Configuration here, or leave empty to use defaults
-- disable_defaults will disable all builtin default settings apart
-- from the base arguments, that are needed to call silicon at all, see
-- mandatory_options below, also those options can be overridden
-- all of the settings could be overridden in the lua setup call,
-- but this clashes with the use of an external silicon --config=file,
-- see issue #9
disable_defaults = false,
-- turn on debug messages
debug = false,
-- most of them could be overridden with other
-- the font settings with size and fallback font
-- Example: font = "VictorMono NF=34;Noto Emoji",
font = nil,
-- the theme to use, depends on themes available to silicon
theme = "gruvbox-dark",
-- the background color outside the rendered os window
-- (in hexcode string e.g "#076678")
background = nil,
-- a path to a background image
background_image = nil,
-- the paddings to either side
pad_horiz = 100,
pad_vert = 80,
-- whether to have the os window rendered with rounded corners
no_round_corner = false,
-- whether to put the close, minimize, maximise traffic light
-- controls on the border
no_window_controls = false,
-- whether to turn off the line numbers
no_line_number = false,
-- with which number the line numbering shall start
line_offset = 1,
-- here a function is used to return the actual source code line number
-- line_offset = function(args)
-- return args.line1
-- end,
-- the distance between lines of code
line_pad = 0,
-- the rendering of tab characters as so many space characters
tab_width = 4,
-- with which language the syntax highlighting shall be done, should be
-- a function that returns either a language name or an extension like "js"
-- it is set to nil, so you can override it, if you do not set it, we try the
-- filetype first, and if that fails, the extension
language = nil,
-- language = function()
-- return vim.bo.filetype
-- end,
-- language = function()
-- return vim.fn.fnamemodify(
-- vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()),
-- ":e"
-- )
-- end,
-- if the shadow below the os window should have be blurred
shadow_blur_radius = 16,
-- the offset of the shadow in x and y directions
shadow_offset_x = 8,
shadow_offset_y = 8,
-- the color of the shadow (in hexcode string e.g "#100808")
shadow_color = nil,
-- whether to strip of superfluous leading whitespace
gobble = true,
-- a string to pad each line with after gobbling removed larger indents,
num_separator = nil,
-- here a bar glyph is used to draw a vertial line and some space
-- num_separator = "\u{258f} ",
-- whether to put the image onto the clipboard, may produce an error,
-- if run on WSL2
to_clipboard = false,
-- a string or function returning a string that defines the title
-- showing in the image, only works in silicon versions greater than v0.5.1
window_title = nil,
-- here a function is used to get the name of the current buffer
-- window_title = function()
-- return vim.fn.fnamemodify(
-- vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()),
-- ":t"
-- )
-- end,
-- how to deal with the clipboard on WSL2
-- possible values are: never, always, auto
wslclipboard = nil,
-- what to do with the temporary screenshot image file when using the Windows
-- clipboard from WSL2, possible values are: keep, delete
wslclipboardcopy = nil,
-- the silicon command, put an absolute location here, if the
-- command is not in your ${PATH}
command = "silicon",
-- a string or function that defines the path to the output image
-- output = nil,
-- here a function is used to create a file in the current directory
output = function()
local home_dir = vim.fn.expand("~") -- Get home directory
local timestamp = os.date("!%Y-%m-%d_%H-%M-%S") -- Get timestamp
local file_name = vim.fn.expand("%:t:r") -- Get the file name without extension
local file_extension = vim.fn.expand("%:e")
return home_dir .. "/" .. timestamp .. "_" .. file_name .. "_" .. file_extension .. ".png"
end,
},
keys = {
{
mode = "v",
"<leader>sc",
function()
require("nvim-silicon").clip()
end,
desc = "Copy code screenshot to clipboard",
},
{
mode = "v",
"<leader>sf",
function()
require("nvim-silicon").file()
end,
desc = "Save code screenshot as file",
},
{
mode = "v",
"<leader>ss",
function()
require("nvim-silicon").shoot()
end,
desc = "Create code screenshot",
},
},
init = function()
local wk = require("which-key")
wk.add({
mode = { "v" },
{ "<leader>s", group = "Snapshot" },
})
end,
}
|