Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lua/codeshot/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ local function run_sss_code(codeshot_options, opts)

local copy = false

if type(codeshot_options.copy) == 'string' and codeshot_options.copy ~= "%c" then
if type(codeshot_options.copy) == 'string' and codeshot_options.copy ~= '%c' then
copy = codeshot_options.copy
output = 'raw'
end

if codeshot_options.filename_as_window_title then
local filename = vim.fn.expand('%:t')
extra_args.window_title = filename
end

local cmd = table.concat({
codeshot_options.bin_path,
table.concat(
utils.obj_to_args(
extra_args,
{ 'bin_path', 'file', 'raw_input', 'use_current_theme', 'output', 'copy', 'silent' }
{ 'bin_path', 'file', 'raw_input', 'use_current_theme', 'output', 'copy', 'silent', 'filename_as_window_title' }
),
' '
),
Expand Down Expand Up @@ -64,20 +69,26 @@ end
function codeshot.selected_lines()
local curr = vim.fn.expand('%:p')
local extension = vim.fn.expand('%:e')

vim.cmd([[execute "normal! \<ESC>"]])
local s_start = vim.fn.getpos("'<")[2]
local s_end = vim.fn.getpos("'>")[2]
local lines = s_start .. '..' .. s_end

codeshot.take(curr, extension, lines, lines)
end

function codeshot.focus_selected_lines()
local curr = vim.fn.expand('%:p')
local extension = vim.fn.expand('%:e')

vim.cmd([[execute "normal! \<ESC>"]])
local s_start = vim.fn.getpos("'<")[2]
local s_end = vim.fn.getpos("'>")[2]
-- Calculate len of lines
-- local n_lines = math.abs(s_end[2] - s_start[2]) + 1
local hi_lines = s_start .. '..' .. s_end

codeshot.take(curr, extension, '..', hi_lines)
end

Expand Down
3 changes: 2 additions & 1 deletion lua/codeshot/option.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local defaults = {
bin_path = 'sss_code',

-- Screenshot flags
copy = "%c",
copy = '%c',
silent = true,
window_controls = false,
shadow = false,
Expand All @@ -25,6 +25,7 @@ local defaults = {
radius = 15,
author = '',
author_color = '#FFFFFF',
filename_as_window_title = true,
window_title = '',
window_title_background = '',
window_title_color = '#FFFFFF',
Expand Down
1 change: 0 additions & 1 deletion lua/codeshot/theme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ function theme._theme_obj()
'SpellBad',
'Title',
'MatchParen',
'IndentBlanklineChar',
'Number',
'Character',
'String',
Expand Down
Loading