Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set cmp keyboard shortcuts correctly #2762

Closed
Acisama opened this issue Dec 28, 2024 · 1 comment
Closed

How to set cmp keyboard shortcuts correctly #2762

Acisama opened this issue Dec 28, 2024 · 1 comment

Comments

@Acisama
Copy link

Acisama commented Dec 28, 2024

I am in the process of migrating my nvim config to nixvim and I love it so far.

But for cmp, the keymaps just don't seem to trigger for some reason.
I want it to start with nothing, tab and shift-tab to navigate between the suggestions and ctrl+space to select a suggestion.

My cmp.nix:

{
  enable = true;
  settings = {
    preselect = "cmp.PreselectMode.None";

    sources = [
      { name = "nvim_lsp"; }
      { name = "path"; }
      { name = "buffer"; }
      { name = "luasnip"; }
    ];

    window = {
      completion.border = "rounded";
      documentation = {
        border = "rounded";
      };
    };

    mappings = {
      "<Tab>" = "cmp.mapping.select_next_item()";
      "<S-Tab>" = "cmp.mapping.select_prev_item()";
      "<C-space>" = "cmp.mapping.confirm({ select = false })";
      "<esc>" = "cmp.mapping.abort()";
    };
  };
}
@traxys
Copy link
Member

traxys commented Dec 28, 2024

You need to use raw values to insert lua, for example "<Tab>".__raw = "cmp.mapping.<...>". See the documentation for some more details

@traxys traxys closed this as completed Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants