Sonic-Pi send visual selection and integration, luasnip TAB jumps insert positions
This commit is contained in:
@@ -33,6 +33,8 @@ cmp.setup({
|
||||
-- Hint: if the completion menu is visible select next one
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
|
||||
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
|
||||
@@ -90,7 +90,7 @@ require('mason-lspconfig').setup_handlers({
|
||||
on_attach = on_attach,
|
||||
config = {
|
||||
on_init = function(client)
|
||||
require('sonicpi').lsp_on_init(client, { server_dir = '/opt/sonic-pi/app/server' })
|
||||
require('sonicpi').lsp_on_init(client, {})
|
||||
end
|
||||
},
|
||||
filetypes = { 'ruby', 'sonicpi' },
|
||||
|
||||
@@ -447,13 +447,12 @@ require("lazy").setup({
|
||||
end,
|
||||
},
|
||||
|
||||
-- -- Live Coding: sonic-pi music programming
|
||||
-- Live Coding: sonic-pi music programming
|
||||
{
|
||||
'magicmonty/sonicpi.nvim',
|
||||
-- broken if used here, setup called further below
|
||||
config = function()
|
||||
require('sonicpi').setup({
|
||||
server_dir = '/opt/sonic-pi/app/server',
|
||||
-- server_dir = '/opt/sonic-pi/app/server',
|
||||
lsp_diagnostics = true,
|
||||
mappings = {
|
||||
{ 'n', '<leader>d', ':SonicPiStartDaemon<CR>', { desc = 'Sonic Pi: start daemon' } },
|
||||
@@ -463,8 +462,11 @@ require("lazy").setup({
|
||||
{ 'i', '<M-r>', require('sonicpi.remote').run_current_buffer, { desc = 'Sonic Pi: run' } },
|
||||
{ 'n', '<leader>R', ':SonicPiSendBuffer<CR>', { desc = 'Sonic Pi: send buffer' } },
|
||||
{ 'i', '<M-R>', ':SonicPiSendBuffer<CR>', { desc = 'Sonic Pi: send buffer' } },
|
||||
-- // TODO.2024-10-29 implement sending of tree-sitter node
|
||||
{ 'n', '<C-H>', function() end, { desc = 'Sonic Pi: send current' } },
|
||||
{ 'v', '<leader>s', require('sonicpi.remote').stop, { desc = 'Sonic Pi: stop' } },
|
||||
{ 'v', '<leader>v',
|
||||
function()
|
||||
require('sonicpi.remote').run_code(SL_get_visual_selection())
|
||||
end, { desc = 'Sonic Pi: send visual range' } }
|
||||
},
|
||||
single_file = true,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user