Sonic-Pi send visual selection and integration, luasnip TAB jumps insert positions

This commit is contained in:
2024-10-30 20:40:56 +01:00
parent 9a0c3a4ca2
commit 67dafbaf6c
5 changed files with 26 additions and 6 deletions

15
lua/functions.lua Normal file
View File

@@ -0,0 +1,15 @@
-- 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