16 lines
580 B
Lua
16 lines
580 B
Lua
-- custom defined functions
|
|
|
|
-- Return the currently, visually selected text range
|
|
function SL_get_visual_selection()
|
|
vim.cmd([[ execute "normal! \<ESC>" ]])
|
|
local s_start = vim.fn.getcharpos("'<")
|
|
local s_end = vim.fn.getcharpos("'>")
|
|
vim.cmd([[ execute "normal! gv" ]])
|
|
|
|
local current_buffer = vim.api.nvim_get_current_buf()
|
|
local r = vim.api.nvim_buf_get_text(current_buffer, s_start[2] - 1, s_start[3] - 1,
|
|
s_end[2] - 1, s_end[3], {})
|
|
-- print("region might be", current_buffer, s_start[2], s_start[3], s_end[2], s_end[3])
|
|
return table.concat(r, "\n")
|
|
end
|