Skip to content

[BUG] cmp.cmdline.<name>.mapping doesnt work for non-presets #3030

Open
@0x5a4

Description

@0x5a4
Field Description
Plugin cmp
Nixpkgs unstable
Home Manager unstable
  • I have read the FAQ and my bug is not listed there.

Description

The option plugins.cmp.cmdline.<name>.mapping doesnt seem to work as intended. It works if you use a preset, but specifying the keymaps manually doesnt produce the output expected by cmp.

cmp wants them to look like this:

{
  ["<C-j>"] = {
    c = cmp.mapping.select_next_item()
  },
  ["<C-k>"] = {
    c = cmp.mapping.select_prev_item()
  },
  ["<esc>"] = {
    c = cmp.mapping.abort(),
  },
  ["<CR>"] = {
    c = cmp.mapping.confirm({ select = false }),
  },
}

while nixvim generates this:

{
  ["<C-j>"] = cmp.mapping.select_next_item(),
  ["<C-k>"] = cmp.mapping.select_prev_item(),
  ["<esc>"] = cmp.mapping.abort(),
  ["<CR>"] = cmp.mapping.confirm({ select = false }),
}

Quick and dirty workaround ist to just use mkRaw

Minimal, Reproducible Example (MRE)

programs.nixvim = {
  plugins.cmp = {
    enable = true;
    cmdline.":" = {
      sources = [ { name = "cmdline"; } ];
      mapping = {
        "<C-j>" = "cmp.mapping.select_next_item()";
        "<C-k>" = "cmp.mapping.select_next_item()";
        "<esc>" = "cmp.mapping.select_next_item()";
        "<CR>" = "cmp.mapping.select_next_item()";
      };
    };
  };
};

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions