From 6064a5a1a7ed5d78714c45c84291d3fbc930a6f1 Mon Sep 17 00:00:00 2001 From: lyrathorpe Date: Tue, 23 Jun 2026 16:33:12 +0100 Subject: [PATCH] feat(editor): add nvim-cmp completion keymaps (#40) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #39. nvim-cmp ships no default keymaps, so the completion menu (including the path source) appeared but nothing could navigate or accept it. Bind the usual set in `plugins.cmp.settings.mapping`: - `` / `` and `` / `` — select next/previous - `` — open the menu - `` — abort - `` — confirm with `select = false` (bare Enter stays a newline unless an entry is highlighted) Documentation: `KEYBINDINGS.md` gains a completion-menu table under the Neovim section covering these keys, and the Neovim summary is reworded accordingly. Verified by rendering the generated nvim config: the mappings emit as raw Lua (e.g. `[""] = cmp.mapping.confirm({ select = false })`), not quoted strings. --------- Co-authored-by: Emma Thorpe Reviewed-on: https://code.emmathe.dev/lyrathorpe/nixfiles/pulls/40 --- lyrathorpe/home/KEYBINDINGS.md | 20 ++++++++++++++++---- lyrathorpe/home/editor.nix | 12 ++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lyrathorpe/home/KEYBINDINGS.md b/lyrathorpe/home/KEYBINDINGS.md index a64d2f1..fb6a2fd 100644 --- a/lyrathorpe/home/KEYBINDINGS.md +++ b/lyrathorpe/home/KEYBINDINGS.md @@ -188,10 +188,22 @@ across vim splits and tmux panes seamlessly. Everything else is stock vim, plus: | `rn` | Rename symbol (LSP; `` is `Space`) | | `ca` | Code action (LSP) | -LSP covers Nix, Lua, Python and Terraform (the work box adds C# and Helm); -completion (nvim-cmp) appears as you type. Files are formatted on save -(conform-nvim). `:Git` opens fugitive; gitsigns shows gutter signs. which-key -pops up after `` to show the rest. +### Completion menu (nvim-cmp) + +Active only while the completion popup is open (it appears as you type, e.g. +file paths): + +| Shortcut | Action | +| ----------------------- | ------------------------------------------------------------------ | +| `Tab` / `Shift`+`Tab` | Select next / previous item | +| `Ctrl`+`n` / `Ctrl`+`p` | Select next / previous item | +| `Ctrl`+`Space` | Open the completion menu | +| `Enter` | Confirm the highlighted item (no auto-select; otherwise a newline) | +| `Ctrl`+`e` | Dismiss the menu | + +LSP covers Nix, Lua, Python and Terraform (the work box adds C# and Helm). +Files are formatted on save (conform-nvim). `:Git` opens fugitive; gitsigns +shows gutter signs. which-key pops up after `` to show the rest. --- diff --git a/lyrathorpe/home/editor.nix b/lyrathorpe/home/editor.nix index a6569cc..23f37e7 100644 --- a/lyrathorpe/home/editor.nix +++ b/lyrathorpe/home/editor.nix @@ -89,6 +89,18 @@ enable = true; autoEnableSources = true; settings = { + # nvim-cmp ships no default keymaps; without these the menu shows but + # nothing accepts it. confirm uses select=false so a bare stays a + # newline unless an entry is explicitly highlighted. + mapping = { + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.confirm({ select = false })"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.abort()"; + }; snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end"; sources = [ { name = "nvim_lsp"; }