davidgranstrom / scnvim

Neovim frontend for SuperCollider.
GNU General Public License v3.0
208 stars 28 forks source link

lua-config: mapping for SCNvimRecompile? #186

Closed kflak closed 2 years ago

kflak commented 2 years ago

I usually have <F4> mapped to :SCNvimRecompile and try to recreate this in the new config, but am not successful. How would I go about setting this?

davidgranstrom commented 2 years ago

The mappings table in the config is a convenience to map the functions exported by the editor module, basically the parts of the API that doesn't have a user command abstraction.

To map :SCNvimRecompile you could either map the command as you have done before, or map the lua function:

vim.keymap.set('n', '<leader>sk', '<cmd>lua require"scnvim".recompile()<cr>')

It is also possible to not specify any mappings in the mappings table of the config, and set up your own keymaps:

vim.keymap.set({'n', 'i'}, '<C-e>', '<cmd>lua require"scnvim.editor".send_block()<cr>')

~(note: I will make the eval flash effect default to true, which is not the case at the moment when you set up mappings manually like the example above.)~ its fixed now

davidgranstrom commented 2 years ago

Maybe the scnvim.map helper could take a function as well, that would consolidate all mappings to the config.

kflak commented 2 years ago

That would be really nice!

davidgranstrom commented 2 years ago

Its now possible to map arbitrary functions:

    ['<leader>sk'] = scnvim.map(scnvim.recompile), -- no need to wrap
    ['<F5>'] = scnvim.map(function()
      vim.cmd [[ SCNvimGenerateAssets ]]
    end),
kflak commented 2 years ago

Fantastic!