davidgranstrom/scnvim

[BUG] Keymaps don't work

Closed this issue · 4 comments

emuhr commented

Describe the bug
scnvim does not pickup configuration I set up using scnvim.setup. For example keymappings using keymaps = {... do not work, however manually setting up a keymap with vim.keymap.set does work.

Heres the relevant scnvim configuration:

local scnvim = require 'scnvim'
local map = scnvim.map
local map_expr = scnvim.map_expr

scnvim.setup {
  ensure_installed = true,
  keymaps = {
    ['<M-e>'] = map('editor.send_line', {'i', 'n'}),
    ['<C-e>'] = {
      map('editor.send_block', {'i', 'n'}),
      map('editor.send_selection', 'x'),
    },
    ['<CR>'] = map('postwin.toggle'),
    ['<M-CR>'] = map('postwin.toggle', 'i'),
    ['<M-L>'] = map('postwin.clear', {'n', 'i'}),
    ['<C-k>'] = map('signature.show', {'n', 'i'}),
    ['<F12>'] = map('sclang.hard_stop', {'n', 'x', 'i'}),
    ['<leader>st'] = map('sclang.start'),
    ['<leader>sk'] = map('sclang.recompile'),
    ['<F1>'] = map_expr('s.boot'),
    ['<F2>'] = map_expr('s.meter'),
  },
  editor = {
    highlight = {
      color = 'IncSearch',
    },
  },
  postwin = {
    float = {
      enabled = true,
    },
  },
}

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

The output of checkhealth also confirms this:


scnvim: require("scnvim.health").check()
========================================================================
## scnvim
  - OK: nvim version 0.7.2
  - OK: sclang executable: /usr/bin/sclang
  - OK: scnvim classes are installed: ~/.local/share/SuperCollider/Extensions/scide_scnvim
  - INFO: no keymaps defined

## scnvim documentation
  - INFO: using HelpBrowser for documentation

## scnvim extensions

Additional context
Information

  • Operating system
    Arch linux with 5.15.63-1-lts kernel

  • SuperCollider version
    3.12.2

  • nvim --version

NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
  • Package manager
    packer.nvim

Can you please help me? I don't know how to debug and query those plugin dictionaries at runtime yet.

Hi @emuhr, thanks for the report.

Your config looks good to me, I just tested it and mappings are applied as expected. Note that the keymaps are only applied to the supercollider filetype (i.e. you need to edit a file with a .scd or .sc file extension)

If you want to debug the config at runtime you can use:

:lua print(vim.inspect(require('scnvim.config').config))

Also make sure that you are using the latest version of scnvim.

If you have your nvim configuration online somewhere I could take a look at that as well.

emuhr commented

Hi @davidgranstrom,
thanks for looking into this. I tested the plugin with existing .scd files to be sure.
Running scnvim works, I can run :SCNvimStart etc.
Thanks for the debug command. This gives me a valid config, however as expected the keymaps section is empty.

I uploaded my current neovim config. If you could take a look, that would be great.
https://github.com/emuhr/neovim

Thanks in Advance.

Thanks for posting your config.

I think that calling scnvim.setup in the packer config hook might overwrite the settings you have here. One solution might be to require("emuhr.scnvim") in the packer config hook instead, or simply comment out the call to scnvim.setup.

emuhr commented

Hi,

Thanks for the quick response.
Indeed commenting out the call to scnvim.setup in the packer config did the trick.