This is a neovim plugin for Sonic Pi
This plugin is inspired by sonicpi.vim.
But
You will need at least version 0.6 of neovim with lua support and nvim-cmp. Use your preferred package/plugin manager to install this plugin. With packer.nvim, this looks like:
use({
'magicmonty/sonicpi.nvim',
config = function()
require('sonicpi').setup()
end,
requires = {¬
'hrsh7th/nvim-cmp',
'kyazdani42/nvim-web-devicons'
}
})
You have to set the directory to the Sonic Pi server, so that the plugin can read the documentation and language arguments for the completion engine.
The default configuration is as follows, you can override it with your own settings if you wish
require('sonicpi').setup({
server_dir = "", -- It will try to find the SonicPi server
lsp_diagnostics = false -- enable LSP diagnostics
mappings = {
{ 'n', '<leader>s', require('sonicpi.remote').stop, default_mapping_opts },
{ 'i', '<M-s>', require('sonicpi.remote').stop, default_mapping_opts },
{ 'n', '<leader>r', require('sonicpi.remote').run_current_buffer, default_mapping_opts },
{ 'i', '<M-r>', require('sonicpi.remote').run_current_buffer, default_mapping_opts },
},
})
If you want to use the LSP, then install solargraph correctly and add the following to the on_init
callback of your lsp config:
local function on_init(client)
...
require('sonicpi').lsp_on_init(client, { server_dir = '/opt/sonic-pi/app/server' })
end
also you need to configure solargraph to accept single files with
single_file = true
in the solargraph settings for your LSP setup
If you want to use the completion engine, then you have to add the sonicpi
source to your config:
require('cmp').setup({
...
sources = {
...
{ name = 'sonicpi' }
...
},
})
This plugin has support for Luasnip. If you have luasnip istalled, then a selection of predefined snippets will be available.
Currently the following snippets are available:
clocks
-> makes a live loop, which acts as a selection of clocks where you can synchronize toll
-> makes a live loopllc
-> makes a live loop, which synchronizes to a specific clock cuebd
-> makes a live loop with a four on the floor base drum patternfx
-> makes a generic with_fx
blockecho
-> makes a with_fx
block with echo settingsreverb
-> makes a with_fx
block with reverb settingsYou need to create a new file with a .sonicpi
extension and open it in neovim.
Then you can use the LSP and completion engine including the snippets.
Mode | Key binding | Description |
---|---|---|
n | <leader>r |
Run current buffer |
n | <leader>s |
Stop execution |
i | <M-r> |
Run current buffer |
i | <M-s> |
Stop execution |