Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: User command register #5

Merged
merged 1 commit into from
Mar 29, 2024
Merged
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
12 changes: 6 additions & 6 deletions lua/codeshot/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ end
function codeshot.selected_lines()
local curr = vim.fn.expand('%:p')
local extension = vim.fn.expand('%:e')
local s_start = vim.fn.getpos("'<")
local s_end = vim.fn.getpos("'>")
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')
local s_start = vim.fn.getpos("'<")
local s_end = vim.fn.getpos("'>")
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
Expand All @@ -66,8 +66,8 @@ end
function codeshot.setup(opts)
option.set(opts)

vim.api.nvim_create_user_command('SSFocused', codeshot.focus_selected_lines, {})
vim.api.nvim_create_user_command('SSSelected', codeshot.focus_selected_lines, {})
vim.api.nvim_create_user_command('SSFocused', codeshot.focus_selected_lines, { range = true })
vim.api.nvim_create_user_command('SSSelected', codeshot.selected_lines, { range = true })
end

return codeshot
Loading