hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
7.88k stars 394 forks source link

Mapping Enter or Shift-Enter does not work as expected #1804

Closed f4T1H21 closed 8 months ago

f4T1H21 commented 8 months ago

FAQ

Announcement

Minimal reproducible full config

According to this My Kitty conf

map shift+enter send_text all \x1b[13;2u
map ctrl+enter send_text all \x1b[13;5u

According to this My Tmux conf

bind -n S-Enter send-keys Escape "[13;2u"
bind -n C-Enter send-keys Escape "[13;5u"

And according to your configuration example My nvim-cmp conf

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

  ["<S-CR>"] = require("cmp").mapping.confirm({ select = true }),
  ["<C-CR>"] = require("cmp").mapping.confirm({ select = true }),
}
return M

Description

Hello, Everything seems alright according to the references I shared above. My mappings for selecting next/prev item and aborting does work. This indicates that I'm at the right point and my nvim-cmp configuration file does work along with all the other configurations!

Although my configutations and mappings also works for Control + Enter, I can't make them work for Enter and Shift+Enter. The problem seems to occur in only those two keys/mappings. I appreciate any help!

P.S: I use NvChad

Steps to reproduce

Try my configurations

Expected behavior

Explained in the description

Actual behavior

Explained in the description

Additional context

No response

danhngo-lx commented 2 months ago

I'm seeing similar problem, in which key mapping is working like mapping, meaning Shift - Enter does not work at all. My config:

                    ["<CR>"] = cmp.mapping.confirm({ select = true }),
                    ["<S-CR>"] = cmp.mapping.abort(),

Pressing Shift-Enter has the effect like pressing Enter.

f4T1H21 commented 2 months ago

Good luck to you on finding a solution. If you do so, please share it here so everybody can benefit from it.