Sonic-Pi send visual selection and integration, luasnip TAB jumps insert positions
This commit is contained in:
15
lua/functions.lua
Normal file
15
lua/functions.lua
Normal 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
|
||||
Reference in New Issue
Block a user