magicmonty / sonicpi.nvim

A neovim Plugin for [Sonic Pi](https://sonic-pi.net)
41 stars 7 forks source link

Failed to run `config` for sonicpi.nvim #7

Open Elahi-cs opened 9 months ago

Elahi-cs commented 9 months ago

After installing the plugin with lazy.nvim and trying to open a .sonicpi file with nvim I get the following error:

Failed to run `config` for sonicpi.nvim
...a/Local/nvim-data/lazy/sonicpi.nvim/lua/sonicpi/init.lua:109: attempt to index local 'opts' (a nil value)
# stacktrace:
  - sonicpi.nvim\lua\sonicpi\init.lua:109 _in_ **setup**
  - ~/AppData/Local/nvim/lua/packages/sonicpi.lua:8 _in_ **config**
  - ~\AppData\Local\nvim\init.lua:21

This is the sonicpi.lua file referenced in the second line of the stack trace:

return {
    'magicmonty/sonicpi.nvim',
    dependencies = {
        'hrsh7th/nvim-cmp',
        'kyazdani42/nvim-web-devicons'
    },
    config = function()
        require('sonicpi').setup()
    end,
}

I haven't done any LSP or CMP setups in case this might be related.

vikke commented 9 months ago

I have same problem on linux and windows11. my lazy.nvim code is below.

require("lazy").setup({
    ....
    ....
    {
        'magicmonty/sonicpi.nvim',
        config = function()
            require('sonicpi').setup()
        end,
        dependencies = {
            'hrsh7th/nvim-cmp',
            'kyazdani42/nvim-web-devicons',
        },
        single_file = true
    },
})

require('sonicpi').setup({
  server_dir = '/var/lib/flatpak/app/net.sonic_pi.SonicPi/current/active/files/app/server',
  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 },
  },
  single_file = true,
})
vikke commented 9 months ago

I resolve it.

    {
        'magicmonty/sonicpi.nvim',
--      config = function()
--          require('sonicpi').setup()
--      end,
        dependencies = {
            'hrsh7th/nvim-cmp',
            'kyazdani42/nvim-web-devicons',
        },
        single_file = true
    }

comment out config block.

sluedecke commented 2 weeks ago

I tried your solution, which works for me.

But I just discovered that if my require('sonicpi').setup() has actual values as parameters for setup, the error does not happen. See https://github.com/magicmonty/sonicpi.nvim/issues/9#issuecomment-2445403397