From c4a9ece8a1777208213e19a71298f5943a66fc64 Mon Sep 17 00:00:00 2001 From: disrupted Date: Fri, 25 Sep 2026 16:48:53 +0200 Subject: [PATCH] fix(keymap): don't warn for preserved existing keymaps --- lua/opencode/keymap.lua | 8 +++++--- tests/unit/keymap_spec.lua | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/opencode/keymap.lua b/lua/opencode/keymap.lua index b8a56ba22..40c0da01c 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 c63927384..e80898eea 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)