Compare commits

...

2 Commits

5 changed files with 61 additions and 26 deletions

View File

@@ -1,5 +1,6 @@
-- load configurations files from lua/*
require('options')
require('functions')
require('plugins')
require('colorscheme')
require('lsp')

View File

@@ -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
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

View File

@@ -83,6 +83,20 @@ require('mason-lspconfig').setup_handlers({
-- and will be called for each installed server that doesn't have
-- a dedicated handler.
function(server_name) -- default handler (optional)
-- 2024-10-29 Solargraph shall handle ruby AND sonicpi files, add on_init according to documentation
if server_name == "solargraph" then
lspconfig[server_name].setup {
on_attach = on_attach,
config = {
on_init = function(client)
require('sonicpi').lsp_on_init(client, {})
end
},
filetypes = { 'ruby', 'sonicpi' },
}
end
if server_name == 'ts_ls' then
-- taken from https://github.com/vuejs/language-tools
-- If you are using mason.nvim, you can get the ts_plugin_path like this

View File

@@ -447,18 +447,35 @@ require("lazy").setup({
end,
},
-- -- Live Coding: sonic-pi music programming
-- {
-- 'magicmonty/sonicpi.nvim',
-- -- broken if used here, setup called further below
-- -- config = function()
-- -- require('sonicpi').setup()
-- -- end,
-- dependencies = {
-- 'hrsh7th/nvim-cmp',
-- 'kyazdani42/nvim-web-devicons'
-- },
-- },
-- Live Coding: sonic-pi music programming
{
'magicmonty/sonicpi.nvim',
config = function()
require('sonicpi').setup({
-- server_dir = '/opt/sonic-pi/app/server',
lsp_diagnostics = true,
mappings = {
{ 'n', '<leader>d', ':SonicPiStartDaemon<CR>', { desc = 'Sonic Pi: start daemon' } },
{ 'n', '<leader>s', require('sonicpi.remote').stop, { desc = 'Sonic Pi: stop' } },
{ 'i', '<M-s>', require('sonicpi.remote').stop, { desc = 'Sonic Pi: stop' } },
{ 'n', '<leader>r', require('sonicpi.remote').run_current_buffer, { desc = 'Sonic Pi: run' } },
{ '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' } },
{ '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,
})
end,
dependencies = {
'hrsh7th/nvim-cmp',
'kyazdani42/nvim-web-devicons'
},
},
-- easy term on a shortcut
{
@@ -487,17 +504,3 @@ require("lazy").setup({
end,
},
})
-- require('sonicpi').setup({
-- server_dir = '/opt/sonic-pi/app/server',
-- mappings = {
-- { 'n', '<leader>d', ':SonicPiStartDaemon<CR>', { desc = 'Sonic Pi: start daemon' } },
-- { 'n', '<leader>s', require('sonicpi.remote').stop, { desc = 'Sonic Pi: stop' } },
-- { 'i', '<M-s>', require('sonicpi.remote').stop, { desc = 'Sonic Pi: stop' } },
-- { 'n', '<leader>r', require('sonicpi.remote').run_current_buffer, { desc = 'Sonic Pi: run' } },
-- { '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' } },
-- },
-- single_file = true,
-- })