accept_word keymap not registered when configured via opts (lazy.nvim/LazyVim), but works when using config with direct setup() call · Issue #721 · zbirenbaum/copilot.lua · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
accept_word keymap not registered when configured via opts (lazy.nvim/LazyVim), but works when using config with direct setup() call #721
When setting accept_word inside suggestion.keymap via lazy.nvim's opts (or LazyVim's default opts merge), the key mapping is never created. However, if I use the config function to directly call require("copilot").setup({...}) with the exact same configuration, the mapping works perfectly. Other keymaps like accept, next, prev are correctly registered under the same opts table. The underlying function require("copilot.suggestion").accept_word() works fine when called directly.
After this configuration, pressing <M-w> while a suggestion is visible correctly accepts the first word. :verbose imap <M-w> shows the mapping.
Expected Behavior
Both opts and config approaches should produce the same result: the accept_word keymap should be registered.
Actual Behavior
Only the config approach works. The opts approach fails to register the accept_word mapping, while other keymaps (accept, next, prev) work fine in both approaches.
Additional Observations
Calling require("copilot.suggestion").accept_word() directly (e.g., via :lua) works correctly – the function itself is not broken.
The issue is specifically about keymap registration when using opts. It seems the accept_word entry in the keymap table is silently ignored during the setup process when configuration comes from merged opts.
Using a single character ("w", ";") instead of a modifier combination ("<M-w>") also fails in the opts approach.
Environment
Neovim version: 0.11.0+
Plugin manager: lazy.nvim (also tested with LazyVim distribution)
copilot.lua version: latest (commit d521d39 as of testing)
OS: Linux / macOS
Possible Cause
The difference between opts and config suggests that lazy.nvim's opts merging process may alter the keymap table in a way that causes accept_word to be dropped or not recognized by copilot.lua's internal setup. Alternatively, copilot.lua's handling of keymap may have a condition that only applies when the table comes from certain sources.
Workaround
Use config function to call require("copilot").setup(...) directly – this is the reliable way to configure accept_word.
changed the title [-]accept_wordkeymap not registered when configured via opts(lazy.nvim/LazyVim), but works when using configwith direct setup()call[/-][+]accept_word keymap not registered when configured via opts (lazy.nvim/LazyVim), but works when using config with direct setup() call[/+]on Jul 8, 2026
Activity
[-]accept_wordkeymap not registered when configured via opts(lazy.nvim/LazyVim), but works when using configwith direct setup()call[/-][+]accept_word keymap not registered when configured via opts (lazy.nvim/LazyVim), but works when using config with direct setup() call[/+]