diff --git a/lua/codeshot/init.lua b/lua/codeshot/init.lua index c0ef8c1..dd43f39 100644 --- a/lua/codeshot/init.lua +++ b/lua/codeshot/init.lua @@ -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' } ), ' ' ), @@ -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! \"]]) 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! \"]]) 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 diff --git a/lua/codeshot/option.lua b/lua/codeshot/option.lua index a3399ad..c609795 100644 --- a/lua/codeshot/option.lua +++ b/lua/codeshot/option.lua @@ -6,7 +6,7 @@ local defaults = { bin_path = 'sss_code', -- Screenshot flags - copy = "%c", + copy = '%c', silent = true, window_controls = false, shadow = false, @@ -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', diff --git a/lua/codeshot/theme.lua b/lua/codeshot/theme.lua index 0aa4c9a..324b026 100644 --- a/lua/codeshot/theme.lua +++ b/lua/codeshot/theme.lua @@ -37,7 +37,6 @@ function theme._theme_obj() 'SpellBad', 'Title', 'MatchParen', - 'IndentBlanklineChar', 'Number', 'Character', 'String',