diff --git a/lua/opencode/keymap.lua b/lua/opencode/keymap.lua index b8a56ba2..40c0da01 100644 --- a/lua/opencode/keymap.lua +++ b/lua/opencode/keymap.lua @@ -80,13 +80,15 @@ local function process_keymap_entry(keymap_config, default_modes, base_opts, pre local opts = vim.tbl_deep_extend('force', {}, base_opts) opts.desc = config_entry.desc or vim.tbl_get(command_defs, func_name, 'desc') or '' - if callback and #modes > 0 then + if not callback then + if type(func_name) ~= 'string' then + vim.notify(string.format('No action found for keymap: %s -> %s', key_binding, func_name), vim.log.levels.WARN) + end + elseif #modes > 0 then if config_entry.defer_to_completion then callback = wrap_with_completion_check(key_binding, callback) end vim.keymap.set(modes, key_binding, callback, opts) - elseif type(func_name) ~= 'string' then - vim.notify(string.format('No action found for keymap: %s -> %s', key_binding, func_name), vim.log.levels.WARN) end end end diff --git a/tests/unit/keymap_spec.lua b/tests/unit/keymap_spec.lua index c6392738..e80898ee 100644 --- a/tests/unit/keymap_spec.lua +++ b/tests/unit/keymap_spec.lua @@ -239,6 +239,7 @@ describe('opencode.keymap', function() }, bufnr, true) assert.equal(0, #set_keymaps) + assert.equal(0, #notify_calls) vim.g.mapleader = original_mapleader vim.api.nvim_buf_delete(bufnr, { force = true }) end)